mirror of
https://github.com/tc39/test262.git
synced 2025-07-24 06:25:30 +02:00
Replace runTestCase with assert helpers [test/language/statements/]
This commit is contained in:
parent
713df280e5
commit
3c3e0a6adb
@ -6,10 +6,8 @@ es5id: 12.8-1
|
|||||||
description: >
|
description: >
|
||||||
The break Statement - a break statement without an identifier may
|
The break Statement - a break statement without an identifier may
|
||||||
have a LineTerminator before the semi-colon
|
have a LineTerminator before the semi-colon
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var i = 1; i <= 10; i++) {
|
for (var i = 1; i <= 10; i++) {
|
||||||
if (i === 6) {
|
if (i === 6) {
|
||||||
@ -18,6 +16,5 @@ function testcase() {
|
|||||||
}
|
}
|
||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
return sum === 15;
|
|
||||||
}
|
assert.sameValue(sum, 15, 'sum');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,16 +6,13 @@ es5id: 12.7-1
|
|||||||
description: >
|
description: >
|
||||||
The continue Statement - a continue statement without an
|
The continue Statement - a continue statement without an
|
||||||
identifier may have a LineTerminator before the semi-colon
|
identifier may have a LineTerminator before the semi-colon
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var i = 1; i <= 10; i++) {
|
for (var i = 1; i <= 10; i++) {
|
||||||
continue
|
continue
|
||||||
;
|
;
|
||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
return sum === 0;
|
|
||||||
}
|
assert.sameValue(sum, 0, 'sum');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 12.6.4-1
|
|||||||
description: >
|
description: >
|
||||||
The for-in Statement - a property name must not be visited more
|
The for-in Statement - a property name must not be visited more
|
||||||
than once in any enumeration.
|
than once in any enumeration.
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var obj = { prop1: "abc", prop2: "bbc", prop3: "cnn" };
|
var obj = { prop1: "abc", prop2: "bbc", prop3: "cnn" };
|
||||||
|
|
||||||
var countProp1 = 0;
|
var countProp1 = 0;
|
||||||
@ -29,6 +27,7 @@ function testcase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return countProp1 === 1 && countProp2 === 1 && countProp3 === 1;
|
|
||||||
}
|
assert.sameValue(countProp1, 1, 'countProp1');
|
||||||
runTestCase(testcase);
|
assert.sameValue(countProp2, 1, 'countProp2');
|
||||||
|
assert.sameValue(countProp3, 1, 'countProp3');
|
||||||
|
@ -7,10 +7,8 @@ description: >
|
|||||||
The for-in Statement - the values of [[Enumerable]] attributes are
|
The for-in Statement - the values of [[Enumerable]] attributes are
|
||||||
not considered when determining if a property of a prototype
|
not considered when determining if a property of a prototype
|
||||||
object is shadowed by a previous object on the prototype chain
|
object is shadowed by a previous object on the prototype chain
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var proto = {
|
var proto = {
|
||||||
prop: "enumerableValue"
|
prop: "enumerableValue"
|
||||||
};
|
};
|
||||||
@ -32,6 +30,5 @@ function testcase() {
|
|||||||
accessedProp = true;
|
accessedProp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !accessedProp;
|
|
||||||
}
|
assert.sameValue(accessedProp, false, 'accessedProp');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -11,13 +11,7 @@ description: >
|
|||||||
when a Function constructor is contained in strict mode code and
|
when a Function constructor is contained in strict mode code and
|
||||||
the function constructor body is not strict
|
the function constructor body is not strict
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var _13_0_12_fun = new Function(" ","eval = 42;");
|
var _13_0_12_fun = new Function(" ","eval = 42;");
|
||||||
_13_0_12_fun();
|
_13_0_12_fun();
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,13 +6,7 @@ es5id: 13.1-2-2
|
|||||||
description: >
|
description: >
|
||||||
eval allowed as formal parameter name of a non-strict function
|
eval allowed as formal parameter name of a non-strict function
|
||||||
expression
|
expression
|
||||||
includes: [runTestCase.js]
|
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase()
|
|
||||||
{
|
|
||||||
eval("(function foo(eval){});");
|
eval("(function foo(eval){});");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,14 +6,11 @@ es5id: 13.2-1-s
|
|||||||
description: >
|
description: >
|
||||||
StrictMode - Writing or reading from a property named 'caller' of
|
StrictMode - Writing or reading from a property named 'caller' of
|
||||||
function objects is allowed under both strict and normal modes.
|
function objects is allowed under both strict and normal modes.
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var foo = function () {
|
var foo = function () {
|
||||||
this.caller = 12;
|
this.caller = 12;
|
||||||
}
|
}
|
||||||
var obj = new foo();
|
var obj = new foo();
|
||||||
return obj.caller === 12;
|
|
||||||
}
|
assert.sameValue(obj.caller, 12, 'obj.caller');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,10 +6,8 @@ es5id: 12.9-1
|
|||||||
description: >
|
description: >
|
||||||
The return Statement - a return statement without an expression
|
The return Statement - a return statement without an expression
|
||||||
may have a LineTerminator before the semi-colon
|
may have a LineTerminator before the semi-colon
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
(function innerTest() {
|
(function innerTest() {
|
||||||
for (var i = 1; i <= 10; i++) {
|
for (var i = 1; i <= 10; i++) {
|
||||||
@ -20,6 +18,5 @@ function testcase() {
|
|||||||
sum += i;
|
sum += i;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return sum === 15;
|
|
||||||
}
|
assert.sameValue(sum, 15, 'sum');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,12 +4,7 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.2.1-10-s
|
es5id: 12.2.1-10-s
|
||||||
description: "Strict Mode: an indirect eval assigning into 'eval' does not throw"
|
description: "Strict Mode: an indirect eval assigning into 'eval' does not throw"
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var s = eval;
|
var s = eval;
|
||||||
s('eval = 42;');
|
s('eval = 42;');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -5,11 +5,6 @@
|
|||||||
es5id: 12.2.1-5-s
|
es5id: 12.2.1-5-s
|
||||||
description: >
|
description: >
|
||||||
a Function declaring var named 'eval' does not throw SyntaxError
|
a Function declaring var named 'eval' does not throw SyntaxError
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
Function('var eval;');
|
Function('var eval;');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -8,12 +8,7 @@ description: >
|
|||||||
if contained within strict mode and its body does not start with
|
if contained within strict mode and its body does not start with
|
||||||
strict mode
|
strict mode
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
includes: [runTestCase.js]
|
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var f = Function('eval = 42;');
|
var f = Function('eval = 42;');
|
||||||
f();
|
f();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -6,11 +6,9 @@ es5id: 12.10-0-1
|
|||||||
description: >
|
description: >
|
||||||
with does not change declaration scope - vars in with are visible
|
with does not change declaration scope - vars in with are visible
|
||||||
outside
|
outside
|
||||||
includes: [runTestCase.js]
|
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = {};
|
var o = {};
|
||||||
var f = function () {
|
var f = function () {
|
||||||
/* capture foo binding before executing with */
|
/* capture foo binding before executing with */
|
||||||
@ -21,7 +19,4 @@ function testcase() {
|
|||||||
var foo = "12.10-0-1";
|
var foo = "12.10-0-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
return f()==="12.10-0-1"
|
assert.sameValue(f(), "12.10-0-1", 'f()');
|
||||||
|
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.10-0-3
|
es5id: 12.10-0-3
|
||||||
description: with introduces scope - that is captured by function expression
|
description: with introduces scope - that is captured by function expression
|
||||||
includes: [runTestCase.js]
|
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = {prop: "12.10-0-3 before"};
|
var o = {prop: "12.10-0-3 before"};
|
||||||
var f;
|
var f;
|
||||||
|
|
||||||
@ -16,6 +14,5 @@ function testcase() {
|
|||||||
f = function () { return prop; }
|
f = function () { return prop; }
|
||||||
}
|
}
|
||||||
o.prop = "12.10-0-3 after";
|
o.prop = "12.10-0-3 after";
|
||||||
return f()==="12.10-0-3 after"
|
|
||||||
}
|
assert.sameValue(f(), "12.10-0-3 after", 'f()');
|
||||||
runTestCase(testcase);
|
|
||||||
|
@ -4,17 +4,13 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.10-0-8
|
es5id: 12.10-0-8
|
||||||
description: with introduces scope - var initializer sets like named property
|
description: with introduces scope - var initializer sets like named property
|
||||||
includes: [runTestCase.js]
|
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function testcase() {
|
|
||||||
var o = {foo: 42};
|
var o = {foo: 42};
|
||||||
|
|
||||||
with (o) {
|
with (o) {
|
||||||
var foo = "set in with";
|
var foo = "set in with";
|
||||||
}
|
}
|
||||||
|
|
||||||
return o.foo === "set in with";
|
assert.sameValue(o.foo, "set in with", 'o.foo');
|
||||||
}
|
|
||||||
runTestCase(testcase);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user