Skip to content
Snippets Groups Projects
Commit 0ceb428e authored by André Bargull's avatar André Bargull Committed by Brian Terlson
Browse files

Add test coverage for identifier resolution in dynamic scopes

Identifier resolution in dynamic scope context is missing test coverage, resolves https://bugs.ecmascript.org/show_bug.cgi?id=1751 .
parent 485059c4
No related branches found
No related tags found
No related merge requests found
Showing
with 640 additions and 0 deletions
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, rval) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding function environment record is not changed.
flags: [noStrict]
---*/
function testFunction() {
var x = 0;
var scope = {x: 1};
with (scope) {
x = (delete scope.x, 2);
}
if (scope.x !== 2) {
$ERROR('#1: scope.x === 2. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
}
testFunction();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, rval) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding global environment record is not changed.
flags: [noStrict]
---*/
var x = 0;
var scope = {x: 1};
with (scope) {
x = (delete scope.x, 2);
}
if (scope.x !== 2) {
$ERROR('#1: scope.x === 2. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, rval) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding object environment record is not changed.
flags: [noStrict]
---*/
var outerScope = {x: 0};
var innerScope = {x: 1};
with (outerScope) {
with (innerScope) {
x = (delete innerScope.x, 2);
}
}
if (innerScope.x !== 2) {
$ERROR('#1: innerScope.x === 2. Actual: ' + (innerScope.x));
}
if (outerScope.x !== 0) {
$ERROR('#2: outerScope.x === 0. Actual: ' + (outerScope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, rval) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when assignment is in strict-mode code and the
original binding is no longer present.
flags: [noStrict]
---*/
var scope = {x: 1};
with (scope) {
(function() {
"use strict";
x = (delete scope.x, 2);
})();
}
if (scope.x !== 2) {
$ERROR('#1: scope.x === 2. Actual: ' + (scope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, rval) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when assignment is in strict-mode code and the
original binding is no longer present.
includes:
- fnGlobalObject.js
---*/
Object.defineProperty(fnGlobalObject(), "x", {
configurable: true,
value: 1
});
(function() {
"use strict";
x = (delete fnGlobalObject().x, 2);
})();
if (fnGlobalObject().x !== 2) {
$ERROR('#1: fnGlobalObject().x === 2. Actual: ' + (fnGlobalObject().x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
declarative environment record. PutValue(lref, rval) uses the initially
created Reference even if a more local binding is available.
flags: [noStrict]
---*/
function testAssignment() {
var x = 0;
var innerX = (function() {
x = (eval("var x;"), 1);
return x;
})();
if (innerX !== undefined) {
$ERROR('#1: innerX === undefined. Actual: ' + (innerX));
}
if (x !== 1) {
$ERROR('#2: x === 1. Actual: ' + (x));
}
}
testAssignment();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
declarative environment record. PutValue(lref, rval) uses the initially
created Reference even if a more local binding is available.
flags: [noStrict]
---*/
function testAssignment() {
var x = 0;
var innerX = (function() {
x = (eval("var x = 2;"), 1);
return x;
})();
if (innerX !== 2) {
$ERROR('#1: innerX === 2. Actual: ' + (innerX));
}
if (x !== 1) {
$ERROR('#2: x === 1. Actual: ' + (x));
}
}
testAssignment();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Assignment Operator calls PutValue(lref, rval)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
declarative environment record. PutValue(lref, rval) uses the initially
created Reference even if a more local binding is available.
flags: [noStrict]
---*/
function testAssignment() {
var x = 0;
var scope = {};
with (scope) {
x = (scope.x = 2, 1);
}
if (scope.x !== 2) {
$ERROR('#1: scope.x === 2. Actual: ' + (scope.x));
}
if (x !== 1) {
$ERROR('#2: x === 1. Actual: ' + (x));
}
}
testAssignment();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding function environment record is not changed.
Check operator is "x ^= y".
flags: [noStrict]
---*/
function testFunction() {
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x ^= 3;
}
if (scope.x !== 1) {
$ERROR('#1: scope.x === 1. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
}
testFunction();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding global environment record is not changed.
Check operator is "x ^= y".
flags: [noStrict]
---*/
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x ^= 3;
}
if (scope.x !== 1) {
$ERROR('#1: scope.x === 1. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding object environment record is not changed.
Check operator is "x ^= y".
flags: [noStrict]
---*/
var outerScope = {
x: 0
};
var innerScope = {
get x() {
delete this.x;
return 2;
}
};
with (outerScope) {
with (innerScope) {
x ^= 3;
}
}
if (innerScope.x !== 1) {
$ERROR('#1: innerScope.x === 1. Actual: ' + (innerScope.x));
}
if (outerScope.x !== 0) {
$ERROR('#2: outerScope.x === 0. Actual: ' + (outerScope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when 'x ^= y' is in strict-mode code and the
original binding is no longer present.
Check operator is "x ^= y".
flags: [noStrict]
---*/
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
(function() {
"use strict";
x ^= 3;
})();
}
if (scope.x !== 1) {
$ERROR('#1: scope.x === 1. Actual: ' + (scope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when 'x ^= y' is in strict-mode code and the
original binding is no longer present.
Check operator is "x ^= y".
includes:
- fnGlobalObject.js
---*/
Object.defineProperty(fnGlobalObject(), "x", {
configurable: true,
get: function() {
delete this.x;
return 2;
}
});
(function() {
"use strict";
x ^= 3;
})();
if (fnGlobalObject().x !== 1) {
$ERROR('#1: fnGlobalObject().x === 1. Actual: ' + (fnGlobalObject().x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding function environment record is not changed.
Check operator is "x |= y".
flags: [noStrict]
---*/
function testFunction() {
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x |= 4;
}
if (scope.x !== 6) {
$ERROR('#1: scope.x === 6. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
}
testFunction();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding global environment record is not changed.
Check operator is "x |= y".
flags: [noStrict]
---*/
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x |= 4;
}
if (scope.x !== 6) {
$ERROR('#1: scope.x === 6. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding object environment record is not changed.
Check operator is "x |= y".
flags: [noStrict]
---*/
var outerScope = {
x: 0
};
var innerScope = {
get x() {
delete this.x;
return 2;
}
};
with (outerScope) {
with (innerScope) {
x |= 4;
}
}
if (innerScope.x !== 6) {
$ERROR('#1: innerScope.x === 6. Actual: ' + (innerScope.x));
}
if (outerScope.x !== 0) {
$ERROR('#2: outerScope.x === 0. Actual: ' + (outerScope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when 'x |= y' is in strict-mode code and the
original binding is no longer present.
Check operator is "x |= y".
flags: [noStrict]
---*/
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
(function() {
"use strict";
x |= 4;
})();
}
if (scope.x !== 6) {
$ERROR('#1: scope.x === 6. Actual: ' + (scope.x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
No ReferenceError is thrown when 'x |= y' is in strict-mode code and the
original binding is no longer present.
Check operator is "x |= y".
includes:
- fnGlobalObject.js
---*/
Object.defineProperty(fnGlobalObject(), "x", {
configurable: true,
get: function() {
delete this.x;
return 2;
}
});
(function() {
"use strict";
x |= 4;
})();
if (fnGlobalObject().x !== 6) {
$ERROR('#1: fnGlobalObject().x === 6. Actual: ' + (fnGlobalObject().x));
}
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding function environment record is not changed.
Check operator is "x *= y".
flags: [noStrict]
---*/
function testFunction() {
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x *= 3;
}
if (scope.x !== 6) {
$ERROR('#1: scope.x === 6. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
}
testFunction();
// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Compound Assignment Operator calls PutValue(lref, v)
description: >
Evaluating LeftHandSideExpression lref returns Reference type; Reference
base value is an environment record and environment record kind is
object environment record. PutValue(lref, v) uses the initially
created Reference even if the environment binding is no longer present.
Binding in surrounding global environment record is not changed.
Check operator is "x *= y".
flags: [noStrict]
---*/
var x = 0;
var scope = {
get x() {
delete this.x;
return 2;
}
};
with (scope) {
x *= 3;
}
if (scope.x !== 6) {
$ERROR('#1: scope.x === 6. Actual: ' + (scope.x));
}
if (x !== 0) {
$ERROR('#2: x === 0. Actual: ' + (x));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment