Replace runTestCase with assert helpers [test/language/statements]

This commit is contained in:
André Bargull 2015-08-13 17:33:42 +02:00
parent 2d5e7e0d44
commit ee8a222125
56 changed files with 85 additions and 425 deletions

View File

@ -11,12 +11,6 @@ description: >
when a Function constructor is contained in strict mode code
within eval code
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
eval("'use strict'; var _13_0_17_fun = new Function('eval = 42;'); _13_0_17_fun();");
return true;
}
runTestCase(testcase);

View File

@ -10,19 +10,10 @@ description: >
Strict Mode - SourceElements is evaluated as strict mode code when
the code of this FunctionExpression is contained in non-strict
mode but the call to eval is a direct call in strict mode code
flags: [noStrict]
includes: [runTestCase.js]
flags: [onlyStrict]
---*/
function testcase() {
"use strict";
try {
assert.throws(SyntaxError, function() {
eval("var _13_0_8_fun = function () {eval = 42;};");
_13_0_8_fun();
return false;
} catch (e) {
return e instanceof SyntaxError;
}
}
runTestCase(testcase);
});

View File

@ -6,17 +6,7 @@ es5id: 13.1-1-1
description: >
Duplicate identifier allowed in non-strict function declaration
parameter list
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval('function foo(a,a){}');
return true;
}
catch (e) { return false }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-1-2
description: >
Duplicate identifier allowed in non-strict function expression
parameter list
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval('(function foo(a,a){})');
return true;
}
catch (e) { return false }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-2-1
description: >
eval allowed as formal parameter name of a non-strict function
declaration
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("function foo(eval){};");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-2-5
description: >
arguments allowed as formal parameter name of a non-strict
function declaration
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("function foo(arguments){};");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,13 +6,7 @@ es5id: 13.1-2-6
description: >
arguments allowed as formal parameter name of a non-strict
function expression
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
eval("(function foo(arguments){});");
return true;
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-3-1
description: >
eval allowed as function identifier in non-strict function
declaration
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("function eval(){};");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-3-2
description: >
eval allowed as function identifier in non-strict function
expression
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("(function eval(){});");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-3-7
description: >
arguments allowed as function identifier in non-strict function
declaration
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("function arguments (){};");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,17 +6,7 @@ es5id: 13.1-3-8
description: >
arguments allowed as function identifier in non-strict function
expression
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase()
{
try
{
eval("(function arguments (){});");
return true;
}
catch (e) { }
}
runTestCase(testcase);

View File

@ -6,17 +6,10 @@ es5id: 13.2-11-s
description: >
StrictMode - enumerating over a function object looking for
'caller' fails outside of the function
includes: [runTestCase.js]
---*/
function testcase() {
var foo = Function("'use strict';");
for (var tempIndex in foo) {
if (tempIndex === "caller") {
return false;
}
assert.notSameValue(tempIndex, "caller", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -6,11 +6,7 @@ es5id: 13.2-12-s
description: >
StrictMode - enumerating over a function object looking for
'caller' fails inside the function
includes: [runTestCase.js]
---*/
function testcase() {
var foo = Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"caller\") {return false;}}; return true;");
return foo.call(foo);
}
runTestCase(testcase);
var foo = Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'caller', 'tempIndex');}");
foo.call(foo);

View File

@ -6,17 +6,10 @@ es5id: 13.2-15-s
description: >
StrictMode - enumerating over a function object looking for
'arguments' fails outside of the function
includes: [runTestCase.js]
---*/
function testcase() {
var foo = new Function("'use strict';");
for (var tempIndex in foo) {
if (tempIndex === "arguments") {
return false;
}
assert.notSameValue(tempIndex, "arguments", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -6,11 +6,7 @@ es5id: 13.2-16-s
description: >
StrictMode - enumerating over a function object looking for
'arguments' fails inside the function
includes: [runTestCase.js]
---*/
function testcase() {
var foo = new Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"arguments\") {return false;}}; return true;");
return foo.call(foo);
}
runTestCase(testcase);
var foo = new Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'arguments', 'tempIndex');}");
foo.call(foo);

View File

@ -6,17 +6,10 @@ es5id: 13.2-19-s
description: >
StrictMode - enumerating over a function object looking for
'arguments' fails outside of the function
includes: [runTestCase.js]
---*/
function testcase() {
var foo = Function("'use strict';");
for (var tempIndex in foo) {
if (tempIndex === "arguments") {
return false;
}
assert.notSameValue(tempIndex, "arguments", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -7,11 +7,7 @@ description: >
StrictMode - enumerating over a function object looking for
'arguments' fails inside the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var foo = Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"arguments\") {return false;}}; return true;");
return foo.call(foo);
}
runTestCase(testcase);
var foo = Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'arguments', 'tempIndex');}");
foo.call(foo);

