diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/language/expressions/delete | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/delete')
63 files changed, 1474 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-0-1.js b/js/src/tests/test262/language/expressions/delete/11.4.1-0-1.js new file mode 100644 index 0000000000..2abdae51d5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-0-1.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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator as UnaryExpression +flags: [noStrict] +---*/ + +var x = 1; +var y = 2; +var z = 3; + +assert((!delete x || delete y), '(!delete x || delete y)'); +assert(delete delete z, 'delete delete z'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-2-2.js b/js/src/tests/test262/language/expressions/delete/11.4.1-2-2.js new file mode 100644 index 0000000000..5fd845828a --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-2-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true when deleting returned value from a + function +---*/ + +var bIsFooCalled = false; +var foo = function() { + bIsFooCalled = true; +}; + +var d = delete foo(); + +assert.sameValue(d, true, 'd'); +assert.sameValue(bIsFooCalled, true, 'bIsFooCalled'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-3-1.js b/js/src/tests/test262/language/expressions/delete/11.4.1-3-1.js new file mode 100644 index 0000000000..26fd6e8472 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-3-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true when deleting an unresolvable + reference +flags: [noStrict] +---*/ + +assert.sameValue(delete unresolvable, true, 'delete unresolvable === true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-3-2.js b/js/src/tests/test262/language/expressions/delete/11.4.1-3-2.js new file mode 100644 index 0000000000..5b104a6308 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-3-2.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. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator throws ReferenceError when deleting an explicitly + qualified yet unresolvable reference (base obj undefined) +---*/ + +assert.throws(ReferenceError, function() { + delete unresolvable.x; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-3-3.js b/js/src/tests/test262/language/expressions/delete/11.4.1-3-3.js new file mode 100644 index 0000000000..6b1fbba700 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-3-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true when deleting an explicitly qualified + yet unresolvable reference (property undefined for base obj) +---*/ + +var o = {}; +assert.sameValue(delete o.x, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-1-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-1-s-strict.js new file mode 100644 index 0000000000..4bde0ebeee --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-1-s-strict.js @@ -0,0 +1,23 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + Strict Mode - TypeError is thrown when deleting non-configurable + data property +flags: [onlyStrict] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'prop', { + value: 'abc', + configurable: false, +}); +assert.throws(TypeError, function() { + delete obj.prop; +}); +assert.sameValue(obj.prop, 'abc', 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-2-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-2-s-strict.js new file mode 100644 index 0000000000..e8f9b5724d --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-2-s-strict.js @@ -0,0 +1,25 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + Strict Mode - TypeError is thrown when deleting non-configurable + accessor property +flags: [onlyStrict] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'prop', { + get: function() { + return 'abc'; + }, + configurable: false, +}); +assert.throws(TypeError, function() { + delete obj.prop; +}); +assert.sameValue(obj.prop, 'abc', 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-3-s.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-3-s.js new file mode 100644 index 0000000000..5a75ac567b --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-3-s.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + TypeError isn't thrown when deleting configurable data property +---*/ + +var obj = {}; +Object.defineProperty(obj, 'prop', { + value: 'abc', + configurable: true, +}); + +delete obj.prop; + +assert.sameValue( + obj.hasOwnProperty('prop'), + false, + 'obj.hasOwnProperty("prop")' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-4-s.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-4-s.js new file mode 100644 index 0000000000..6783d5090e --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4-a-4-s.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + TypeError isn't thrown when deleting configurable accessor property +---*/ + +var obj = {}; +Object.defineProperty(obj, 'prop', { + get: function() { + return 'abc'; + }, + configurable: true, +}); + +delete obj.prop; + +assert.sameValue( + obj.hasOwnProperty('prop'), + false, + 'obj.hasOwnProperty("prop")' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-1.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-1.js new file mode 100644 index 0000000000..856ea0da33 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-1.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true when deleting a configurable data + property +---*/ + +var o = {}; + +var desc = { + value: 1, + configurable: true, +}; +Object.defineProperty(o, 'foo', desc); + +var d = delete o.foo; + +assert.sameValue(d, true, 'd'); +assert.sameValue(o.hasOwnProperty('foo'), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-10.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-10.js new file mode 100644 index 0000000000..c0738a9755 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-10.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true for property (stringify) defined on + built-in object (JSON) +---*/ + +var d = delete JSON.stringify; + +assert.sameValue(d, true, 'd'); +assert.sameValue(JSON.stringify, undefined, 'JSON.stringify'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-11.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-11.js new file mode 100644 index 0000000000..420ba93379 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-11.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true on deleting arguments + properties(arguments.callee) +flags: [noStrict] +---*/ + +(function() { + function foo(a, b) { + return delete arguments.callee; + } + var d = delete arguments.callee; + + assert.sameValue(d, true, 'd'); + assert.sameValue(arguments.callee, undefined, 'arguments.callee'); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-12.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-12.js new file mode 100644 index 0000000000..3f7fc897a1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-12.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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns false when deleting a property(length) +flags: [noStrict] +---*/ + +var a = [1, 2, 3]; +a.x = 10; +var d = delete a.length; + +assert.sameValue(d, false, 'd'); +assert.sameValue(a.length, 3, 'a.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-13.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-13.js new file mode 100644 index 0000000000..459421fa5f --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-13.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns false when deleting Array object +flags: [noStrict] +---*/ + +var a = [1, 2, 3]; +a.x = 10; + +var d = delete a; + +assert.sameValue(d, false, 'd'); +assert.sameValue(Array.isArray(a), true, 'Array.isArray(a)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-14.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-14.js new file mode 100644 index 0000000000..dd3d849168 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-14.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns true when deleting Array elements +---*/ + +var a = [1, 2, 3]; +a.x = 10; +var d = delete a[1]; + +assert.sameValue(d, true, 'd'); +assert.sameValue(a[1], undefined, 'a[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-15.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-15.js new file mode 100644 index 0000000000..ea2a3e0bd2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-15.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns true when deleting Array expandos +---*/ + +var a = [1, 2, 3]; +a.x = 10; +var d = delete a.x; + +assert.sameValue(d, true, 'd'); +assert.sameValue(a.x, undefined, 'a.x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-16.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-16.js new file mode 100644 index 0000000000..4d0e7d1ef0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-16.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns false on deleting arguments object +flags: [noStrict] +---*/ + +(function() { + assert.sameValue(delete arguments, false, 'delete arguments'); + assert.notSameValue(arguments, undefined, 'arguments'); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-17.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-17.js new file mode 100644 index 0000000000..d5d9e39ce6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-17.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns true on deleting a arguments element +---*/ + +function foo(a, b) { + var d = delete arguments[0]; + return d === true && arguments[0] === undefined; +} + +assert.sameValue(foo(1, 2), true, 'foo(1,2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-2.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-2.js new file mode 100644 index 0000000000..dc375ee9ed --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-2.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns true when deleting a configurable accessor + property +---*/ + +var o = {}; + +// define an accessor +// dummy getter +var getter = function() { + return 1; +}; +var desc = { + get: getter, + configurable: true, +}; +Object.defineProperty(o, 'foo', desc); + +var d = delete o.foo; + +assert.sameValue(d, true, 'd'); +assert.sameValue(o.hasOwnProperty('foo'), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3-s-strict.js new file mode 100644 index 0000000000..8a25d34be6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3-s-strict.js @@ -0,0 +1,27 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator throws TypeError when deleting a non-configurable + data property in strict mode +flags: [onlyStrict] +---*/ + +var o = {}; +var desc = { + value: 1, +}; // all other attributes default to false +Object.defineProperty(o, 'foo', desc); + +// Now, deleting o.foo should throw TypeError because [[Configurable]] on foo is false. +assert.throws(TypeError, function() { + delete o.foo; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3.js new file mode 100644 index 0000000000..76eb6c2eb1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-3.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a non-configurable + data property +flags: [noStrict] +---*/ + +var o = {}; +var desc = { + value: 1, + configurable: false, +}; // all other attributes default to false +Object.defineProperty(o, 'foo', desc); + +// Now, deleting o.foo should fail because [[Configurable]] on foo is false. +var d = delete o.foo; + +assert.sameValue(d, false, 'd'); +assert.sameValue(o.hasOwnProperty('foo'), true, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-4.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-4.js new file mode 100644 index 0000000000..425ce3ff35 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-4.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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a non-configurable + data property (NaN) +flags: [noStrict] +---*/ + +// NaN (15.1.1.1) has [[Configurable]] set to false. +var d = delete NaN; + +assert.sameValue(d, false, 'd'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-5.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-5.js new file mode 100644 index 0000000000..da68d598ac --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-5.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting the declaration of the environment object + inside 'with' +flags: [noStrict] +---*/ + +var o = new Object(); +o.x = 1; +var d; +with(o) { + d = delete o; +} + +assert.sameValue(d, false, 'd'); +assert.sameValue(typeof o, 'object', 'typeof(o)'); +assert.sameValue(o.x, 1, 'o.x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-6.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-6.js new file mode 100644 index 0000000000..cee3aff136 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-6.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns true when deleting a property inside 'with' +flags: [noStrict] +---*/ + +var o = new Object(); +o.x = 1; +var d; +with(o) { + d = delete x; +} + +assert.sameValue(d, true, 'd'); +assert.sameValue(o.x, undefined, 'o.x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-7.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-7.js new file mode 100644 index 0000000000..0507d4019f --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-7.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator inside 'eval' +flags: [noStrict] +---*/ + +var x = 1; +var d = eval('delete x'); + +assert.sameValue(d, false, 'd'); +assert.sameValue(x, 1, 'x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8-s-strict.js new file mode 100644 index 0000000000..d6150ba9e5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8-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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator throws TypeError when deleting a non-configurable + data property in strict mode +flags: [onlyStrict] +---*/ + +var global = this; +// NaN (15.1.1.1) has [[Configurable]] set to false. +assert.throws(TypeError, function() { + delete global.NaN; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8.js new file mode 100644 index 0000000000..b6638c57f0 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-8.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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: delete operator returns true for built-in objects (JSON) +flags: [noStrict] +---*/ + +var d = delete JSON; + +assert.sameValue(d, true, 'd'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9-s-strict.js new file mode 100644 index 0000000000..332c565978 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9-s-strict.js @@ -0,0 +1,20 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator throws TypeError when deleting a non-configurable + data property (Math.LN2) in strict mode +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + delete Math.LN2; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9.js b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9.js new file mode 100644 index 0000000000..b2472ca17a --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-4.a-9.js @@ -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. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a non-configurable + data property (Math.LN2) +flags: [noStrict] +---*/ + +var d = delete Math.LN2; + +assert.sameValue(d, false, 'd'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-5-1.js b/js/src/tests/test262/language/expressions/delete/11.4.1-5-1.js new file mode 100644 index 0000000000..22b056520c --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-5-1.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. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a direct reference to + a var +flags: [noStrict] +---*/ + +var x = 1; + +// Now, deleting 'x' directly should fail; +var d = delete x; + +assert.sameValue(d, false, 'd'); +assert.sameValue(x, 1, 'x'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-5-2.js b/js/src/tests/test262/language/expressions/delete/11.4.1-5-2.js new file mode 100644 index 0000000000..7f7cb95ad1 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-5-2.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a direct reference to + a function argument +flags: [noStrict] +---*/ + +function foo(a, b) { + // Now, deleting 'a' directly should fail + // because 'a' is direct reference to a function argument; + var d = delete a; + return d === false && a === 1; +} + +assert(foo(1, 2), 'foo(1,2) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-5-3.js b/js/src/tests/test262/language/expressions/delete/11.4.1-5-3.js new file mode 100644 index 0000000000..a9353540ca --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-5-3.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. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator returns false when deleting a direct reference to + a function name +flags: [noStrict] +---*/ + +var foo = function() {}; + +// Now, deleting 'foo' directly should fail; +var d = delete foo; + +assert.sameValue(d, false, 'd'); +assert.sameValue(typeof foo, 'function', 'typeof foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-27-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-27-s-strict.js new file mode 100644 index 0000000000..c32710b2b6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-27-s-strict.js @@ -0,0 +1,25 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + Strict Mode - TypeError is thrown after deleting a property, + calling preventExtensions, and attempting to reassign the property +flags: [onlyStrict] +---*/ + +var a = { + x: 0, + get y() { + return 0; + }, +}; +delete a.x; +Object.preventExtensions(a); +assert.throws(TypeError, function() { + a.x = 1; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-28-s.js b/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-28-s.js new file mode 100644 index 0000000000..aa465ea689 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.1-5-a-28-s.js @@ -0,0 +1,12 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: Strict Mode - TypeError is not thrown when deleting RegExp.length +---*/ + +var a = new RegExp(); +var b = delete RegExp.length; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/11.4.4-4.a-3-s-strict.js b/js/src/tests/test262/language/expressions/delete/11.4.4-4.a-3-s-strict.js new file mode 100644 index 0000000000..8a25d34be6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/11.4.4-4.a-3-s-strict.js @@ -0,0 +1,27 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + This test is actually testing the [[Delete]] internal method (8.12.8). Since the + language provides no way to directly exercise [[Delete]], the tests are placed here. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operator throws TypeError when deleting a non-configurable + data property in strict mode +flags: [onlyStrict] +---*/ + +var o = {}; +var desc = { + value: 1, +}; // all other attributes default to false +Object.defineProperty(o, 'foo', desc); + +// Now, deleting o.foo should throw TypeError because [[Configurable]] on foo is false. +assert.throws(TypeError, function() { + delete o.foo; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.1.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.1.js new file mode 100644 index 0000000000..b2a838d7dc --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If Type(x) is not Reference, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking primitive value and Object value cases +---*/ + +//CHECK#1 +if (delete 1 !== true) { + $ERROR('#1: delete 1 === true'); +} + +//CHECK#2 +if (delete new Object() !== true) { + $ERROR('#2: delete new Object() === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T1.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T1.js new file mode 100644 index 0000000000..692cbcc692 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T1.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If GetBase(x) doesn't have a property GetPropertyName(x), return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking undeclared variable case +flags: [noStrict] +---*/ + +//CHECK#1 +if (delete x !== true) { + $ERROR('#1: delete x === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T2.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T2.js new file mode 100644 index 0000000000..7e6b467f69 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If GetBase(x) doesn't have a property GetPropertyName(x), return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking Object object and Function object cases +---*/ + +//CHECK#1 +function MyFunction() {} +var MyObject = new MyFunction(); +if (delete MyObject.prop !== true) { + $ERROR( + '#1: function MyFunction(){}; var MyObject = new MyFunction(); delete MyObject.prop === true' + ); +} + +//CHECK#2 +var MyObject = new Object(); +if (delete MyObject.prop !== true) { + $ERROR('#2: var MyObject = new Object(); delete MyObject.prop === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T3.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T3.js new file mode 100644 index 0000000000..af5f97e9f9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A2.2_T3.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If GetBase(x) doesn't have a property GetPropertyName(x), return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking undeclared variable case +---*/ + +//CHECK#1 +if (delete this.x !== true) { + $ERROR('#1: delete this.x === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.1.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.1.js new file mode 100644 index 0000000000..2e4089c940 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property has the DontDelete attribute, return false +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +var x = 1; +if (delete x !== false) { + $ERROR('#1: var x = 1; delete x === false'); +} + +//CHECK#2 +var y = 1; +if (delete this.y !== false) { + $ERROR('#2: var y = 1; delete this.y === false'); +} + +//CHECK#3 +function MyFunction() {} +if (delete MyFunction !== false) { + $ERROR('#3: function MyFunction(){}; delete MyFunction === false'); +} + +//CHECK#4 +var MyObject = new MyFunction(); +if (delete MyObject !== false) { + $ERROR( + '#4: function MyFunction(){}; var MyObject = new MyFunction(); delete MyObject === false' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T1.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T1.js new file mode 100644 index 0000000000..63458adcd5 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +x = 1; +if (delete x !== true) { + $ERROR('#1: x = 1; delete x === true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T2.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T2.js new file mode 100644 index 0000000000..cec60b8e64 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +---*/ + +//CHECK#1 +function MyFunction() {} +MyFunction.prop = 1; +if (delete MyFunction.prop !== true) { + $ERROR( + '#1: function MyFunction(){}; MyFunction.prop = 1; delete MyFunction.prop === true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T3.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T3.js new file mode 100644 index 0000000000..8bacd19b13 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.2_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +---*/ + +//CHECK#1 +function MyFunction() {} +var MyObject = new MyFunction(); +MyObject.prop = 1; +if (delete MyObject.prop !== true) { + $ERROR( + '#1: function MyFunction(){}; var MyObject = new MyFunction(); MyFunction.prop = 1; delete MyObject.prop === true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T1.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T1.js new file mode 100644 index 0000000000..08e7b97fe6 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +try { + x = 1; + delete x; + x; + $ERROR('#1: x = 1; delete x; x is not exist'); +} catch (e) { + if (e instanceof ReferenceError !== true) { + $ERROR('#1: x = 1; delete x; x is not exist'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T2.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T2.js new file mode 100644 index 0000000000..3563245ccc --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +---*/ + +//CHECK#1 +function MyFunction() {} +MyFunction.prop = 1; +delete MyFunction.prop; +if (MyFunction.prop !== undefined) { + $ERROR( + '#1: function MyFunction(){}; MyFunction.prop = 1; delete MyFunction.prop; MyFunction.prop === undefined. Actual: ' + + MyFunction.prop + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T3.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T3.js new file mode 100644 index 0000000000..2e5b126069 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +---*/ + +//CHECK#1 +function MyFunction() {} +var MyObjectVar = new MyFunction(); +MyObjectVar.prop = 1; +delete MyObjectVar.prop; +if (MyObjectVar.prop !== undefined) { + $ERROR( + '#1: function MyFunction(){}; var MyObjectVar = new MyFunction(); MyFunction.prop = 1; delete MyObjectVar.prop; MyObjectVar.prop === undefined. Actual: ' + + MyObjectVar.prop + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T4.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T4.js new file mode 100644 index 0000000000..7ee571725e --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +function MyFunction() {} +var MyObjectVar = new MyFunction(); +if (delete MyObjectVar !== false) { + $ERROR( + '#1: function MyFunction(){}; var MyObjectVar = new MyFunction(); delete MyObjectVar === false' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T5.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T5.js new file mode 100644 index 0000000000..0047288f4d --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +function MyFunction() {} +MyObjectNotVar = new MyFunction(); +MyObjectNotVar.prop = 1; +delete MyObjectNotVar.prop; +if (MyObjectNotVar.prop !== undefined) { + $ERROR( + '#1: function MyFunction(){}; MyObjectNotVar = new MyFunction(); MyFunction.prop = 1; delete MyObjectNotVar.prop; MyObjectNotVar.prop === undefined. Actual: ' + + MyObjectNotVar.prop + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T6.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T6.js new file mode 100644 index 0000000000..d1bdd0287d --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A3.3_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If the property doesn't have the DontDelete attribute, remove the property +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking declared variable +flags: [noStrict] +---*/ + +//CHECK#1 +function MyFunction() {} +var MyObjectVar = new MyFunction(); +if (delete MyObjectNotVar !== true) { + $ERROR( + '#1: function MyFunction(){}; var MyObjectNotVar = new MyFunction(); delete MyObjectNotVar === true' + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A4.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A4.js new file mode 100644 index 0000000000..2573373979 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "Delete" operator removes property, which is reference to the object, not + the object +esid: sec-delete-operator-runtime-semantics-evaluation +description: Checking two reference by one object +flags: [noStrict] +---*/ + +//CHECK#1 +var obj = new Object(); +var ref = obj; +delete ref; +if (typeof obj !== 'object') { + $ERROR( + '#1: obj = new Object(); ref = obj; delete ref; typeof obj === "object". Actual: ' + + typeof obj + ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S11.4.1_A5-strict.js b/js/src/tests/test262/language/expressions/delete/S11.4.1_A5-strict.js new file mode 100644 index 0000000000..e332942b23 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S11.4.1_A5-strict.js @@ -0,0 +1,36 @@ +'use strict'; +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + A strict delete should either succeed, returning true, or it + should fail by throwing a TypeError. Under no circumstances + should a strict delete return false. +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + See if a strict delete returns false when deleting a non-standard + property. +flags: [onlyStrict] +---*/ + +var reNames = Object.getOwnPropertyNames(RegExp); +for (var i = 0, len = reNames.length; i < len; i++) { + var reName = reNames[i]; + if (reName !== 'prototype') { + var deleted = 'unassigned'; + try { + deleted = delete RegExp[reName]; + } catch (err) { + if (!(err instanceof TypeError)) { + $ERROR('#1: strict delete threw a non-TypeError: ' + err); + } + // fall through + } + if (deleted === false) { + $ERROR('#2: Strict delete returned false'); + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S8.12.7_A1.js b/js/src/tests/test262/language/expressions/delete/S8.12.7_A1.js new file mode 100644 index 0000000000..85cf56d7de --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S8.12.7_A1.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: | + When the [[Delete]] method of O is called with property name P, + and If the property has the DontDelete attribute, return false +esid: sec-delete-operator-runtime-semantics-evaluation +description: Try to delete Math.E, that has the DontDelete attribute +flags: [noStrict] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (delete Math.E !== false) { + $ERROR('#1: delete Math.E === false. Actual: ' + delete Math.E); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (Math.E === undefined) { + $ERROR('#2: delete Math.E; Math.E !== undefined'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_T1.js b/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_T1.js new file mode 100644 index 0000000000..5c782a67cf --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_T1.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Delete]] method of O is called with property name P, + and if O doesn't have a property with name P, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Try to delete not existent properties +---*/ + +var __color__map = {}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (delete __color__map.red !== true) { + $ERROR( + '#1: var __color__map = {}; delete __color__map.red === true. Actual: ' + + delete __color__map.red + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (delete __color__map['green'] !== true) { + $ERROR( + '#2: var __color__map = {}; delete __color__map["green"] === true. Actual: ' + + delete __color__map['green'] + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +var blue = 1; +if (delete __color__map[blue] !== true) { + $ERROR( + '#3: var __color__map = {}; var blue = 1; delete __color__map[blue] === true. Actual: ' + + delete __color__map[blue] + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_T2.js b/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_T2.js new file mode 100644 index 0000000000..ead16654ec --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S8.12.7_A2_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: | + When the [[Delete]] method of O is called with property name P, + and if O doesn't have a property with name P, return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + Try to delete not existent properties of O, but existent property + of prototype +---*/ + +function Palette() {} +Palette.prototype = { + red: 0xff0000, + green: 0x00ff00, +}; +var __palette = new Palette(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__palette.red !== 0xff0000) { + $ERROR( + '#1: function Palette(){}; Palette.prototype = {red:0xFF0000, green:0x00FF00}; __palette = new Palette; __palette.red === 0xFF0000. Actual: ' + + __palette.red + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (delete __palette.red !== true) { + $ERROR( + '#2 function Palette(){}; Palette.prototype = {red:0xFF0000, green:0x00FF00}; __palette = new Palette; delete __palette.red === true. Actual: ' + + delete __palette.red + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__palette.red !== 0xff0000) { + $ERROR( + '#3: function Palette(){}; Palette.prototype = {red:0xFF0000, green:0x00FF00}; __palette = new Palette; __palette.red === 0xFF0000. Actual: ' + + __palette.red + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/S8.12.7_A3.js b/js/src/tests/test262/language/expressions/delete/S8.12.7_A3.js new file mode 100644 index 0000000000..e672da8fbe --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/S8.12.7_A3.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When the [[Delete]] method of O is called with property name P, + removes the property with name P from O and return true +esid: sec-delete-operator-runtime-semantics-evaluation +description: Delete existent properties +---*/ + +var BLUE_NUM = 1; +var BLUE_STR = '1'; +var YELLOW_NUM = 2; +var YELLOW_STR = '2'; +var __color__map = { + red: 0xff0000, + BLUE_NUM: 0x0000ff, + green: 0x00ff00, + YELLOW_STR: 0xffff00, +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (delete __color__map[YELLOW_NUM] !== true) { + $ERROR( + '#1: var BLUE_NUM=1; var BLUE_STR="1"; var YELLOW_NUM=2; var YELLOW_STR="2"; var __color__map = {red:0xFF0000, BLUE_NUM:0x0000FF, green:0x00FF00, YELLOW_STR:0xFFFF00}; delete __color__map[YELLOW_NUM] === true;' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__color__map[YELLOW_STR] !== undefined) { + $ERROR( + '#2: var BLUE_NUM=1; var BLUE_STR="1"; var YELLOW_NUM=2; var YELLOW_STR="2"; var __color__map = {red:0xFF0000, BLUE_NUM:0x0000FF, green:0x00FF00, YELLOW_STR:0xFFFF00}; delete __color__map[YELLOW_NUM]; __color__map[YELLOW_STR] === undefined. Actual: ' + + __color__map[YELLOW_STR] + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (delete __color__map[BLUE_STR] !== true) { + $ERROR( + '#3: var BLUE_NUM=1; var BLUE_STR="1"; var YELLOW_NUM=2; var YELLOW_STR="2"; var __color__map = {red:0xFF0000, BLUE_NUM:0x0000FF, green:0x00FF00, YELLOW_STR:0xFFFF00}; delete __color__map[BLUE_STR] === true. Actual: ' + + delete __color__map[BLUE_STR] + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__color__map[BLUE_NUM] !== undefined) { + $ERROR( + '#4: var BLUE_NUM=1; var BLUE_STR="1"; var YELLOW_NUM=2; var YELLOW_STR="2"; var __color__map = {red:0xFF0000, BLUE_NUM:0x0000FF, green:0x00FF00, YELLOW_STR:0xFFFF00}; delete __color__map[BLUE_STR]; __color__map[BLUE_NUM] === undefined. Actual: ' + + __color__map[BLUE_NUM] + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/browser.js b/js/src/tests/test262/language/expressions/delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/browser.js diff --git a/js/src/tests/test262/language/expressions/delete/delete-unresolvable-base-object-reference-throws-typeerror.js b/js/src/tests/test262/language/expressions/delete/delete-unresolvable-base-object-reference-throws-typeerror.js new file mode 100644 index 0000000000..934e59eec9 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/delete-unresolvable-base-object-reference-throws-typeerror.js @@ -0,0 +1,14 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + delete operations throws TypeError exception when base object is unresolvable reference. +---*/ + +assert.throws(TypeError, () => { + delete Object[0][0]; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/identifier-strict-strict.js b/js/src/tests/test262/language/expressions/delete/identifier-strict-strict.js new file mode 100644 index 0000000000..d84e8a4e59 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/identifier-strict-strict.js @@ -0,0 +1,19 @@ +// |reftest| error:SyntaxError +'use strict'; +// Copyright (c) 2018 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-delete-operator-static-semantics-early-errors +description: Parsing error when operand is an IdentifierReference +info: | + It is a Syntax Error if the UnaryExpression is contained in strict mode code + and the derived UnaryExpression is PrimaryExpression:IdentifierReference. +negative: + phase: parse + type: SyntaxError +flags: [onlyStrict] +---*/ + +$DONOTEVALUATE(); + +delete test262identifier; diff --git a/js/src/tests/test262/language/expressions/delete/non-reference-return-true.js b/js/src/tests/test262/language/expressions/delete/non-reference-return-true.js new file mode 100644 index 0000000000..85c2e44f68 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/non-reference-return-true.js @@ -0,0 +1,37 @@ +// Copyright (c) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: > + The delete expression should return true if the right hand UnaryExpression is not a Reference +info: | + Runtime Semantics: Evaluation + UnaryExpression : delete UnaryExpression + + 1. Let ref be the result of evaluating UnaryExpression. + 2. ReturnIfAbrupt(ref). + 3. If Type(ref) is not Reference, return true. +---*/ + +var a = { b: 42 }; +assert.sameValue(delete void a.b, true, 'delete void a.b'); +assert.sameValue(delete void 0, true, 'delete void 0'); +assert.sameValue(delete typeof 0, true, 'delete typeof 0'); +assert.sameValue(delete delete 0, true, 'delete delete 0'); +assert.sameValue(delete void typeof +-~!0, true, 'delete void typeof +-~!0'); +assert.sameValue(delete {x:1}, true, 'delete {x:1}'); +assert.sameValue(delete null, true, 'delete null'); +assert.sameValue(delete true, true, 'delete true'); +assert.sameValue(delete false, true, 'delete false'); +assert.sameValue(delete 0, true, 'delete 0'); +assert.sameValue(delete 1, true, 'delete 1'); +assert.sameValue(delete '', true, 'delete ""'); +assert.sameValue(delete 'Test262', true, 'delete "Test262"'); +assert.sameValue(delete 'Test262'[100], true, 'delete "Test262"[100]'); +assert.sameValue(delete typeof +-~!0, true, 'delete typeof +-~!0'); +assert.sameValue(delete +-~!0, true, 'delete +-~!0'); +assert.sameValue(delete -~!0, true, 'delete -~!0'); +assert.sameValue(delete ~!0, true, 'delete ~!0'); +assert.sameValue(delete !0, true, 'delete !0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/shell.js b/js/src/tests/test262/language/expressions/delete/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/shell.js diff --git a/js/src/tests/test262/language/expressions/delete/super-property-method.js b/js/src/tests/test262/language/expressions/delete/super-property-method.js new file mode 100644 index 0000000000..80406af00d --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/super-property-method.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-delete-operator-runtime-semantics-evaluation +description: Attempts to delete super reference property references throws ReferenceError exception +features: [class] +---*/ + +class X { + method() { + return this; + } +} + +class Y extends X { + method() { + delete super.method; + } +} + +const y = new Y(); + +assert.throws(ReferenceError, () => { + y.method(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/super-property.js b/js/src/tests/test262/language/expressions/delete/super-property.js new file mode 100644 index 0000000000..2e6e6e4857 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/super-property.js @@ -0,0 +1,24 @@ +// 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-delete-operator-runtime-semantics-evaluation +description: SuperReferences may not be deleted +info: | + [...] + 5.If IsPropertyReference(ref) is true, then + a. If IsSuperReference(ref) is true, throw a ReferenceError exception. +features: [class] +---*/ + +class C extends Object { + constructor() { + super(); + delete super.x; + } +} + +assert.throws(ReferenceError, () => { + new C(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/delete/white-space-line-terminator-between-delete-unaryexpression-allowed.js b/js/src/tests/test262/language/expressions/delete/white-space-line-terminator-between-delete-unaryexpression-allowed.js new file mode 100644 index 0000000000..aeed0ffa12 --- /dev/null +++ b/js/src/tests/test262/language/expressions/delete/white-space-line-terminator-between-delete-unaryexpression-allowed.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-delete-operator +description: > + White Space and Line Terminator between "delete" and UnaryExpression are allowed +info: | + UnaryExpression : + delete UnaryExpression + +---*/ + +var result; + +result = delete 0; +assert.sameValue(result, true, '\\u0009'); + +result = delete0; +assert.sameValue(result, true, '\\u000B'); + +result = delete0; +assert.sameValue(result, true, '\\u000C'); + +result = delete 0; +assert.sameValue(result, true, '\\u0020'); + +result = delete 0; +assert.sameValue(result, true, '\\u00A0'); + +// Line Break is intentional +result = delete +0; +assert.sameValue(result, true, '\\u000A'); + +// Line Break is intentional +result = delete +0; +assert.sameValue(result, true, '\\u000D'); + +result = delete
0; +assert.sameValue(result, true, '\\u2028'); + +result = delete
0; +assert.sameValue(result, true, '\\u2029'); + +// Line Break is intentional +result = delete +
0; +assert.sameValue(result, true, '\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029'); + +reportCompare(0, 0); |