OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-async-await --allow-natives-syntax | 5 // Flags: --harmony-async-await --allow-natives-syntax |
6 | 6 |
7 function assertThrowsAsync(run, errorType, message) { | 7 function assertThrowsAsync(run, errorType, message) { |
8 var actual; | 8 var actual; |
9 var hadValue = false; | 9 var hadValue = false; |
10 var hadError = false; | 10 var hadError = false; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 var g12 = async (y, g = () => y) => { var y = 2; return g(); }; | 144 var g12 = async (y, g = () => y) => { var y = 2; return g(); }; |
145 assertEqualsAsync(1, () => g12(1)); | 145 assertEqualsAsync(1, () => g12(1)); |
146 var g13 = async ({x}, y, [z], v) => { var x, y, z; return x*y*z*v }; | 146 var g13 = async ({x}, y, [z], v) => { var x, y, z; return x*y*z*v }; |
147 assertEqualsAsync(210, () => g13({x: 2}, 3, [5], 7)); | 147 assertEqualsAsync(210, () => g13({x: 2}, 3, [5], 7)); |
148 | 148 |
149 var g20 = async ({x}) => { function x() { return 2 }; return x(); } | 149 var g20 = async ({x}) => { function x() { return 2 }; return x(); } |
150 assertEqualsAsync(2, () => g20({x: 1})); | 150 assertEqualsAsync(2, () => g20({x: 1})); |
151 var g21 = async ({x}) => { { function x() { return 2 } } return x(); } | 151 var g21 = async ({x}) => { { function x() { return 2 } } return x(); } |
152 assertThrowsAsync(() => g21({x: 1}), TypeError); | 152 assertThrowsAsync(() => g21({x: 1}), TypeError); |
153 | 153 |
154 assertThrows("'use strict'; async function f(x) { let x = 0; }", SyntaxError); | 154 // These errors are not recognized in lazy parsing; see mjsunit/bugs/bug-2728.
js |
155 assertThrows("'use strict'; async function f({x}) { let x = 0; }", SyntaxError
); | 155 assertThrows("'use strict'; (async function f(x) { let x = 0; })()", SyntaxErr
or); |
156 assertThrows("'use strict'; async function f(x) { const x = 0; }", SyntaxError
); | 156 assertThrows("'use strict'; (async function f({x}) { let x = 0; })()", SyntaxE
rror); |
157 assertThrows("'use strict'; async function f({x}) { const x = 0; }", SyntaxErr
or); | 157 assertThrows("'use strict'; (async function f(x) { const x = 0; })()", SyntaxE
rror); |
| 158 assertThrows("'use strict'; (async function f({x}) { const x = 0; })()", Synta
xError); |
158 | 159 |
159 assertThrows("'use strict'; let g = async (x) => { let x = 0; }", SyntaxError)
; | 160 assertThrows("'use strict'; let g = async (x) => { let x = 0; }", SyntaxError)
; |
160 assertThrows("'use strict'; let g = async ({x}) => { let x = 0; }", SyntaxErro
r); | 161 assertThrows("'use strict'; let g = async ({x}) => { let x = 0; }", SyntaxErro
r); |
161 assertThrows("'use strict'; let g = async (x) => { const x = 0; }", SyntaxErro
r); | 162 assertThrows("'use strict'; let g = async (x) => { const x = 0; }", SyntaxErro
r); |
162 assertThrows("'use strict'; let g = async ({x}) => { const x = 0; }", SyntaxEr
ror); | 163 assertThrows("'use strict'; let g = async ({x}) => { const x = 0; }", SyntaxEr
ror); |
163 }()); | 164 }()); |
164 | 165 |
165 (function TestDefaults() { | 166 (function TestDefaults() { |
166 async function f1(x = 1) { return x } | 167 async function f1(x = 1) { return x } |
167 assertEqualsAsync(1, () => f1()); | 168 assertEqualsAsync(1, () => f1()); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 assertEquals(1, (async function(x, y = 1, z, v = 2, ...a) {}).length); | 507 assertEquals(1, (async function(x, y = 1, z, v = 2, ...a) {}).length); |
507 })(); | 508 })(); |
508 | 509 |
509 (function TestDirectiveThrows() { | 510 (function TestDirectiveThrows() { |
510 "use strict"; | 511 "use strict"; |
511 | 512 |
512 assertThrows("(async function(x=1){'use strict';})", SyntaxError); | 513 assertThrows("(async function(x=1){'use strict';})", SyntaxError); |
513 assertThrows("(async function(a, x=1){'use strict';})", SyntaxError); | 514 assertThrows("(async function(a, x=1){'use strict';})", SyntaxError); |
514 assertThrows("(async function({x}){'use strict';})", SyntaxError); | 515 assertThrows("(async function({x}){'use strict';})", SyntaxError); |
515 })(); | 516 })(); |
OLD | NEW |