View File

@ -7,16 +7,9 @@ description: >
StrictMode - enumerating over a function object looking for
'caller' fails outside of the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function foo () {"use strict";}
for (var tempIndex in foo) {
if (tempIndex === "caller") {
return false;
}
assert.notSameValue(tempIndex, "caller", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -7,19 +7,13 @@ description: >
StrictMode - enumerating over a function object looking for
'caller' fails inside the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function foo () {
"use strict";
for (var tempIndex in this) {
if (tempIndex==="caller") {
return false;
}
assert.notSameValue(tempIndex, "caller", 'tempIndex');
}
return true;
}
return foo.call(foo);
}
runTestCase(testcase);
foo.call(foo);

View File

@ -7,17 +7,10 @@ description: >
StrictMode - enumerating over a function object looking for
'arguments' fails outside of the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function foo () {"use strict";}
for (var tempIndex in foo) {
if (tempIndex === "arguments") {
return false;
}
assert.notSameValue(tempIndex, "arguments", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -7,19 +7,12 @@ description: >
StrictMode - enumerating over a function object looking for
'arguments' fails inside the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
function foo() {
"use strict";
for (var tempIndex in this) {
if (tempIndex==="arguments") {
return false;
}
assert.notSameValue(tempIndex, "arguments", 'tempIndex');
}
return true;
}
return foo.call(foo);
}
runTestCase(testcase);
foo.call(foo);

View File

@ -6,14 +6,11 @@ es5id: 13.2-3-s
description: >
StrictMode - Writing or reading from a property named 'arguments'
of function objects is allowed under both strict and normal modes.
includes: [runTestCase.js]
---*/
function testcase() {
var foo = function () {
this.arguments = 12;
}
var obj = new foo();
return obj.arguments === 12;
}
runTestCase(testcase);
assert.sameValue(obj.arguments, 12, 'obj.arguments');

View File

@ -7,17 +7,10 @@ description: >
StrictMode - enumerating over a function object looking for
'caller' fails outside of the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var foo = new Function("'use strict';");
for (var tempIndex in foo) {
if (tempIndex === "caller") {
return false;
}
assert.notSameValue(tempIndex, "caller", 'tempIndex');
}
return true;
}
runTestCase(testcase);

View File

@ -7,11 +7,7 @@ description: >
StrictMode - enumerating over a function object looking for
'caller' fails inside the function
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var foo = new Function("'use strict'; for (var tempIndex in this) {if (tempIndex===\"caller\") {return false;}}; return true;");
return foo.call(foo);
}
runTestCase(testcase);
var foo = new Function("'use strict'; for (var tempIndex in this) {assert.notSameValue(tempIndex, 'caller', 'tempIndex');}");
foo.call(foo);

View File

