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

This commit is contained in:
André Bargull 2015-08-06 18:33:10 +02:00
parent 713df280e5
commit 3c3e0a6adb
14 changed files with 18 additions and 73 deletions

View File

@ -6,10 +6,8 @@ es5id: 12.8-1
description: >
The break Statement - a break statement without an identifier may
have a LineTerminator before the semi-colon
includes: [runTestCase.js]
---*/
function testcase() {
var sum = 0;
for (var i = 1; i <= 10; i++) {
if (i === 6) {
@ -18,6 +16,5 @@ function testcase() {
}
sum += i;
}
return sum === 15;
}
runTestCase(testcase);
assert.sameValue(sum, 15, 'sum');

View File

@ -6,16 +6,13 @@ es5id: 12.7-1
description: >
The continue Statement - a continue statement without an
identifier may have a LineTerminator before the semi-colon
includes: [runTestCase.js]
---*/
function testcase() {
var sum = 0;
for (var i = 1; i <= 10; i++) {
continue
;
sum += i;
}
return sum === 0;
}
runTestCase(testcase);
assert.sameValue(sum, 0, 'sum');

View File

@ -6,10 +6,8 @@ es5id: 12.6.4-1
description: >
The for-in Statement - a property name must not be visited more
than once in any enumeration.
includes: [runTestCase.js]
---*/
function testcase() {
var obj = { prop1: "abc", prop2: "bbc", prop3: "cnn" };
var countProp1 = 0;
@ -29,6 +27,7 @@ function testcase() {
}
}
}
return countProp1 === 1 && countProp2 === 1 && countProp3 === 1;
}
runTestCase(testcase);
assert.sameValue(countProp1, 1, 'countProp1');
assert.sameValue(countProp2, 1, 'countProp2');
assert.sameValue(countProp3, 1, 'countProp3');

View File

@ -7,10 +7,8 @@ description: >
The for-in Statement - the values of [[Enumerable]] attributes are
not considered when determining if a property of a prototype
object is shadowed by a previous object on the prototype chain
includes: [runTestCase.js]
---*/
function testcase() {
var proto = {
prop: "enumerableValue"
};
@ -32,6 +30,5 @@ function testcase() {
accessedProp = true;
}
}
return !accessedProp;
}
runTestCase(testcase);
assert.sameValue(accessedProp, false, 'accessedProp');

View File

@ -11,13 +11,7 @@ description: >
when a Function constructor is contained in strict mode code and
the function constructor body is not strict
flags: [onlyStrict]
includes: [runTestCase.js]
---*/
function testcase() {
var _13_0_12_fun = new Function(" ","eval = 42;");
_13_0_12_fun();
return true;
}
runTestCase(testcase);

View File

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

View File

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

View File

@ -6,10 +6,8 @@ es5id: 12.9-1
description: >
The return Statement - a return statement without an expression
may have a LineTerminator before the semi-colon
includes: [runTestCase.js]
---*/
function testcase() {
var sum = 0;
(function innerTest() {
for (var i = 1; i <= 10; i++) {
@ -20,6 +18,5 @@ function testcase() {
sum += i;
}
})();
return sum === 15;
}
runTestCase(testcase);
assert.sameValue(sum, 15, 'sum');

View File

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

View File

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

View File

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

View File

@ -6,11 +6,9 @@ es5id: 12.10-0-1
description: >
with does not change declaration scope - vars in with are visible
outside
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = {};
var f = function () {
/* capture foo binding before executing with */
@ -21,7 +19,4 @@ function testcase() {
var foo = "12.10-0-1";
}
return f()==="12.10-0-1"
}
runTestCase(testcase);
assert.sameValue(f(), "12.10-0-1", 'f()');

View File

@ -4,11 +4,9 @@
/*---
es5id: 12.10-0-3
description: with introduces scope - that is captured by function expression
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = {prop: "12.10-0-3 before"};
var f;
@ -16,6 +14,5 @@ function testcase() {
f = function () { return prop; }
}
o.prop = "12.10-0-3 after";
return f()==="12.10-0-3 after"
}
runTestCase(testcase);
assert.sameValue(f(), "12.10-0-3 after", 'f()');

View File

@ -4,17 +4,13 @@
/*---
es5id: 12.10-0-8
description: with introduces scope - var initializer sets like named property
includes: [runTestCase.js]
flags: [noStrict]
---*/
function testcase() {
var o = {foo: 42};
with (o) {
var foo = "set in with";
}
return o.foo === "set in with";
}
runTestCase(testcase);
assert.sameValue(o.foo, "set in with", 'o.foo');