Refactor tests for eval code

Some tests asserted behavior for both "direct" eval and "indirect" eval.
Split these assertions across files dedicated for each use case.
This commit is contained in:
Mike Pennisi 2016-04-11 12:45:47 -04:00 committed by Leonardo Balter
parent 7630e1763d
commit 364d6433e2
10 changed files with 89 additions and 11 deletions

View File

@ -0,0 +1,20 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-3
description: >
Direct call to eval has context set to local context (catch block)
---*/
var __10_4_2_1_3 = "str";
function testcase() {
var __10_4_2_1_3 = "str1";
try {
throw "error";
}
catch (e) {
var __10_4_2_1_3 = "str2";
assert(eval("\'str2\' === __10_4_2_1_3"), 'direct eval');
}
}
testcase();

View File

@ -0,0 +1,18 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-5
description: >
Direct call to eval has context set to local context (inside another eval)
---*/
var __10_4_2_1_5 = "str";
function testcase() {
var __10_4_2_1_5 = "str1";
var r = eval("\
var __10_4_2_1_5 = \'str2\'; \
eval(\"\'str2\' === __10_4_2_1_5\")\
");
assert(r);
}
testcase();

View File

@ -0,0 +1,18 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-2
description: >
Direct call to eval has context set to local context (nested function)
---*/
var __10_4_2_1_2 = "str";
function testcase() {
var __10_4_2_1_2 = "str1";
function foo() {
var __10_4_2_1_2 = "str2";
assert(eval("\'str2\' === __10_4_2_1_2"), 'direct eval');
}
foo();
}
testcase();

View File

@ -0,0 +1,19 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-4
description: >
Direct call to eval has context set to local context (with block)
flags: [noStrict]
---*/
var __10_4_2_1_4 = "str";
function testcase() {
var o = new Object();
o.__10_4_2_1_4 = "str2";
var __10_4_2_1_4 = "str1";
with (o) {
assert(eval("\'str2\' === __10_4_2_1_4"), 'direct eval');
}
}
testcase();

View File

@ -0,0 +1,13 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-1
description: Direct call to eval has context set to local context
---*/
var __10_4_2_1_1_1 = "str";
function testcase() {
var __10_4_2_1_1_1 = "str1";
assert(eval("\'str1\' === __10_4_2_1_1_1"), 'direct eval');
}
testcase();

View File

@ -1,6 +1,5 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-3
description: >
@ -18,7 +17,6 @@ function testcase() {
catch (e) {
var __10_4_2_1_3 = "str2";
assert(_eval("\'str\' === __10_4_2_1_3"), 'indirect eval');
assert(eval("\'str2\' === __10_4_2_1_3"), 'direct eval');
}
}
testcase();

View File

@ -1,6 +1,5 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-5
description: >
@ -14,8 +13,7 @@ function testcase() {
var r = eval("\
var _eval = eval; \
var __10_4_2_1_5 = \'str2\'; \
_eval(\"\'str\' === __10_4_2_1_5 \") && \
eval(\"\'str2\' === __10_4_2_1_5\")\
_eval(\"\'str\' === __10_4_2_1_5 \") \
");
assert(r);
}

View File

@ -1,6 +1,5 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-2
description: >
@ -15,7 +14,6 @@ function testcase() {
function foo() {
var __10_4_2_1_2 = "str2";
assert(_eval("\'str\' === __10_4_2_1_2"), 'indirect eval');
assert(eval("\'str2\' === __10_4_2_1_2"), 'direct eval');
}
foo();
}

View File

@ -1,6 +1,5 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-4
description: >
@ -17,7 +16,6 @@ function testcase() {
var __10_4_2_1_4 = "str1";
with (o) {
assert(_eval("\'str\' === __10_4_2_1_4"), 'indirect eval');
assert(eval("\'str2\' === __10_4_2_1_4"), 'direct eval');
}
}
testcase();

View File

@ -1,6 +1,5 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 10.4.2-1-1
description: Indirect call to eval has context set to global context
@ -11,6 +10,5 @@ function testcase() {
var _eval = eval;
var __10_4_2_1_1_1 = "str1";
assert(_eval("\'str\' === __10_4_2_1_1_1"), 'indirect eval');
assert(eval("\'str1\' === __10_4_2_1_1_1"), 'direct eval');
}
testcase();