diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/types/reference | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/types/reference')
31 files changed, 827 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/types/reference/8.7.2-1-s-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-1-s-strict.js new file mode 100644 index 0000000000..4513bdb656 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-1-s-strict.js @@ -0,0 +1,18 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-1-s +description: > + Strict Mode - ReferenceError is thrown if LeftHandSide evaluates + to an unresolvable Reference +flags: [onlyStrict] +---*/ + + +assert.throws(ReferenceError, function() { + eval("_8_7_2_1 = 11;"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-2-s.js b/js/src/tests/test262/language/types/reference/8.7.2-2-s.js new file mode 100644 index 0000000000..607bed0434 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-2-s.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-2-s +description: > + ReferenceError isn't thrown if LeftHandSide evaluates to a resolvable + Reference +---*/ + + var b = 11; + +assert.sameValue(b, 11, 'b'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-3-1-s.js b/js/src/tests/test262/language/types/reference/8.7.2-3-1-s.js new file mode 100644 index 0000000000..06db448896 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-3-1-s.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-3-1-s +description: eval - a property named 'eval' is permitted +---*/ + + var o = { eval: 42}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-3-a-1gs-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-3-a-1gs-strict.js new file mode 100644 index 0000000000..7dae24da59 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-3-a-1gs-strict.js @@ -0,0 +1,17 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-3-a-1gs +description: > + Strict Mode - ReferenceError is thrown if LeftHandSide evaluate to + an unresolvable Reference +flags: [onlyStrict] +---*/ + +assert.throws(ReferenceError, function() { + b = 11; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-3-a-2gs-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-3-a-2gs-strict.js new file mode 100644 index 0000000000..2a47c30665 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-3-a-2gs-strict.js @@ -0,0 +1,18 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-3-a-2gs +description: > + Strict Mode - 'runtime' error is thrown before LeftHandSide + evaluates to an unresolvable Reference +flags: [onlyStrict] +---*/ + +assert.throws(Test262Error, function() { + throw new Test262Error(); + b = 11; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-3-s-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-3-s-strict.js new file mode 100644 index 0000000000..600c8ca8e5 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-3-s-strict.js @@ -0,0 +1,21 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-3-s +description: > + Strict Mode - TypeError is thrown if LeftHandSide is a reference + to a non-writable data property +flags: [onlyStrict] +---*/ + + var _8_7_2_3 = {}; + Object.defineProperty(_8_7_2_3, "b", { + writable: false + }); +assert.throws(TypeError, function() { + _8_7_2_3.b = 11; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-4-s-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-4-s-strict.js new file mode 100644 index 0000000000..391146cf0b --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-4-s-strict.js @@ -0,0 +1,22 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-4-s +description: > + Strict Mode - TypeError is thrown if LeftHandSide is a reference + to an accessor property with no setter +flags: [onlyStrict] +---*/ + + var _8_7_2_4 = {}; + var _8_7_2_4_bValue = 1; + Object.defineProperty(_8_7_2_4, "b", { + get: function () { return _8_7_2_4_bValue; } + }); +assert.throws(TypeError, function() { + _8_7_2_4.b = 11; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-5-s-strict.js b/js/src/tests/test262/language/types/reference/8.7.2-5-s-strict.js new file mode 100644 index 0000000000..4345f82704 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-5-s-strict.js @@ -0,0 +1,19 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-5-s +description: > + Strict Mode - TypeError is thrown if LeftHandSide is a reference + to a non-existent property of an non-extensible object +flags: [onlyStrict] +---*/ + + var _8_7_2_5 = {}; + Object.preventExtensions(_8_7_2_5); +assert.throws(TypeError, function() { + _8_7_2_5.b = 11; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-6-s.js b/js/src/tests/test262/language/types/reference/8.7.2-6-s.js new file mode 100644 index 0000000000..83d556a13d --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-6-s.js @@ -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: 8.7.2-6-s +description: > + TypeError isn't thrown if LeftHandSide is a reference to a writable data + property +---*/ + + var _8_7_2_6 = {}; + Object.defineProperty(_8_7_2_6, "b", { + writable: true + }); + + _8_7_2_6.b = 11; + +assert.sameValue(_8_7_2_6.b, 11, '_8_7_2_6.b'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-7-s.js b/js/src/tests/test262/language/types/reference/8.7.2-7-s.js new file mode 100644 index 0000000000..ffc16ca89b --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-7-s.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-7-s +description: > + TypeError isn't thrown if LeftHandSide is a reference to an accessor + property with setter +---*/ + + var _8_7_2_7 = {}; + var _8_7_2_7_bValue = 1; + Object.defineProperty(_8_7_2_7, "b", { + get: function () { return _8_7_2_7_bValue; }, + set: function (value) { _8_7_2_7_bValue = value; } + }); + + _8_7_2_7.b = 11; + +assert.sameValue(_8_7_2_7.b, 11, '_8_7_2_7.b'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/8.7.2-8-s.js b/js/src/tests/test262/language/types/reference/8.7.2-8-s.js new file mode 100644 index 0000000000..a6dd4f357d --- /dev/null +++ b/js/src/tests/test262/language/types/reference/8.7.2-8-s.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.7.2-8-s +description: > + TypeError isn't thrown if LeftHandSide is a reference to a property of an + extensible object +---*/ + + var _8_7_2_8 = {}; + + _8_7_2_8.b = 11; + +assert.sameValue(_8_7_2_8.b, 11, '_8_7_2_8.b'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7.1_A1.js b/js/src/tests/test262/language/types/reference/S8.7.1_A1.js new file mode 100644 index 0000000000..e921083660 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.1_A1.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Delete operator deletes pure property, so it returns true to be applyed + to this.property +es5id: 8.7.1_A1 +description: Try to delete this.y, where y is this.y=1 +---*/ + +this.y = 1; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if((delete this.y) !== true){ + throw new Test262Error('#1: this.y = 1; (delete this.y) === true. Actual: ' + ((delete this.y))); +}; +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (this.y !== undefined){ + throw new Test262Error('#2: this.y = 1; (delete this.y) === true; this.y === undefined. Actual: ' + (this.y)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7.1_A2.js b/js/src/tests/test262/language/types/reference/S8.7.1_A2.js new file mode 100644 index 0000000000..caa0053891 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.1_A2.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Delete operator can't delete reference, so it returns false to be applyed + to reference +es5id: 8.7.1_A2 +description: Try to delete y, where y is var y=1 +flags: [noStrict] +---*/ + +var y = 1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var result = delete y; +if(result){ + throw new Test262Error('#1: y = 1; (delete y) === false. Actual: ' + result); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (y !== 1) { + throw new Test262Error('#2: y = 1; delete y; y === 1. Actual: ' + (y)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7.2_A1_T1.js b/js/src/tests/test262/language/types/reference/S8.7.2_A1_T1.js new file mode 100644 index 0000000000..a18e421c30 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.2_A1_T1.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: GetValue(V) mast fail +es5id: 8.7.2_A1_T1 +description: Checking if execution of "'litera'=1;" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +'litera'=1; diff --git a/js/src/tests/test262/language/types/reference/S8.7.2_A1_T2.js b/js/src/tests/test262/language/types/reference/S8.7.2_A1_T2.js new file mode 100644 index 0000000000..2256edac7d --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.2_A1_T2.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: GetValue(V) mast fail +es5id: 8.7.2_A1_T2 +description: Checking if execution of "1=1" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +1=1; diff --git a/js/src/tests/test262/language/types/reference/S8.7.2_A2.js b/js/src/tests/test262/language/types/reference/S8.7.2_A2.js new file mode 100644 index 0000000000..c3c1714e83 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.2_A2.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + x++ calls GetValue then PutValue so after applying postfix increment(actually conrete operator type is unimportant) + we must have reference to defined value +es5id: 8.7.2_A2 +description: Execute x++, where x is var x +---*/ + +var x; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (x !== undefined) { + throw new Test262Error('#1: var x; x === undefined. Actual: ' + (x)); +} +// +////////////////////////////////////////////////////////////////////////////// +x++; +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x === undefined) { + throw new Test262Error('#2: var x; x++; x !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7.2_A3.js b/js/src/tests/test262/language/types/reference/S8.7.2_A3.js new file mode 100644 index 0000000000..c513dcc818 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7.2_A3.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + this.x++ calls GetValue then PutValue so after applying postfix increment(actually conrete operator type is unimportan) + we must have reference to defined value +es5id: 8.7.2_A3 +description: Execute this.x++, where this.x is undefined +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (this.x !== undefined) { + throw new Test262Error('#1: this.x === undefined. Actual: ' + (this.x)); +} +// +////////////////////////////////////////////////////////////////////////////// +this.x++; +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (x === undefined) { + throw new Test262Error('#2: this.x; this.x++; x !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A1.js b/js/src/tests/test262/language/types/reference/S8.7_A1.js new file mode 100644 index 0000000000..70a4c24586 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A1.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Multiple Variables should Referring to a Single Object +es5id: 8.7_A1 +description: > + Create object and refers to the other object, modify a property in + the original object. We now see that that change is represented + in both variables +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +// Set obj to an empty object +// +var obj = new Object(); +// objRef now refers to the other object +// +var objRef = obj; +// Modify a property in the original object +objRef.oneProperty = -1; +obj.oneProperty = true; +// We now see that that change is represented in both variables +// (Since they both refer to the same object) +if(objRef.oneProperty !== true){ + throw new Test262Error('#1: var obj = new Object(); var objRef = obj; objRef.oneProperty = -1; obj.oneProperty = true; objRef.oneProperty === true. Actual: ' + (objRef.oneProperty)); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A2.js b/js/src/tests/test262/language/types/reference/S8.7_A2.js new file mode 100644 index 0000000000..a22951e440 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Reference to Self-Modifying Object remain the integrity +es5id: 8.7_A2 +description: Create a reference to the array, and change original array +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +// Create an array of items +var items = new Array( "one", "two", "three" ); +// Create a reference to the array of items +var itemsRef = items; +// Add an item to the original array +items.push( "four" );var itemsRef = items; +// The length of each array should be the same, +// since they both point to the same array object +if( itemsRef.length !== 4){ + throw new Test262Error('#1: var items = new Array( "one", "two", "three" ); var itemsRef = items; items.push( "four" );var itemsRef = items; itemsRef.length !== 4'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +// Create an array of items +var items = new Array( "one", "two", "three" ); +// Create a reference to the array of items +var itemsRef = items; +// Add an item to the original array +items[1]="duo"; +// The length of each array should be the same, +// since they both point to the same array object +if( itemsRef[1] !== "duo"){ + throw new Test262Error('#2: var items = new Array( "one", "two", "three" ); var itemsRef = items; items[1]="duo"; itemsRef[1] === "duo". Actual: ' + (itemsRef[1])); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A3.js b/js/src/tests/test262/language/types/reference/S8.7_A3.js new file mode 100644 index 0000000000..989d4ef545 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A3.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Changing the Reference of an Object While Maintaining Integrity +es5id: 8.7_A3 +description: > + Create a reference to the array, and redefine original array with + new array +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +// Set items to an array (object) of strings +var items = new Array( "one", "two", "three" ); +// Set itemsRef to a reference to items +// +var itemsRef = items; +// Set items to equal a new object +// +items = new Array( "new", "array" ); +// items and itemsRef now point to different objects. +// items points to new Array( "new", "array" ) +// itemsRef points to new Array( "one", "two", "three" ) +if( items == itemsRef ){ + throw new Test262Error('#1: var items = new Array( "one", "two", "three" ); var itemsRef = items; items = new Array( "new", "array" ); items != itemsRef'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A4.js b/js/src/tests/test262/language/types/reference/S8.7_A4.js new file mode 100644 index 0000000000..a63097b949 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A4.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Object Modification Resulting in a New Object for Not a Self-Modified + Object leads to loss of integrity +es5id: 8.7_A4 +description: > + Create a reference to the string, and Concatenate some new text + onto the string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK# +// Set item equal to a new string object +var item = new String("test"); +// itemRef now refers to the same string object +var itemRef = item; +// Concatenate some new text onto the string object +// NOTE: This creates a new object, and does not modify +// the original object. +item += "ing"; +// The values of item and itemRef are NOT equal, as a whole +// new string object has been created +if( item == itemRef ){ + throw new Test262Error('#1: var item = new String("test"); var itemRef = item; item += "ing"; item != itemRef'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A5_T1.js b/js/src/tests/test262/language/types/reference/S8.7_A5_T1.js new file mode 100644 index 0000000000..b0a12ec30e --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A5_T1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Delete unary operator can't delete object to be referenced +es5id: 8.7_A5_T1 +description: Delete referenced object, var __ref = obj +flags: [noStrict] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof(__ref) !== "undefined"){ + throw new Test262Error('#1: typeof(__ref) === "undefined". Actual: ' + (typeof(__ref))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +var obj = new Object(); +var __ref = obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof(__ref) === "undefined"){ + throw new Test262Error('#2: obj = new Object(); var __ref = obj; typeof(__ref) !== "undefined"'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (delete __ref !== false){ + throw new Test262Error('#3: obj = new Object(); var __ref = obj; delete __ref === false. Actual: ' + (delete __ref)); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof(__ref) !== "object"){ + throw new Test262Error('#4: obj = new Object(); var __ref = obj; delete __ref; typeof(__ref) === "object". Actual: ' + (typeof(__ref))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof(obj) !== "object"){ + throw new Test262Error('#5: obj = new Object(); var __ref = obj; delete __ref; typeof(obj) === "object". Actual: ' + (typeof(obj))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A5_T2.js b/js/src/tests/test262/language/types/reference/S8.7_A5_T2.js new file mode 100644 index 0000000000..382a3b8e25 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A5_T2.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Delete unary operator can't delete object to be referenced +es5id: 8.7_A5_T2 +description: Delete referenced object, __ref = obj +flags: [noStrict] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof(__ref) !== "undefined"){ + throw new Test262Error('#1: typeof(__ref) === "undefined". Actual: ' + (typeof(__ref))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +var obj = new Object(); +__ref = obj; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (typeof(__ref) === "undefined"){ + throw new Test262Error('#2: obj = new Object(); __ref = obj; typeof(__ref) !== "undefined"'); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (delete __ref !== true){ + throw new Test262Error('#3: obj = new Object(); __ref = obj; delete __ref === true. Actual: ' + (delete __ref)); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (typeof(__ref) !== "undefined"){ + throw new Test262Error('#4: obj = new Object(); __ref = obj; delete __ref; typeof(__ref) === "undefined". Actual: ' + (typeof(__ref))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof(obj) !== "object"){ + throw new Test262Error('#5: obj = new Object(); __ref = obj; delete __ref; typeof(obj) === "object". Actual: ' + (typeof(obj))); +}; +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A6.js b/js/src/tests/test262/language/types/reference/S8.7_A6.js new file mode 100644 index 0000000000..d866f9bbd3 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A6.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Passing arguments by value differs from by reference and do not change + values to be passed +es5id: 8.7_A6 +description: Adding original variable with referenced one inside function +---*/ + +var n = 1; +var m = n; + +function addFirst2Second(first, second){first += second;} + +addFirst2Second(n, m); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (m !== 1) { + throw new Test262Error('#1: var n = 1; var m = n; function addFirst2Second(first, second){first += second;} addFirst2Second(n, m); m === 1. Actual: ' + (m)); +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/S8.7_A7.js b/js/src/tests/test262/language/types/reference/S8.7_A7.js new file mode 100644 index 0000000000..87895d39df --- /dev/null +++ b/js/src/tests/test262/language/types/reference/S8.7_A7.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Passing arguments by reference do change values of reference to be passed +es5id: 8.7_A7 +description: Add new property to original variable inside function +---*/ + +var n = {}; +var m = n; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof m !== "object") { + throw new Test262Error('#1: var n = {}; var m = n; typeof m === "object". Actual: ' + (typeof m)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function populateAge(person){person.age = 50;} + +populateAge(m); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (n.age !== 50) { + throw new Test262Error('#2: var n = {}; var m = n; function populateAge(person){person.age = 50;} populateAge(m); n.age === 50. Actual: ' + (n.age)); +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/browser.js b/js/src/tests/test262/language/types/reference/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/browser.js diff --git a/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive-realm.js b/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive-realm.js new file mode 100644 index 0000000000..a0720572d1 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive-realm.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-getvalue +es6id: 6.2.3.1 +description: > + When the base of a property reference is primitive, it is coerced to an + object during value retrieval (honoring the realm of the current execution + context) +info: | + [...] + 5. If IsPropertyReference(V) is true, then + a. If HasPrimitiveBase(V) is true, then + i. Assert: In this case, base will never be null or undefined. + ii. Let base be ToObject(base). + b. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). +features: [cross-realm, Symbol] +---*/ + +var other = $262.createRealm().global; + +other.Number.prototype.test262 = 'number prototype'; +other.value = 1; +assert.sameValue(other.eval('value.test262'), 'number prototype'); + +other.String.prototype.test262 = 'string prototype'; +other.value = ''; +assert.sameValue(other.eval('value.test262'), 'string prototype'); + +other.Boolean.prototype.test262 = 'Boolean prototype'; +other.value = true; +assert.sameValue(other.eval('value.test262'), 'Boolean prototype'); + +other.Symbol.prototype.test262 = 'Symbol prototype'; +other.value = Symbol(); +assert.sameValue(other.eval('value.test262'), 'Symbol prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive.js b/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive.js new file mode 100644 index 0000000000..fba94808b3 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/get-value-prop-base-primitive.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-getvalue +es6id: 6.2.3.1 +description: > + When the base of a property reference is primitive, it is coerced to an + object during value retrieval +info: | + [...] + 5. If IsPropertyReference(V) is true, then + a. If HasPrimitiveBase(V) is true, then + i. Assert: In this case, base will never be null or undefined. + ii. Let base be ToObject(base). + b. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). +features: [Symbol] +---*/ + +Number.prototype.test262 = 'number prototype'; +assert.sameValue(1..test262, 'number prototype'); + +String.prototype.test262 = 'string prototype'; +assert.sameValue(''.test262, 'string prototype'); + +Boolean.prototype.test262 = 'Boolean prototype'; +assert.sameValue(true.test262, 'Boolean prototype'); + +Symbol.prototype.test262 = 'Symbol prototype'; +assert.sameValue(Symbol().test262, 'Symbol prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive-realm.js b/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive-realm.js new file mode 100644 index 0000000000..77f2787c70 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive-realm.js @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-putvalue +es6id: 6.2.3.2 +description: > + When the base of a property reference is primitive, it is coerced to an + object during value assignment (honoring the realm of the current execution + context) +info: | + [...] + 6. Else if IsPropertyReference(V) is true, then + a. If HasPrimitiveBase(V) is true, then + i. Assert: In this case, base will never be null or undefined. + ii. Set base to ToObject(base). + b. Let succeeded be ? base.[[Set]](GetReferencedName(V), W, + GetThisValue(V)). + c. If succeeded is false and IsStrictReference(V) is true, throw a + TypeError exception. + d. Return. +features: [cross-realm, Symbol, Proxy] +---*/ + +var other = $262.createRealm().global; +var numberCount = 0; +var stringCount = 0; +var booleanCount = 0; +var symbolCount = 0; +var spy; + +spy = new Proxy({}, { set: function() { numberCount += 1; return true; } }); +Object.setPrototypeOf(other.Number.prototype, spy); +other.eval('0..test262 = null;'); +assert.sameValue(numberCount, 1, 'number'); + +spy = new Proxy({}, { set: function() { stringCount += 1; return true; } }); +Object.setPrototypeOf(other.String.prototype, spy); +other.eval('"".test262 = null;'); +assert.sameValue(stringCount, 1, 'string'); + +spy = new Proxy({}, { set: function() { booleanCount += 1; return true; } }); +Object.setPrototypeOf(other.Boolean.prototype, spy); +other.eval('true.test262 = null;'); +assert.sameValue(booleanCount, 1, 'string'); + +spy = new Proxy({}, { set: function() { symbolCount += 1; return true; } }); +Object.setPrototypeOf(other.Symbol.prototype, spy); +other.eval('Symbol().test262 = null;'); +assert.sameValue(symbolCount, 1, 'string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive.js b/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive.js new file mode 100644 index 0000000000..b7856f0d05 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-putvalue +es6id: 6.2.3.2 +description: > + When the base of a property reference is primitive, it is coerced to an + object during value assignment +info: | + [...] + 6. Else if IsPropertyReference(V) is true, then + a. If HasPrimitiveBase(V) is true, then + i. Assert: In this case, base will never be null or undefined. + ii. Set base to ToObject(base). + b. Let succeeded be ? base.[[Set]](GetReferencedName(V), W, + GetThisValue(V)). + c. If succeeded is false and IsStrictReference(V) is true, throw a + TypeError exception. + d. Return. +features: [Symbol, Proxy] +---*/ + +var numberCount = 0; +var stringCount = 0; +var booleanCount = 0; +var symbolCount = 0; +var spy; + +spy = new Proxy({}, { set: function() { numberCount += 1; return true; } }); +Object.setPrototypeOf(Number.prototype, spy); +0..test262 = null; +assert.sameValue(numberCount, 1, 'number'); + +spy = new Proxy({}, { set: function() { stringCount += 1; return true; } }); +Object.setPrototypeOf(String.prototype, spy); +''.test262 = null; +assert.sameValue(stringCount, 1, 'string'); + +spy = new Proxy({}, { set: function() { booleanCount += 1; return true; } }); +Object.setPrototypeOf(Boolean.prototype, spy); +true.test262 = null; +assert.sameValue(booleanCount, 1, 'string'); + +spy = new Proxy({}, { set: function() { symbolCount += 1; return true; } }); +Object.setPrototypeOf(Symbol.prototype, spy); +Symbol().test262 = null; +assert.sameValue(symbolCount, 1, 'string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/types/reference/shell.js b/js/src/tests/test262/language/types/reference/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/types/reference/shell.js |