Replace runTestCase with assert helpers [test/language/eval-code]

This commit is contained in:
André Bargull 2015-08-13 17:32:19 +02:00
parent 27b234f708
commit ba1b02a047
12 changed files with 36 additions and 65 deletions

View File

@ -4,17 +4,13 @@
/*--- /*---
es5id: 10.4.2-1-1 es5id: 10.4.2-1-1
description: Indirect call to eval has context set to global context description: Indirect call to eval has context set to global context
includes: [runTestCase.js]
---*/ ---*/
var __10_4_2_1_1_1 = "str"; var __10_4_2_1_1_1 = "str";
function testcase() { function testcase() {
var _eval = eval; var _eval = eval;
var __10_4_2_1_1_1 = "str1"; var __10_4_2_1_1_1 = "str1";
if(_eval("\'str\' === __10_4_2_1_1_1") === true && // indirect eval assert(_eval("\'str\' === __10_4_2_1_1_1"), 'indirect eval');
eval("\'str1\' === __10_4_2_1_1_1") === true) { // direct eval assert(eval("\'str1\' === __10_4_2_1_1_1"), 'direct eval');
return true;
}
return false;
} }
runTestCase(testcase); testcase();

View File

@ -6,7 +6,6 @@ es5id: 10.4.2-1-2
description: > description: >
Indirect call to eval has context set to global context (nested Indirect call to eval has context set to global context (nested
function) function)
includes: [runTestCase.js]
---*/ ---*/
var __10_4_2_1_2 = "str"; var __10_4_2_1_2 = "str";
@ -15,13 +14,9 @@ function testcase() {
var __10_4_2_1_2 = "str1"; var __10_4_2_1_2 = "str1";
function foo() { function foo() {
var __10_4_2_1_2 = "str2"; var __10_4_2_1_2 = "str2";
if(_eval("\'str\' === __10_4_2_1_2") === true && // indirect eval assert(_eval("\'str\' === __10_4_2_1_2"), 'indirect eval');
eval("\'str2\' === __10_4_2_1_2") === true) { // direct eval assert(eval("\'str2\' === __10_4_2_1_2"), 'direct eval');
return true;
} else {
return false;
}
} }
return foo(); foo();
} }
runTestCase(testcase); testcase();

View File

@ -6,7 +6,6 @@ es5id: 10.4.2-1-3
description: > description: >
Indirect call to eval has context set to global context (catch Indirect call to eval has context set to global context (catch
block) block)
includes: [runTestCase.js]
---*/ ---*/
var __10_4_2_1_3 = "str"; var __10_4_2_1_3 = "str";
@ -18,12 +17,8 @@ function testcase() {
} }
catch (e) { catch (e) {
var __10_4_2_1_3 = "str2"; var __10_4_2_1_3 = "str2";
if (_eval("\'str\' === __10_4_2_1_3") === true && // indirect eval assert(_eval("\'str\' === __10_4_2_1_3"), 'indirect eval');
eval("\'str2\' === __10_4_2_1_3") === true) { // direct eval assert(eval("\'str2\' === __10_4_2_1_3"), 'direct eval');
return true;
} else {
return false;
}
} }
} }
runTestCase(testcase); testcase();

View File

@ -7,7 +7,6 @@ description: >
Indirect call to eval has context set to global context (with Indirect call to eval has context set to global context (with
block) block)
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
var __10_4_2_1_4 = "str"; var __10_4_2_1_4 = "str";
@ -17,11 +16,8 @@ function testcase() {
var _eval = eval; var _eval = eval;
var __10_4_2_1_4 = "str1"; var __10_4_2_1_4 = "str1";
with (o) { with (o) {
if (_eval("\'str\' === __10_4_2_1_4") === true && // indirect eval assert(_eval("\'str\' === __10_4_2_1_4"), 'indirect eval');
eval("\'str2\' === __10_4_2_1_4") === true) { // direct eval assert(eval("\'str2\' === __10_4_2_1_4"), 'direct eval');
return true;
}
} }
return false;
} }
runTestCase(testcase); testcase();

View File

@ -6,7 +6,6 @@ es5id: 10.4.2-1-5
description: > description: >
Indirect call to eval has context set to global context (inside Indirect call to eval has context set to global context (inside
another eval) another eval)
includes: [runTestCase.js]
---*/ ---*/
var __10_4_2_1_5 = "str"; var __10_4_2_1_5 = "str";
@ -18,6 +17,6 @@ function testcase() {
_eval(\"\'str\' === __10_4_2_1_5 \") && \ _eval(\"\'str\' === __10_4_2_1_5 \") && \
eval(\"\'str2\' === __10_4_2_1_5\")\ eval(\"\'str2\' === __10_4_2_1_5\")\
"); ");
return r; assert(r);
} }
runTestCase(testcase); testcase();

