JavaScript Tests - update tests to account for bug 408957, not part of the build

This commit is contained in:
bclary@bclary.com 2008-01-05 17:18:47 -08:00
Родитель 1cb341361c
Коммит 8fd2612448
11 изменённых файлов: 349 добавлений и 113 удалений

Просмотреть файл

@ -53,7 +53,17 @@ function test()
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
(function() { for(i=0;i<4;++i) let x = 4; }); try
{
eval('(function() { for(i=0;i<4;++i) let x = 4; })');
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
}
reportCompare(expect, actual, summary); reportCompare(expect, actual, summary);

Просмотреть файл

@ -52,8 +52,18 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
with({}) let y; try
{
eval('with({}) let y;');
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
}
reportCompare(expect, actual, summary); reportCompare(expect, actual, summary);

Просмотреть файл

@ -52,8 +52,18 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
let(z) { with({}) let y = 3; } try
{
eval('let(z) { with({}) let y = 3; }');
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
}
reportCompare(expect, actual, summary); reportCompare(expect, actual, summary);

Просмотреть файл

@ -52,8 +52,18 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
switch(let (a) 2) { case 0: let b; } try
{
eval('switch(let (a) 2) { case 0: let b; }');
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
}
reportCompare(expect, actual, summary); reportCompare(expect, actual, summary);

Просмотреть файл

