await-expr-resolution.js (1168B)
1 // |reftest| module async 2 // Copyright (C) 2019 Leo Balter. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 description: > 7 AwaitExpression Resolutions 8 info: | 9 ModuleItem: 10 StatementListItem[~Yield, +Await, ~Return] 11 12 ... 13 14 UnaryExpression[Yield, Await] 15 void UnaryExpression[?Yield, ?Await] 16 [+Await]AwaitExpression[?Yield] 17 18 AwaitExpression[Yield]: 19 await UnaryExpression[?Yield, +Await] 20 esid: prod-AwaitExpression 21 flags: [module, async] 22 features: [top-level-await] 23 ---*/ 24 25 var x; 26 27 x = await 42; 28 assert.sameValue(x, 42, 'number'); 29 30 x = await ''; 31 assert.sameValue(x, '', 'string'); 32 33 var s = Symbol(); 34 x = await s; 35 assert.sameValue(x, s, 'symbol'); 36 37 x = await false; 38 assert.sameValue(x, false, 'false'); 39 40 x = await true; 41 assert.sameValue(x, true, 'true'); 42 43 x = await NaN; 44 assert.sameValue(x, NaN, 'NaN'); 45 46 x = await null; 47 assert.sameValue(x, null, 'null'); 48 49 x = await undefined; 50 assert.sameValue(x, undefined, 'undefined'); 51 52 var obj = {}; 53 x = await obj; 54 assert.sameValue(x, obj, 'object'); 55 56 x = await Promise.resolve(1).then(v => v * 2).then(v => v * 3); 57 assert.sameValue(x, 6, 'promise'); 58 59 $DONE();