View File

@ -7,15 +7,14 @@ description: >
Direct val code in non-strict mode - can instantiate variable in Direct val code in non-strict mode - can instantiate variable in
calling context calling context
flags: [noStrict] flags: [noStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
var x = 0; var x = 0;
return function inner() { function inner() {
eval("var x = 1"); eval("var x = 1");
if (x === 1) assert.sameValue(x, 1, "x");
return true; }
} (); inner();
} }
runTestCase(testcase); testcase();

View File

@ -7,11 +7,10 @@ description: >
Strict Mode - Strict mode eval code cannot instantiate functions Strict Mode - Strict mode eval code cannot instantiate functions
in the variable environment of the caller to eval in the variable environment of the caller to eval
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
eval("function fun(x){ return x }"); eval("function fun(x){ return x }");
return typeof (fun) === "undefined"; assert.sameValue(typeof (fun), "undefined");
} }
runTestCase(testcase); testcase();

View File

@ -6,15 +6,14 @@ es5id: 10.4.2-3-c-1-s
description: > description: >
Direct eval code in strict mode - cannot instantiate variable in Direct eval code in strict mode - cannot instantiate variable in
the variable environment of the calling context the variable environment of the calling context
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
var _10_4_2_3_c_1_s = 0; var _10_4_2_3_c_1_s = 0;
function _10_4_2_3_c_1_sFunc() { function _10_4_2_3_c_1_sFunc() {
eval("'use strict';var _10_4_2_3_c_1_s = 1"); eval("'use strict';var _10_4_2_3_c_1_s = 1");
return _10_4_2_3_c_1_s===0; assert.sameValue(_10_4_2_3_c_1_s, 0);
} }
return _10_4_2_3_c_1_sFunc(); _10_4_2_3_c_1_sFunc();
} }
runTestCase(testcase); testcase();

View File

@ -7,15 +7,14 @@ description: >
Calling code in strict mode - eval cannot instantiate variable in Calling code in strict mode - eval cannot instantiate variable in
the variable environment of the calling context the variable environment of the calling context
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
var _10_4_2_3_c_2_s = 0; var _10_4_2_3_c_2_s = 0;
function _10_4_2_3_c_2_sFunc() { function _10_4_2_3_c_2_sFunc() {
eval("var _10_4_2_3_c_2_s = 1"); eval("var _10_4_2_3_c_2_s = 1");
return _10_4_2_3_c_2_s===0; assert.sameValue(_10_4_2_3_c_2_s, 0);
} }
return _10_4_2_3_c_2_sFunc(); _10_4_2_3_c_2_sFunc();
} }
runTestCase(testcase); testcase();

View File

@ -7,15 +7,11 @@ description: >
Calling code in strict mode - eval cannot instantiate variable in Calling code in strict mode - eval cannot instantiate variable in
the global context the global context
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
var _10_4_2_3_c_3_s = 0; var _10_4_2_3_c_3_s = 0;
function testcase() { function testcase() {
function _10_4_2_3_c_3_sFunc() { eval("var _10_4_2_3_c_3_s = 1");
eval("var _10_4_2_3_c_3_s = 1"); assert.sameValue(_10_4_2_3_c_3_s, 0);
return _10_4_2_3_c_3_s===0;
}
return _10_4_2_3_c_3_sFunc();
} }
runTestCase(testcase); testcase();

View File

@ -7,11 +7,10 @@ description: >
Strict Mode - Strict mode eval code cannot instantiate functions Strict Mode - Strict mode eval code cannot instantiate functions
in the variable environment of the caller to eval in the variable environment of the caller to eval
flags: [onlyStrict] flags: [onlyStrict]
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
eval("function _10_4_2_1_2_fun(){}"); eval("function _10_4_2_1_2_fun(){}");
return typeof _10_4_2_1_2_fun === "undefined"; assert.sameValue(typeof _10_4_2_1_2_fun, "undefined");
} }
runTestCase(testcase); testcase();

View File

@ -6,11 +6,10 @@ es5id: 10.4.2.1-4-s
description: > description: >
Strict Mode - Strict mode eval code cannot instantiate functions Strict Mode - Strict mode eval code cannot instantiate functions
in the variable environment of the caller to eval. in the variable environment of the caller to eval.
includes: [runTestCase.js]
---*/ ---*/
function testcase() { function testcase() {
eval("'use strict'; function _10_4_2_1_4_fun(){}"); eval("'use strict'; function _10_4_2_1_4_fun(){}");
return typeof _10_4_2_1_4_fun === "undefined"; assert.sameValue(typeof _10_4_2_1_4_fun, "undefined");
} }
runTestCase(testcase); testcase();