47 function expectError(src, msg, error) { 48 try { 49 eval(src); 50 Assert.fail(msg); 51 } catch (e) { 52 if (e.name !== error) { 53 Assert.fail('Unexpected error: ' + e); 54 } 55 } 56 } 57 58 expectError('let i = 0', 'let', 'SyntaxError'); 59 expectError('const i = 0', 'const', 'SyntaxError'); 60 expectError('for (let i = 0; i < 10; i++) print(i)', 'for-let', 'SyntaxError'); 61 expectError('0b0', 'numeric literal', 'SyntaxError'); 62 expectError('0o0', 'numeric litera', 'SyntaxError'); 63 expectError('`text`', 'template literal', 'SyntaxError'); 64 expectError('`${ x }`', 'template literal', 'SyntaxError'); 65 expectError('`text ${ x } text`', 'template literal', 'SyntaxError'); 66 expectError('f`text`', 'template literal', 'SyntaxError'); | 47 function expectError(src, msg, error) { 48 try { 49 eval(src); 50 Assert.fail(msg); 51 } catch (e) { 52 if (e.name !== error) { 53 Assert.fail('Unexpected error: ' + e); 54 } 55 } 56 } 57 58 expectError('let i = 0', 'let', 'SyntaxError'); 59 expectError('const i = 0', 'const', 'SyntaxError'); 60 expectError('for (let i = 0; i < 10; i++) print(i)', 'for-let', 'SyntaxError'); 61 expectError('0b0', 'numeric literal', 'SyntaxError'); 62 expectError('0o0', 'numeric litera', 'SyntaxError'); 63 expectError('`text`', 'template literal', 'SyntaxError'); 64 expectError('`${ x }`', 'template literal', 'SyntaxError'); 65 expectError('`text ${ x } text`', 'template literal', 'SyntaxError'); 66 expectError('f`text`', 'template literal', 'SyntaxError'); 67 expectError('for (a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError'); 68 expectError('for (var a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError'); 69 expectError('for (let a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError'); 70 expectError('for (const a of [1, 2, 3]) print(a)', 'for-of', 'SyntaxError'); 71 |