| 1 |
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ |
| 2 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 |
|
| 6 |
//----------------------------------------------------------------------------- |
| 7 |
var BUGNUMBER = 351515; |
| 8 |
var summary = 'Invalid uses of yield, let keywords in js17'; |
| 9 |
var actual = ''; |
| 10 |
var expect = ''; |
| 11 |
|
| 12 |
|
| 13 |
//----------------------------------------------------------------------------- |
| 14 |
test(); |
| 15 |
//----------------------------------------------------------------------------- |
| 16 |
|
| 17 |
try |
| 18 |
{ |
| 19 |
expect = "No Error"; |
| 20 |
eval('yield = 1;'); |
| 21 |
actual = 'No Error'; |
| 22 |
} |
| 23 |
catch(ex) |
| 24 |
{ |
| 25 |
actual = ex.name; |
| 26 |
} |
| 27 |
reportCompare(expect, actual, summary + ': global: yield = 1'); |
| 28 |
|
| 29 |
try |
| 30 |
{ |
| 31 |
expect = "No Error"; |
| 32 |
eval('(function(){yield = 1;})'); |
| 33 |
actual = 'No Error'; |
| 34 |
} |
| 35 |
catch(ex) |
| 36 |
{ |
| 37 |
actual = ex.name; |
| 38 |
} |
| 39 |
reportCompare(expect, actual, summary + ': local: yield = 1'); |
| 40 |
|
| 41 |
try |
| 42 |
{ |
| 43 |
expect = "No Error"; |
| 44 |
eval('let = 1;'); |
| 45 |
actual = 'No Error'; |
| 46 |
} |
| 47 |
catch(ex) |
| 48 |
{ |
| 49 |
actual = ex.name; |
| 50 |
} |
| 51 |
reportCompare(expect, actual, summary + ': global: let = 1'); |
| 52 |
|
| 53 |
function test() |
| 54 |
{ |
| 55 |
printBugNumber(BUGNUMBER); |
| 56 |
printStatus (summary); |
| 57 |
|
| 58 |
try |
| 59 |
{ |
| 60 |
expect = "No Error"; |
| 61 |
eval('function f(yield, let) { return yield+let; }'); |
| 62 |
actual = 'No Error'; |
| 63 |
} |
| 64 |
catch(ex) |
| 65 |
{ |
| 66 |
actual = ex.name; |
| 67 |
} |
| 68 |
reportCompare(expect, actual, summary + |
| 69 |
': function f(yield, let) { return yield+let; }'); |
| 70 |
|
| 71 |
try |
| 72 |
{ |
| 73 |
expect = "No Error"; |
| 74 |
eval('var yield = 1;'); |
| 75 |
actual = 'No Error'; |
| 76 |
} |
| 77 |
catch(ex) |
| 78 |
{ |
| 79 |
actual = ex.name; |
| 80 |
} |
| 81 |
reportCompare(expect, actual, summary + ': function () {var yield;}'); |
| 82 |
|
| 83 |
try |
| 84 |
{ |
| 85 |
expect = "No Error"; |
| 86 |
eval('var let = 1;'); |
| 87 |
actual = 'No Error'; |
| 88 |
} |
| 89 |
catch(ex) |
| 90 |
{ |
| 91 |
actual = ex.name; |
| 92 |
} |
| 93 |
reportCompare(expect, actual, summary + ': function () { var let;}'); |
| 94 |
} |