зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1215341 - Update tests. (r=jandem)
This commit is contained in:
Родитель
acb34e89d9
Коммит
b75caf79c0
|
@ -4,8 +4,8 @@
|
|||
(function () {
|
||||
const c = 0;
|
||||
with ({}) {
|
||||
for each (c in [{}, {}]) {
|
||||
"" + c;
|
||||
for each (k in [{}, {}]) {
|
||||
"" + k;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
load(libdir + "asserts.js");
|
||||
|
||||
assertThrowsInstanceOf(function () {
|
||||
eval("function x() { 'use strict'; const x = 4; x = 3; }");
|
||||
}, SyntaxError);
|
||||
assertThrowsInstanceOf(function () {
|
||||
Function("'use strict'; const x = x = 5;");
|
||||
}, SyntaxError)
|
|
@ -1,23 +1,23 @@
|
|||
// Can't assign to const
|
||||
// Can't assign to const is a runtime TypeError
|
||||
|
||||
load(libdir + 'asserts.js');
|
||||
|
||||
function assertSyntaxError(str) {
|
||||
assertThrowsInstanceOf(function () { eval(str); }, SyntaxError);
|
||||
function assertTypeError(str) {
|
||||
assertThrowsInstanceOf(function () { eval(str); }, TypeError);
|
||||
}
|
||||
|
||||
assertSyntaxError("(function() { const x = 3; (function() x++)(); return x })");
|
||||
assertSyntaxError("(function() { const x = 3; (function() x++)(); return x++ })");
|
||||
assertSyntaxError("(function() { const x = 2; (function() x++)(); return ++x })");
|
||||
assertSyntaxError("(function() { const x = 2; (function() x++)(); return x += 1 })");
|
||||
assertTypeError("(function() { const x = 3; (() => x++)(); return x })()");
|
||||
assertTypeError("(function() { const x = 3; (() => x++)(); return x++ })()");
|
||||
assertTypeError("(function() { const x = 2; (() => x++)(); return ++x })()");
|
||||
assertTypeError("(function() { const x = 2; (() => x++)(); return x += 1 })()");
|
||||
|
||||
assertSyntaxError("(function() { const x = 3; x = 1; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; x = 1; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; x++; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; ++x; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; x--; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; --x; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; x += 1; return (function() { return x})() })");
|
||||
assertSyntaxError("(function() { const x = 3; x -= 1; return (function() { return x})() })");
|
||||
assertTypeError("(function() { const x = 3; x = 1; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; x = 1; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; x++; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; ++x; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; x--; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; --x; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; x += 1; return (function() { return x})() })()");
|
||||
assertTypeError("(function() { const x = 3; x -= 1; return (function() { return x})() })()");
|
||||
|
||||
assertSyntaxError("(function() { const x = 3; [x] = [1]; })");
|
||||
assertTypeError("(function() { const x = 3; [x] = [1]; })()");
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// |jit-test| error: SyntaxError
|
||||
// |jit-test| error: TypeError
|
||||
|
||||
const x = 1; x = 2;
|
||||
|
|
|
@ -4,38 +4,16 @@
|
|||
|
||||
if (classesEnabled()) {
|
||||
|
||||
// XXXefaust Because we currently try to do assignment to const as an early
|
||||
// error, sometimes, maybe, this is almost sometimes a syntax error.
|
||||
// It is specced to be a TypeError
|
||||
|
||||
function statementWrapper() {
|
||||
eval("class Foo { constructor() { } tryBreak() { Foo = 4; } }");
|
||||
}
|
||||
|
||||
function expressionWrapper() {
|
||||
// Mmmmm. Lazy parseing means we don't see this as an error until later.
|
||||
eval(`var x = class Foo { constructor() { }; tryBreak() { Foo = 4; } };
|
||||
new x().tryBreak();`);
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(statementWrapper, SyntaxError);
|
||||
assertThrowsInstanceOf(expressionWrapper, TypeError);
|
||||
|
||||
/*
|
||||
var test = `
|
||||
class Foo { constructor() { }; tryBreak() { Foo = 4; } }
|
||||
for (let result of [Foo, class Bar { constructor() { }; tryBreak() { Bar = 4; } }])
|
||||
class Foof { constructor() { }; tryBreak() { Foof = 4; } }
|
||||
for (let result of [Foof, class Bar { constructor() { }; tryBreak() { Bar = 4; } }])
|
||||
assertThrowsInstanceOf(() => new result().tryBreak(), TypeError);
|
||||
|
||||
{
|
||||
class foo { constructor() { }; tryBreak() { foo = 4; } }
|
||||
for (let result of [foo, class Bar { constructor() { }; tryBreak() { Bar = 4 }])
|
||||
for (let result of [foo, class Bar { constructor() { }; tryBreak() { Bar = 4 } }])
|
||||
assertThrowsInstanceOf(() => new result().tryBreak(), TypeError);
|
||||
}
|
||||
`;
|
||||
*/
|
||||
|
||||
var test = `
|
||||
|
||||
// TDZ applies to inner bindings
|
||||
assertThrowsInstanceOf(()=>eval(\`class Bar {
|
||||
|
|
|
@ -174,7 +174,7 @@ catch(ex)
|
|||
reportCompare(expect, actual, summary + section);
|
||||
|
||||
const c = 0;
|
||||
expect = 0;
|
||||
expect = 'error';
|
||||
section = ': for(c in b);';
|
||||
printStatus(section);
|
||||
try
|
||||
|
@ -190,7 +190,7 @@ catch(ex)
|
|||
}
|
||||
reportCompare(expect, actual, summary + section);
|
||||
|
||||
expect = 0;
|
||||
expect = 'error';
|
||||
section = ': function foo(){for(c in b);};foo();';
|
||||
printStatus(section);
|
||||
try
|
||||
|
|
|
@ -20,7 +20,7 @@ function test()
|
|||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'SyntaxError: invalid assignment to const b';
|
||||
expect = 'TypeError: invalid assignment to const `b\'';
|
||||
|
||||
jit(true);
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ function test()
|
|||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'SyntaxError: invalid assignment to const x';
|
||||
try
|
||||
{
|
||||
eval('(function() { const x = 1; for (x in null); })();');
|
||||
|
|
|
@ -21,7 +21,6 @@ function test()
|
|||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'SyntaxError: invalid assignment to const x';
|
||||
try
|
||||
{
|
||||
eval('const x = undefined; for (x in []);');
|
||||
|
|
|
@ -24,10 +24,8 @@ f(w);
|
|||
c = 2;
|
||||
try {
|
||||
eval('"use strict"; function g(x) { const y = x; y = 1 + x; } c = 3');
|
||||
assertEq(0, 1);
|
||||
} catch (e) {
|
||||
assertEq(e.name, 'SyntaxError');
|
||||
assertEq(2, c);
|
||||
assertEq(0, 1);
|
||||
}
|
||||
|
||||
c = 4;
|
||||
|
@ -35,7 +33,7 @@ try {
|
|||
eval('"use strict"; const z = w; z = 1 + w; c = 5');
|
||||
assertEq(0, 1);
|
||||
} catch (e) {
|
||||
assertEq(e.name, 'SyntaxError');
|
||||
assertEq(e.name, 'TypeError');
|
||||
assertEq(4, c);
|
||||
assertEq('z' in this, false);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче