MCPcopy Index your code
hub / github.com/nodejs/node / ordinaryTests

Function ordinaryTests

test/parallel/test-repl-top-level-await.js:70–205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70async function ordinaryTests() {
71 // These tests were created based on
72 // https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-top-level-await.js?rcl=5d0ea979f0ba87655b7ef0e03b58fa3c04986ba6
73 putIn.run([
74 'function foo(x) { return x; }',
75 'function koo() { return Promise.resolve(4); }',
76 ]);
77 const testCases = [
78 ['await Promise.resolve(0)', '0'],
79 ['{ a: await Promise.resolve(1) }', '{ a: 1 }'],
80 ['_', '{ a: 1 }'],
81 ['let { aa, bb } = await Promise.resolve({ aa: 1, bb: 2 }), f = 5;'],
82 ['aa', '1'],
83 ['bb', '2'],
84 ['f', '5'],
85 ['let cc = await Promise.resolve(2)'],
86 ['cc', '2'],
87 ['let dd;'],
88 ['dd'],
89 ['let [ii, { abc: { kk } }] = [0, { abc: { kk: 1 } }];'],
90 ['ii', '0'],
91 ['kk', '1'],
92 ['var ll = await Promise.resolve(2);'],
93 ['ll', '2'],
94 ['foo(await koo())', '4'],
95 ['_', '4'],
96 ['const m = foo(await koo());'],
97 ['m', '4'],
98 ['const n = foo(await\nkoo());',
99 ['const n = foo(await\r', '| koo());\r', 'undefined']],
100 ['n', '4'],
101 // eslint-disable-next-line no-template-curly-in-string
102 ['`status: ${(await Promise.resolve({ status: 200 })).status}`',
103 "'status: 200'"],
104 ['for (let i = 0; i < 2; ++i) await i'],
105 ['for (let i = 0; i < 2; ++i) { await i }'],
106 ['await 0', '0'],
107 ['await 0; function foo() {}'],
108 ['foo', '[Function: foo]'],
109 ['class Foo {}; await 1;', '1'],
110 ['Foo', '[class Foo]'],
111 ['if (await true) { function bar() {}; }'],
112 ['bar', '[Function: bar]'],
113 ['if (await true) { class Bar {}; }'],
114 ['Bar', 'Uncaught ReferenceError: Bar is not defined'],
115 ['await 0; function* gen(){}'],
116 ['for (var i = 0; i < 10; ++i) { await i; }'],
117 ['i', '10'],
118 ['for (let j = 0; j < 5; ++j) { await j; }'],
119 ['j', 'Uncaught ReferenceError: j is not defined', { line: 0 }],
120 ['gen', '[GeneratorFunction: gen]'],
121 ['return 42; await 5;', 'Uncaught SyntaxError: Illegal return statement',
122 { line: 3 }],
123 ['let o = await 1, p'],
124 ['p'],
125 ['let q = 1, s = await 2'],
126 ['s', '2'],
127 ['for await (let i of [1,2,3]) console.log(i)',

Callers 1

mainFunction · 0.85

Calls 7

runAndWaitFunction · 0.70
mapMethod · 0.65
runMethod · 0.45
logMethod · 0.45
splitMethod · 0.45
pushMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected