Streamline redundant `eval` tests (#570)

Some tests for `eval` assert the equality of key enumeration on the
global object, comparing the ordering when the object is referenced
through eval.

Based on the test bodies and the "info" field in their metadata, these
tests appear to have been written under the mistaken impression that
erroneous creation of an environment record would be observable through
the `this` value.

In reality, the value in such cases resolves to the global object. That
renders these tests redundant and overly complex--none of the
distinctions between each test actually demonstrates a different
behavior.

Remove the redundant tests and introduce three new tests asserting the
correct resolution of the `this` keyword for direct eval code from
within the global scope and from within function scope.
This commit is contained in:
jugglinmike 2016-04-18 13:35:03 -04:00 committed by Leo Balter
parent 3723e7caeb
commit a068f19f06
33 changed files with 44 additions and 896 deletions

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T1
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
x = 1;
y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T10
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
var x = 1;
var y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T11
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
this.x = 1;
this.y = 2;

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T12
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var x = 1;
var y = 2;

View File

@ -1,27 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T13
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
this.x = 1;
this.y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T14
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
var x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var y = 2;

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T15
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
this.y = 2;

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T16
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
var x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
this.y = 2;

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T17
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var y = 2;

View File

@ -1,27 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T18
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
var x = 1;
var y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T19
description: eval within global execution context
---*/
var i;
var j;
var str1 = '';
var str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
this.x = 1;
this.y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T2
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var x = 1;
var y = 2;

View File

@ -1,28 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T3
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
this.y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T4
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T5
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
var x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T6
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
this.y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T7
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T8
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
var y = 2;

View File

@ -1,29 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.1_T9
description: eval within global execution context
flags: [noStrict]
---*/
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
if(!(str1 === str2)){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}
x = 1;
y = 2;

View File

@ -1,31 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T1
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
x = 1;
y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,32 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T10
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
var x = 1;
var y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T11
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
this.x = 1;
this.y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,32 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T2
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
var x = 1;
var y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,32 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T3
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
this.y = 2;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T4
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T5
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
var x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
var y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T6
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
this.y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T7
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
var y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T8
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
this.x = 1;
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
var y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -1,33 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
The scope chain is initialised to contain the same objects,
in the same order, as the calling context's scope chain
es5id: 10.4.2_A1.2_T9
description: eval within global execution context
flags: [noStrict]
---*/
function f(){
var i;
var j;
str1 = '';
str2 = '';
for(i in this){
str1+=i;
}
eval('for(j in this){\nstr2+=j;\n}');
return (str1 === str2);
x = 1;
y = 2;
}
if(!f()){
$ERROR("#1: scope chain must contain same objects in the same order as the calling context");
}

View File

@ -0,0 +1,17 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Direct eval code has the same `this` binding as the calling context
(non-strict function scope)
esid: sec-performeval
flags: [noStrict]
---*/
var thisValue;
(function() {
thisValue = eval('this;');
}());
assert.sameValue(thisValue, this);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Direct eval code has the same `this` binding as the calling context (strict
function scope)
esid: sec-performeval
flags: [onlyStrict]
---*/
var thisValue = null;
(function() {
thisValue = eval('this;');
}());
assert.sameValue(thisValue, undefined);

View File

@ -0,0 +1,10 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Direct eval code has the same `this` binding as the calling context (global
scope)
esid: sec-performeval
---*/
assert.sameValue(eval('this;'), this);