@ -39,6 +39,8 @@ var gTestfile = 'regress-351070-01.js';
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
var BUGNUMBER = 351070; var BUGNUMBER = 351070;
var summary = 'decompilation of let declaration should not change scope'; var summary = 'decompilation of let declaration should not change scope';
var summarytrunk = 'let declaration must be direct child of block or top-level implicit block';
var actual = ''; var actual = '';
var expect = ''; var expect = '';
@ -52,24 +54,49 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var f = function () { var a = 2; if (!!true) let a = 3; return a; }
expect = 'function () { var a = 2; if (!!true) let a = 3; return a; }';
actual = f + '';
compareSource(expect, actual, summary);
expect = 3; var f;
actual = f(); var c;
reportCompare(expect, actual, summary);
f = function () { var a = 2; if (!!true) {let a = 3;} return a; } try
expect = 'function () { var a = 2; if (!!true) { let a = 3;} return a; }'; {
actual = f + ''; c = '(function () { var a = 2; if (!!true) let a = 3; return a; })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function () { var a = 2; if (!!true) let a = 3; return a; }';
actual = f + '';
compareSource(expect, actual, summary);
expect = 2; expect = 3;
actual = f(); actual = f();
reportCompare(expect, actual, summary); reportCompare(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
try
{
c = '(function () { var a = 2; if (!!true) {let a = 3;} return a; })';
f = eval(c);
expect = 'function () { var a = 2; if (!!true) { let a = 3;} return a; }';
actual = f + '';
compareSource(expect, actual, summary);
expect = 2;
actual = f();
reportCompare(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -39,6 +39,7 @@ var gTestfile = 'regress-351070-03.js';
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
var BUGNUMBER = 351070; var BUGNUMBER = 351070;
var summary = 'decompilation of let declaration should not change scope'; var summary = 'decompilation of let declaration should not change scope';
var summarytrunk = 'let declaration must be direct child of block or top-level implicit block';
var actual = ''; var actual = '';
var expect = ''; var expect = '';
@ -52,43 +53,121 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var c;
var f; var f;
f = function (x){if (x) if (y) z; else let w } try
expect = 'function (x){if (x) {if (y) { z; } else let w; }}'; {
actual = f + ''; c = '(function (x){if (x) if (y) z; else let w })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function (x){if (x) {if (y) { z; } else let w; }}';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function (x){if (x){ if (y) z;} else let w } try
expect = 'function (x){if (x){ if (y) {z;}} else let w; }'; {
actual = f + ''; c = '(function (x){if (x){ if (y) z;} else let w })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function (x){if (x){ if (y) {z;}} else let w; }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function (x){if (x){ if (y) let z;} else let w } try
expect = 'function (x){if (x){ if (y) let z;} else let w; }'; {
actual = f + ''; c = '(function (x){if (x){ if (y) let z;} else let w })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function (x){if (x){ if (y) let z;} else let w; }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function f(){var a = 2; if (x) {let a = 3; print(a)} return a} try
expect = 'function f(){var a = 2; if (x) {let a = 3; print(a);} return a;}'; {
actual = f + ''; c = '(function f(){var a = 2; if (x) {let a = 3; print(a)} return a})';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function f(){var a = 2; if (x) {let a = 3; print(a);} return a;}';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function f(){var a = 2; if (x) {print(a);let a = 3} return a} try
expect = 'function f(){var a = 2; if (x) {print(a);let a = 3;} return a;}'; {
actual = f + ''; c = '(function f(){var a = 2; if (x) {print(a);let a = 3} return a})';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function f(){var a = 2; if (x) {print(a);let a = 3;} return a;}';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function f(){var a = 2; if (x) {let a = 3} return a} try
expect = 'function f(){var a = 2; if (x) {let a = 3;} return a;}'; {
actual = f + ''; c = '(function f(){var a = 2; if (x) {let a = 3} return a})';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function f(){var a = 2; if (x) {let a = 3;} return a;}';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
f = function f(){var a = 2; if (x) let a = 3; return a} try
expect = 'function f(){var a = 2; if (x) let a = 3; return a;}'; {
actual = f + ''; c = '(function f(){var a = 2; if (x) let a = 3; return a})';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function f(){var a = 2; if (x) let a = 3; return a;}';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -52,12 +52,26 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var c;
var f; var f;
f = function() { if(g) h; else let x; }
expect = 'function() { if(g) { h; } else let x; }'; try
actual = f + ''; {
compareSource(expect, actual, summary); c = '(function() { if(g) h; else let x; })';
f = eval(c);
expect = 'function() { if(g) { h; } else let x; }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summary);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -52,13 +52,26 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var c;
var f; var f;
f = function() { if(x) { } else if (y) let b=2; } try
expect = 'function() { if(x) { } else if (y) let b=2; }'; {
actual = f + ''; c = '(function() { if(x) { } else if (y) let b=2; })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function() { if(x) { } else if (y) let b=2; }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
summary = 'let declaration must be direct child of block or top-level implicit block';
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summary);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -39,6 +39,7 @@ var gTestfile = 'regress-352732.js';
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
var BUGNUMBER = 352732; var BUGNUMBER = 352732;
var summary = 'Decompiling "if (x) L: let x;"'; var summary = 'Decompiling "if (x) L: let x;"';
var summarytrunk = 'let declaration must be direct child of block or top-level implicit block';
var actual = ''; var actual = '';
var expect = ''; var expect = '';
@ -52,16 +53,41 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var f = (function() { if (x) L: let x; });
expect = 'function() { if (x) { L: let x; } }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function() { if (x) L: let x; else y; }); var c;
expect = 'function() { if (x) { L: let x; } else { y;} }'; var f;
actual = f + '';
compareSource(expect, actual, summary); try
{
c = '(function() { if (x) L: let x; })';
f = eval(c);
expect = 'function() { if (x) { L: let x; } }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
try
{
c = '(function() { if (x) L: let x; else y; })';
f = eval(c);
expect = 'function() { if (x) { L: let x; } else { y;} }';
actual = f + '';
compareSource(expect, actual, summary);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -40,6 +40,7 @@ var gTestfile = 'regress-356247.js';
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
var BUGNUMBER = 356247; var BUGNUMBER = 356247;
var summary = 'Decompilation of let {} = [1] in a loop'; var summary = 'Decompilation of let {} = [1] in a loop';
var summarytrunk = 'let declaration must be direct child of block or top-level implicit block';
var actual = ''; var actual = '';
var expect = ''; var expect = '';
@ -53,25 +54,50 @@ function test()
enterFunc ('test'); enterFunc ('test');
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var f = function() { for(let x in []) let {} = [1]; };
expect = 'function() { for(let x in []) let [] = [1]; }';
actual = f + '';
compareSource(expect, actual, summary);
var g = eval('(' + f + ')'); var c;
actual = g + ''; var f;
compareSource(expect, actual, summary); var g;
f = function() { while(0) let {} = [1]; }; try
expect = 'function() { while(0) let [] = [1]; }'; {
actual = f + ''; c = '(function() { for(let x in []) let {} = [1]; })';
compareSource(expect, actual, summary); f = eval(c);
expect = 'function() { for(let x in []) let [] = [1]; }';
actual = f + '';
compareSource(expect, actual, summary + ': f : ' + c);
g = eval('(' + f + ')'); g = eval('(' + f + ')');
actual = g + ''; actual = g + '';
compareSource(expect, actual, summary); compareSource(expect, actual, summary + ': g : ' + c);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
try
{
c = '(function() { while(0) let {} = [1]; })';
f = eval(c);
expect = 'function() { while(0) let [] = [1]; }';
actual = f + '';
compareSource(expect, actual, summary + ': f : ' + c);
g = eval('(' + f + ')');
actual = g + '';
compareSource(expect, actual, summary + ': g : ' + c);
}
catch(ex)
{
// See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summarytrunk + ': ' + c);
}
exitFunc ('test'); exitFunc ('test');
} }

Просмотреть файл

@ -53,38 +53,49 @@ function test()
printBugNumber(BUGNUMBER); printBugNumber(BUGNUMBER);
printStatus (summary); printStatus (summary);
var pfx = "(function f() { var n = 2, a = 2; ", try
decl = " let a = 3;", {
end = " return a; })"; var pfx = "(function f() { var n = 2, a = 2; ",
decl = " let a = 3;",
end = " return a; })";
var table = [ var table = [
["if (!!true)", ""], ["if (!!true)", ""],
["if (!!true)", " else foopy();"], ["if (!!true)", " else foopy();"],
["if (!true); else", ""], ["if (!true); else", ""],
["do ", " while (false);"], ["do ", " while (false);"],
["while (--n)", ""], ["while (--n)", ""],
["for (--n;n;--n)", ""], ["for (--n;n;--n)", ""],
["for (a in this)", ""], ["for (a in this)", ""],
["with (this)", ""], ["with (this)", ""],
]; ];
expect = 3; expect = 3;
for (i = 0; i < table.length; i++) { for (i = 0; i < table.length; i++) {
var src = pfx + table[i][0] + decl + table[i][1] + end; var src = pfx + table[i][0] + decl + table[i][1] + end;
print('src: ' + src); print('src: ' + src);
var fun = eval(src); var fun = eval(src);
var testval = fun(); var testval = fun();
reportCompare(expect, testval, summary + ': ' + src); reportCompare(expect, testval, summary + ': ' + src);
if (testval != expect) { if (testval != expect) {
break; break;
}
print('uneval: ' + uneval(fun));
var declsrc = '(' +
src.slice(1, -1).replace('function f', 'function f' + i) + ')';
print('declsrc: ' + declsrc);
this['f' + i] = eval(declsrc);
print('f' + i + ': ' + this['f' + i]);
} }
print('uneval: ' + uneval(fun)); }
var declsrc = '(' + catch(ex)
src.slice(1, -1).replace('function f', 'function f' + i) + ')'; {
print('declsrc: ' + declsrc); // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
this['f' + i] = eval(declsrc); summary = 'let declaration must be direct child of block or top-level implicit block';
print('f' + i + ': ' + this['f' + i]); expect = 'SyntaxError';
actual = ex.name;
reportCompare(expect, actual, summary);
} }
exitFunc ('test'); exitFunc ('test');