@ -7,10 +7,8 @@ description: >
catch doesn't change declaration scope - var initializer in catch
with same name as catch parameter changes parameter
features: [AnnexB]
includes: [runTestCase.js]
---*/
function testcase() {
foo = "prior to throw";
try {
throw new Error();
@ -18,7 +16,5 @@ function testcase() {
catch (foo) {
var foo = "initializer in catch";
}
return foo === "prior to throw";
}
runTestCase(testcase);
assert.sameValue(foo, "prior to throw");

View File

@ -4,10 +4,8 @@
/*---
es5id: 12.14-10
description: catch introduces scope - name lookup finds function parameter
includes: [runTestCase.js]
---*/
function testcase() {
function f(o) {
function innerf(o, x) {
@ -21,9 +19,5 @@ function testcase() {
return innerf(o, 42);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -4,10 +4,8 @@
/*---
es5id: 12.14-11
description: catch introduces scope - name lookup finds inner variable
includes: [runTestCase.js]
---*/
function testcase() {
function f(o) {
function innerf(o) {
@ -23,9 +21,5 @@ function testcase() {
return innerf(o);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -4,10 +4,8 @@
/*---
es5id: 12.14-12
description: catch introduces scope - name lookup finds property
includes: [runTestCase.js]
---*/
function testcase() {
function f(o) {
function innerf(o) {
@ -21,9 +19,5 @@ function testcase() {
return innerf(o);
}
if (f({x:42}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({x:42}), 42);

View File

@ -7,10 +7,8 @@ description: >
catch doesn't change declaration scope - var initializer in catch
with same name as catch parameter changes parameter
features: [AnnexB]
includes: [runTestCase.js]
---*/
function testcase() {
function capturedFoo() {return foo};
foo = "prior to throw";
try {
@ -18,8 +16,6 @@ function testcase() {
}
catch (foo) {
var foo = "initializer in catch";
return capturedFoo() !== "initializer in catch";
}
}
runTestCase(testcase);
assert.sameValue(capturedFoo(), "prior to throw");

View File

@ -14,17 +14,13 @@ es5id: 12.14-3
description: >
catch doesn't change declaration scope - var declaration are
visible outside when name different from catch parameter
includes: [runTestCase.js]
---*/
function testcase() {
try {
throw new Error();
}
catch (e) {
var foo = "declaration in catch";
}
return foo === "declaration in catch";
}
runTestCase(testcase);
assert.sameValue(foo, "declaration in catch");

View File

@ -12,10 +12,8 @@ info: >
eval should use the appended object to the scope chain
es5id: 12.14-4
description: catch introduces scope - block-local vars must shadow outer vars
includes: [runTestCase.js]
---*/
function testcase() {
var o = { foo : 42};
try {
@ -23,10 +21,6 @@ function testcase() {
}
catch (e) {
var foo;
if (foo === undefined) {
return true;
}
}
}
runTestCase(testcase);
assert.sameValue(foo, undefined);

View File

@ -14,10 +14,8 @@ es5id: 12.14-6
description: >
catch introduces scope - block-local function expression must
shadow outer function expression
includes: [runTestCase.js]
---*/
function testcase() {
var o = {foo : function () { return 42;}};
try {
@ -25,9 +23,6 @@ function testcase() {
}
catch (e) {
var foo = function () {};
if (foo() === undefined) {
return true;
}
}
}
runTestCase(testcase);
assert.sameValue(foo(), undefined);

View File

@ -12,10 +12,8 @@ info: >
eval should use the appended object to the scope chain
es5id: 12.14-7
description: catch introduces scope - scope removed when exiting catch block
includes: [runTestCase.js]
---*/
function testcase() {
var o = {foo: 1};
var catchAccessed = false;
@ -25,13 +23,14 @@ function testcase() {
catch (expObj) {
catchAccessed = (expObj.foo == 1);
}
assert(catchAccessed, '(expObj.foo == 1)');
catchAccessed = false;
try {
expObj;
}
catch (e) {
return catchAccessed && e instanceof ReferenceError
catchAccessed = e instanceof ReferenceError
}
return false;
}
runTestCase(testcase);
assert(catchAccessed, 'e instanceof ReferenceError');

View File

@ -14,10 +14,8 @@ es5id: 12.14-8
description: >
catch introduces scope - scope removed when exiting catch block
(properties)
includes: [runTestCase.js]
---*/
function testcase() {
var o = {foo: 42};
try {
@ -27,8 +25,4 @@ function testcase() {
var foo = 1;
}
if (o.foo === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(o.foo, 42);

View File

@ -4,10 +4,8 @@
/*---
es5id: 12.14-9
description: catch introduces scope - name lookup finds outer variable
includes: [runTestCase.js]
---*/
function testcase() {
function f(o) {
var x = 42;
@ -22,9 +20,5 @@ function testcase() {
return innerf(o);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -7,15 +7,14 @@ description: >
Strict Mode - SyntaxError isn't thrown if a TryStatement with a
Catch occurs within strict code and the Identifier of the Catch
production is EVAL
includes: [runTestCase.js]
---*/
function testcase() {
var isInstance = false;
try {
throw new Error("...");
return false;
} catch (EVAL) {
return EVAL instanceof Error;
isInstance = EVAL instanceof Error;
}
}
runTestCase(testcase);
assert(isInstance);

View File

@ -7,15 +7,14 @@ description: >
Strict Mode - SyntaxError isn't thrown if a TryStatement with a
Catch occurs within strict code and the Identifier of the Catch
production is Arguments
includes: [runTestCase.js]
---*/
function testcase() {
var isInstance = false;
try {
throw new Error("...");
return false;
} catch (Arguments) {
return Arguments instanceof Error;
isInstance = Arguments instanceof Error;
}
}
runTestCase(testcase);
assert(isInstance);

View File

@ -7,15 +7,14 @@ description: >
Strict Mode - SyntaxError isn't thrown if a TryStatement with a
Catch occurs within strict code and the Identifier of the Catch
production is ARGUMENTS
includes: [runTestCase.js]
---*/
function testcase() {
var isInstance = false;
try {
throw new Error("...");
return false;
} catch (ARGUMENTS) {
return ARGUMENTS instanceof Error;
isInstance = ARGUMENTS instanceof Error;
}
}
runTestCase(testcase);
assert(isInstance);

View File

@ -4,12 +4,10 @@
/*---
es5id: 12.2.1-11
description: arguments as var identifier in eval code is allowed
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
eval("var arguments;");
return true;
}
runTestCase(testcase);
testcase();

View File

@ -4,12 +4,7 @@
/*---
es5id: 12.2.1-12
description: arguments as local var identifier is allowed
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
eval("(function (){var arguments;})");
return true;
}
runTestCase(testcase);

View File

@ -6,11 +6,6 @@ es5id: 12.2.1-16-s
description: >
A Function constructor (called as a function) declaring a var
named 'arguments' does not throw a SyntaxError
includes: [runTestCase.js]
---*/
function testcase() {
Function('var arguments;');
return true;
}
runTestCase(testcase);

View File

@ -8,12 +8,7 @@ description: >
'arguments' will not throw any error if contained within strict
mode and its body does not start with strict mode
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var f = Function('arguments = 42;');
f();
return true;
}
runTestCase(testcase);

View File

@ -6,12 +6,7 @@ es5id: 12.2.1-20-s
description: >
Strict Mode: an indirect eval declaring a var named 'arguments'
does not throw
includes: [runTestCase.js]
---*/
function testcase() {
var s = eval;
s('var arguments;');
return true;
}
runTestCase(testcase);

View File

@ -6,12 +6,7 @@ es5id: 12.2.1-21-s
description: >
Strict Mode: an indirect eval assigning into 'arguments' does not
throw
includes: [runTestCase.js]
---*/
function testcase() {
var s = eval;
s('arguments = 42;');
return true;
}
runTestCase(testcase);

View File

@ -5,12 +5,7 @@
es5id: 12.2.1-9-s
description: >
an indirect eval declaring a var named 'eval' does not throw
includes: [runTestCase.js]
---*/
function testcase() {
var s = eval;
s('var eval;');
return true;
}
runTestCase(testcase);

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-10
description: with introduces scope - name lookup finds function parameter
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
function f(o) {
function innerf(o, x) {
@ -19,9 +17,5 @@ function testcase() {
return innerf(o, 42);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-11
description: with introduces scope - name lookup finds inner variable
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
function f(o) {
function innerf(o) {
@ -21,9 +19,5 @@ function testcase() {
return innerf(o);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-12
description: with introduces scope - name lookup finds property
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
function f(o) {
function innerf(o) {
@ -19,9 +17,5 @@ function testcase() {
return innerf(o);
}
if (f({x:42}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({x:42}), 42);

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-7
description: with introduces scope - scope removed when exiting with statement
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = {foo: 1};
with (o) {
@ -17,9 +15,8 @@ function testcase() {
try {
foo;
throw new Error();
}
catch (e) {
return true;
assert(e instanceof ReferenceError);
}
}
runTestCase(testcase);

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-9
description: with introduces scope - name lookup finds outer variable
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
function f(o) {
var x = 42;
@ -20,9 +18,5 @@ function testcase() {
return innerf(o);
}
if (f({}) === 42) {
return true;
}
}
runTestCase(testcase);
assert.sameValue(f({}), 42);

View File

@ -4,23 +4,13 @@
/*---
es5id: 12.10-2-1
description: with - expression being Number
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = 2;
var foo = 1;
try
{
with (o) {
foo = 42;
}
}
catch(e)
{
}
return true;
}
runTestCase(testcase);
assert.sameValue(foo, 42);

View File

@ -4,23 +4,13 @@
/*---
es5id: 12.10-2-2
description: with - expression being Boolean
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = true;
var foo = 1;
try
{
with (o) {
foo = 42;
}
}
catch(e)
{
}
return true;
}
runTestCase(testcase);
assert.sameValue(foo, 42);

View File

@ -4,23 +4,13 @@
/*---
es5id: 12.10-2-3
description: with - expression being string
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = "str";
var foo = 1;
try
{
with (o) {
foo = 42;
}
}
catch(e)
{
}
return true;
}
runTestCase(testcase);
assert.sameValue(foo, 42);

View File

@ -4,28 +4,21 @@
/*---
es5id: 12.10-7-1
description: with introduces scope - restores the earlier environment on exit
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var a = 1;
var o = {a : 2};
try
{
try {
with (o) {
a = 3;
throw 1;
a = 4;
}
}
catch(e)
{}
if (a === 1 && o.a === 3) {
return true;
} catch (e) {
// intentionally ignored
}
}
runTestCase(testcase);
assert.sameValue(a, 1, 'a');
assert.sameValue(o.a, 3, 'o.a');

View File

@ -7,13 +7,8 @@ description: >
Strict Mode - SyntaxError isn't thrown when WithStatement body is
in strict mode code
flags: [noStrict]
includes: [runTestCase.js]
---*/
function testcase() {
with ({}) {
"use strict";
}
return true;
}
runTestCase(testcase);

View File

@ -7,13 +7,6 @@ description: >
with statement allowed in nested Function even if its container
Function is strict)
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
Function("\'use strict\'; var f1 = Function( \"var o = {}; with (o) {};\")");
return true;
}
runTestCase(testcase);