diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Object/defineProperty | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/defineProperty')
1130 files changed, 36190 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-1.js new file mode 100644 index 0000000000..3856ae8cd9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-0-1 +description: Object.defineProperty must exist as a function +---*/ + +var f = Object.defineProperty; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-2.js new file mode 100644 index 0000000000..0e8cfad057 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-0-2.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: 15.2.3.6-0-2 +description: Object.defineProperty must exist as a function taking 3 parameters +---*/ + +assert.sameValue(Object.defineProperty.length, 3, 'Object.defineProperty.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-1.js new file mode 100644 index 0000000000..a700f0931e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-1-1 +description: Object.defineProperty applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty(undefined, "foo", {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-2.js new file mode 100644 index 0000000000..5fbd82ad18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-1-2 +description: Object.defineProperty applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty(null, "foo", {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-3.js new file mode 100644 index 0000000000..074f517829 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-3.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: 15.2.3.6-1-3 +description: > + Object.defineProperty applied to number primitive throws a + TypeError +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty(5, "foo", {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-4.js new file mode 100644 index 0000000000..ecdc174158 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1-4.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: 15.2.3.6-1-4 +description: > + Object.defineProperty applied to string primitive throws a + TypeError +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty("hello\nworld\\!", "foo", {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1.js new file mode 100644 index 0000000000..f0d7bd674a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-1.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: 15.2.3.6-1 +description: > + Object.defineProperty throws TypeError if type of first param is + not Object +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty(true, "foo", {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-1.js new file mode 100644 index 0000000000..870cf114db --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-1 +description: > + Object.defineProperty - argument 'P' is undefined that converts to + string 'undefined' +---*/ + +var obj = {}; +Object.defineProperty(obj, undefined, {}); + +assert(obj.hasOwnProperty("undefined"), 'obj.hasOwnProperty("undefined") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-10.js new file mode 100644 index 0000000000..e7336435e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-10.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-10 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is a negative number) +---*/ + +var obj = {}; +Object.defineProperty(obj, -20, {}); + +assert(obj.hasOwnProperty("-20"), 'obj.hasOwnProperty("-20") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-11.js new file mode 100644 index 0000000000..f981ebca50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-11.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-11 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is Infinity) +---*/ + +var obj = {}; +Object.defineProperty(obj, Infinity, {}); + +assert(obj.hasOwnProperty("Infinity"), 'obj.hasOwnProperty("Infinity") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-12.js new file mode 100644 index 0000000000..6429958577 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-12.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-12 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is +Infinity) +---*/ + +var obj = {}; +Object.defineProperty(obj, +Infinity, {}); + +assert(obj.hasOwnProperty("Infinity"), 'obj.hasOwnProperty("Infinity") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-13.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-13.js new file mode 100644 index 0000000000..d2ce79aa00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-13.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-13 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is -Infinity) +---*/ + +var obj = {}; +Object.defineProperty(obj, -Infinity, {}); + +assert(obj.hasOwnProperty("-Infinity"), 'obj.hasOwnProperty("-Infinity") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-14.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-14.js new file mode 100644 index 0000000000..29ff89bd5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-14.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-14 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 20 zeros)) +---*/ + +var obj = {}; +Object.defineProperty(obj, 100000000000000000000, {}); + +assert(obj.hasOwnProperty("100000000000000000000"), 'obj.hasOwnProperty("100000000000000000000") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-15.js new file mode 100644 index 0000000000..95186e1b5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-15.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-15 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 21 zeros)) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1000000000000000000000, {}); + +assert(obj.hasOwnProperty("1e+21"), 'obj.hasOwnProperty("1e+21") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-16.js new file mode 100644 index 0000000000..7b567bcaee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-16.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-16 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 22 zeros)) +---*/ + +var obj = {}; +Object.defineProperty(obj, 10000000000000000000000, {}); + +assert(obj.hasOwnProperty("1e+22"), 'obj.hasOwnProperty("1e+22") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17-1.js new file mode 100644 index 0000000000..72b4a87427 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-17-1 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1, {}); + +assert(obj.hasOwnProperty("1"), 'obj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17.js new file mode 100644 index 0000000000..d52fe6c430 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-17.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-17 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1e+20) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e+20, {}); + +assert(obj.hasOwnProperty("100000000000000000000"), 'obj.hasOwnProperty("100000000000000000000") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-18.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-18.js new file mode 100644 index 0000000000..99d389c919 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-18.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-18 +description: > + Object.defineProperty - argument 'P' is a number that converts to + string (value is 1e+21) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e+21, {}); + +assert(obj.hasOwnProperty("1e+21"), 'obj.hasOwnProperty("1e+21") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-19.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-19.js new file mode 100644 index 0000000000..61b2777fe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-19.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-19 +description: > + Object.defineProperty - argument 'P' is a number that converts to + string (value is 1e+22) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e+22, {}); + +assert(obj.hasOwnProperty("1e+22"), 'obj.hasOwnProperty("1e+22") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-2.js new file mode 100644 index 0000000000..aead4fda4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-2.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-2 +description: > + Object.defineProperty - argument 'P' is null that converts to + string 'null' +---*/ + +var obj = {}; +Object.defineProperty(obj, null, {}); + +assert(obj.hasOwnProperty("null"), 'obj.hasOwnProperty("null") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-20.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-20.js new file mode 100644 index 0000000000..adf5a5a54d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-20.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-20 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 0.000001) +---*/ + +var obj = {}; +Object.defineProperty(obj, 0.000001, {}); + +assert(obj.hasOwnProperty("0.000001"), 'obj.hasOwnProperty("0.000001") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-21.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-21.js new file mode 100644 index 0000000000..63087964d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-21.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-21 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 0.0000001) +---*/ + +var obj = {}; +Object.defineProperty(obj, 0.0000001, {}); + +assert(obj.hasOwnProperty("1e-7"), 'obj.hasOwnProperty("1e-7") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-22.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-22.js new file mode 100644 index 0000000000..52691ced6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-22.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-22 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 0.00000001) +---*/ + +var obj = {}; +Object.defineProperty(obj, 0.00000001, {}); + +assert(obj.hasOwnProperty("1e-8"), 'obj.hasOwnProperty("1e-8") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-23.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-23.js new file mode 100644 index 0000000000..5587c2a1d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-23.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-23 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1e-7) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e-7, {}); + +assert(obj.hasOwnProperty("1e-7"), 'obj.hasOwnProperty("1e-7") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-24.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-24.js new file mode 100644 index 0000000000..3f23263180 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-24.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-24 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1e-6) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e-6, {}); + +assert(obj.hasOwnProperty("0.000001"), 'obj.hasOwnProperty("0.000001") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-25.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-25.js new file mode 100644 index 0000000000..831a8141f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-25.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-25 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1e-5) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1e-5, {}); + +assert(obj.hasOwnProperty("0.00001"), 'obj.hasOwnProperty("0.00001") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-26.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-26.js new file mode 100644 index 0000000000..27b5f1c9ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-26.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-26 +description: > + Object.defineProperty - argument 'P' is an integer that converts + to a string (value is 123) +---*/ + +var obj = {}; +Object.defineProperty(obj, 123, {}); + +assert(obj.hasOwnProperty("123"), 'obj.hasOwnProperty("123") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-27.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-27.js new file mode 100644 index 0000000000..5fd691c8f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-27.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-27 +description: > + Object.defineProperty - argument 'P' is a decimal that converts to + a string (value is 123.456) +---*/ + +var obj = {}; +Object.defineProperty(obj, 123.456, {}); + +assert(obj.hasOwnProperty("123.456"), 'obj.hasOwnProperty("123.456") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-28.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-28.js new file mode 100644 index 0000000000..34dbcd6729 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-28.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-28 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 19 zeros).1) +---*/ + +var obj = {}; +Object.defineProperty(obj, 10000000000000000000.1, {}); + +assert(obj.hasOwnProperty("10000000000000000000"), 'obj.hasOwnProperty("10000000000000000000") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-29.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-29.js new file mode 100644 index 0000000000..3a9bbbdbad --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-29.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-29 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 20 zeros).1) +---*/ + +var obj = {}; +Object.defineProperty(obj, 100000000000000000000.1, {}); + +assert(obj.hasOwnProperty("100000000000000000000"), 'obj.hasOwnProperty("100000000000000000000") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-3.js new file mode 100644 index 0000000000..7795fbed0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-3.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-3 +description: > + Object.defineProperty - argument 'P' is a boolean whose value is + false +---*/ + +var obj = {}; +Object.defineProperty(obj, false, {}); + +assert(obj.hasOwnProperty("false"), 'obj.hasOwnProperty("false") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-30.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-30.js new file mode 100644 index 0000000000..d4c2aef75c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-30.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-30 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 21 zeros).1) +---*/ + +var obj = {}; +Object.defineProperty(obj, 1000000000000000000000.1, {}); + +assert(obj.hasOwnProperty("1e+21"), 'obj.hasOwnProperty("1e+21") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-31.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-31.js new file mode 100644 index 0000000000..8bb17e8749 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-31.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-31 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 1(following 22 zeros).1) +---*/ + +var obj = {}; +Object.defineProperty(obj, 10000000000000000000000.1, {}); + +assert(obj.hasOwnProperty("1e+22"), 'obj.hasOwnProperty("1e+22") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-32.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-32.js new file mode 100644 index 0000000000..07693a2673 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-32.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-32 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 123.1234567) +---*/ + +var obj = {}; +Object.defineProperty(obj, 123.1234567, {}); + +assert(obj.hasOwnProperty("123.1234567"), 'obj.hasOwnProperty("123.1234567") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-33.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-33.js new file mode 100644 index 0000000000..f7b0ea7f23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-33.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. + +/*--- +es5id: 15.2.3.6-2-33 +description: Object.defineProperty - argument 'P' is applied to an empty string +---*/ + +var obj = {}; +Object.defineProperty(obj, "", {}); + +assert(obj.hasOwnProperty(""), 'obj.hasOwnProperty("") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-34.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-34.js new file mode 100644 index 0000000000..8be5d677bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-34.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. + +/*--- +es5id: 15.2.3.6-2-34 +description: Object.defineProperty - argument 'P' is applied to string 'AB \cd' +---*/ + +var obj = {}; +Object.defineProperty(obj, "AB\n\\cd", {}); + +assert(obj.hasOwnProperty("AB\n\\cd"), 'obj.hasOwnProperty("AB\n\\cd") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-35.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-35.js new file mode 100644 index 0000000000..f8d9ded21b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-35.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-35 +description: > + Object.defineProperty - argument 'P' is applied to string + 'undefined' +---*/ + +var obj = {}; +Object.defineProperty(obj, "undefined", {}); + +assert(obj.hasOwnProperty("undefined"), 'obj.hasOwnProperty("undefined") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-36.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-36.js new file mode 100644 index 0000000000..465db16a17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-36.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. + +/*--- +es5id: 15.2.3.6-2-36 +description: Object.defineProperty - argument 'P' is applied to string 'null' +---*/ + +var obj = {}; +Object.defineProperty(obj, "null", {}); + +assert(obj.hasOwnProperty("null"), 'obj.hasOwnProperty("null") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-37.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-37.js new file mode 100644 index 0000000000..abaa54913b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-37.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-37 +description: > + Object.defineProperty - argument 'P' is applied to string + '123αβπcd' +---*/ + +var obj = {}; +Object.defineProperty(obj, "123αβπcd", {}); + +assert(obj.hasOwnProperty("123αβπcd"), 'obj.hasOwnProperty("123αβπcd") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-38.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-38.js new file mode 100644 index 0000000000..9df02e80c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-38.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. + +/*--- +es5id: 15.2.3.6-2-38 +description: Object.defineProperty - argument 'P' is applied to string '1' +---*/ + +var obj = {}; +Object.defineProperty(obj, "1", {}); + +assert(obj.hasOwnProperty("1"), 'obj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-39.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-39.js new file mode 100644 index 0000000000..76ac86fbe5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-39.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-39 +description: > + Object.defineProperty - argument 'P' is an array that converts to + a string +---*/ + +var obj = {}; +Object.defineProperty(obj, [1, 2], {}); + +assert(obj.hasOwnProperty("1,2"), 'obj.hasOwnProperty("1,2") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-4.js new file mode 100644 index 0000000000..eb87be87d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-4 +description: > + Object.defineProperty - argument 'P' is a boolean whose value is + true +---*/ + +var obj = {}; +Object.defineProperty(obj, true, {}); + +assert(obj.hasOwnProperty("true"), 'obj.hasOwnProperty("true") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-40.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-40.js new file mode 100644 index 0000000000..a447e8eb7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-40.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-40 +description: > + Object.defineProperty - argument 'P' is a String Object that + converts to a string +---*/ + +var obj = {}; +Object.defineProperty(obj, new String("Hello"), {}); + +assert(obj.hasOwnProperty("Hello"), 'obj.hasOwnProperty("Hello") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-41.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-41.js new file mode 100644 index 0000000000..4472709e24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-41.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-41 +description: > + Object.defineProperty - argument 'P' is a Boolean Object that + converts to a string +---*/ + +var obj = {}; +Object.defineProperty(obj, new Boolean(false), {}); + +assert(obj.hasOwnProperty("false"), 'obj.hasOwnProperty("false") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-42.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-42.js new file mode 100644 index 0000000000..6f45293a7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-42.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-42 +description: > + Object.defineProperty - argument 'P' is a Number Object that + converts to a string +---*/ + +var obj = {}; +Object.defineProperty(obj, new Number(123), {}); + +assert(obj.hasOwnProperty("123"), 'obj.hasOwnProperty("123") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-43.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-43.js new file mode 100644 index 0000000000..7a80d5f8e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-43.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. + +/*--- +es5id: 15.2.3.6-2-43 +description: > + Object.defineProperty - argument 'P' is an object that has an own + toString method +---*/ + +var obj = {}; + +var ownProp = { + toString: function() { + return "abc"; + } +}; + +Object.defineProperty(obj, ownProp, {}); + +assert(obj.hasOwnProperty("abc"), 'obj.hasOwnProperty("abc") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-44.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-44.js new file mode 100644 index 0000000000..a6d7429de0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-44.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. + +/*--- +es5id: 15.2.3.6-2-44 +description: > + Object.defineProperty - argument 'P' is an object that has an own + valueOf method +---*/ + +var obj = {}; + +var ownProp = { + valueOf: function() { + return "abc"; + }, + toString: undefined +}; + +Object.defineProperty(obj, ownProp, {}); + +assert(obj.hasOwnProperty("abc"), 'obj.hasOwnProperty("abc") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-45.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-45.js new file mode 100644 index 0000000000..2156a69401 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-45.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-45 +description: > + Object.defineProperty - argument 'P' is an object whose toString + method returns an object and whose valueOf method returns a + primitive value +---*/ + +var obj = {}; +var toStringAccessed = false; +var valueOfAccessed = false; + +var ownProp = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return "abc"; + } +}; + +Object.defineProperty(obj, ownProp, {}); + +assert(obj.hasOwnProperty("abc"), 'obj.hasOwnProperty("abc") !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-46.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-46.js new file mode 100644 index 0000000000..bf15ec924f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-46.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-46 +description: > + Object.defineProperty - argument 'P' is an object that has an own + toString and valueOf method +---*/ + +var obj = {}; +var toStringAccessed = false; +var valueOfAccessed = false; + +var ownProp = { + toString: function() { + toStringAccessed = true; + return "abc"; + }, + valueOf: function() { + valueOfAccessed = true; + return "prop"; + } +}; +Object.defineProperty(obj, ownProp, {}); + +assert(obj.hasOwnProperty("abc"), 'obj.hasOwnProperty("abc") !== true'); +assert.sameValue(valueOfAccessed, false, 'valueOfAccessed'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-47.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-47.js new file mode 100644 index 0000000000..71303c6e21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-47.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. + +/*--- +es5id: 15.2.3.6-2-47 +description: > + Object.defineProperty - TypeError exception is thrown when 'P' is + an object that neither toString nor valueOf returns a primitive + value +---*/ + +var obj = {}; +var toStringAccessed = false; +var valueOfAccessed = false; + +var ownProp = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.throws(TypeError, function() { + Object.defineProperty(obj, ownProp, {}); +}); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-48.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-48.js new file mode 100644 index 0000000000..3b997eed54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-48.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-48 +description: > + Object.defineProperty - an inherited toString method is invoked + when 'P' is an object with an own valueOf and an inherited + toString methods +---*/ + +var obj = {}; +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + toString: function() { + toStringAccessed = true; + return "test"; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.valueOf = function() { + valueOfAccessed = true; + return "10"; +}; + +Object.defineProperty(obj, child, {}); + +assert(obj.hasOwnProperty("test"), 'obj.hasOwnProperty("test") !== true'); +assert.sameValue(valueOfAccessed, false, 'valueOfAccessed'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-5.js new file mode 100644 index 0000000000..0ea5959bc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-5.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-5 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is NaN) +---*/ + +var obj = {}; +Object.defineProperty(obj, NaN, {}); + +assert(obj.hasOwnProperty("NaN"), 'obj.hasOwnProperty("NaN") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-6.js new file mode 100644 index 0000000000..8e8a548982 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-6 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is 0) +---*/ + +var obj = {}; +Object.defineProperty(obj, 0, {}); + +assert(obj.hasOwnProperty("0"), 'obj.hasOwnProperty("0") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-7.js new file mode 100644 index 0000000000..7725312dc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-7 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is +0) +---*/ + +var obj = {}; +Object.defineProperty(obj, +0, {}); + +assert(obj.hasOwnProperty("0"), 'obj.hasOwnProperty("0") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-8.js new file mode 100644 index 0000000000..fc9b767e59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-8.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-8 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is -0) +---*/ + +var obj = {}; +Object.defineProperty(obj, -0, {}); + +assert(obj.hasOwnProperty("0"), 'obj.hasOwnProperty("0") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-9.js new file mode 100644 index 0000000000..24b648cb01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-2-9.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-2-9 +description: > + Object.defineProperty - argument 'P' is a number that converts to + a string (value is a positive number) +---*/ + +var obj = {}; +Object.defineProperty(obj, 30, {}); + +assert(obj.hasOwnProperty("30"), 'obj.hasOwnProperty("30") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-1.js new file mode 100644 index 0000000000..f5bb1b783b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-1 +description: > + Object.defineProperty throws TypeError if desc has 'get' and + 'value' present(8.10.5 step 9.a) +---*/ + +var o = {}; + +// dummy getter +var getter = function() { + return 1; +} +var desc = { + get: getter, + value: 101 +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-10.js new file mode 100644 index 0000000000..7ea5acea6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-10.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-10 +description: > + Object.defineProperty throws TypeError if setter is not callable + but not undefined (Number)(8.10.5 step 8.b) +---*/ + +var o = {}; + +// dummy setter +var setter = 42; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.js new file mode 100644 index 0000000000..de37bdae68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-100.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. + +/*--- +es5id: 15.2.3.6-3-100 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + null (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: null +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-101.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-101.js new file mode 100644 index 0000000000..5593c40eac --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-101.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. + +/*--- +es5id: 15.2.3.6-3-101 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + true (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: true +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.js new file mode 100644 index 0000000000..a0abf592c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-102.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. + +/*--- +es5id: 15.2.3.6-3-102 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + false (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: false +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.js new file mode 100644 index 0000000000..c9b59463af --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-103.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. + +/*--- +es5id: 15.2.3.6-3-103 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + 0 (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: 0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.js new file mode 100644 index 0000000000..9ae7f58e48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-104.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. + +/*--- +es5id: 15.2.3.6-3-104 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + +0 (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: +0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.js new file mode 100644 index 0000000000..3055a6ff9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-105.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. + +/*--- +es5id: 15.2.3.6-3-105 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + -0 (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: -0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.js new file mode 100644 index 0000000000..c6a037f9a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-106.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. + +/*--- +es5id: 15.2.3.6-3-106 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + NaN (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: NaN +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-107.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-107.js new file mode 100644 index 0000000000..7c154ae5ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-107.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. + +/*--- +es5id: 15.2.3.6-3-107 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a positive number (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: 12345 +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-108.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-108.js new file mode 100644 index 0000000000..4aad8d160b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-108.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. + +/*--- +es5id: 15.2.3.6-3-108 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a negative number (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: -12345 +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.js new file mode 100644 index 0000000000..575c4c9459 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-109.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. + +/*--- +es5id: 15.2.3.6-3-109 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + an empty string (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: "" +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-11.js new file mode 100644 index 0000000000..4b9db99ad5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-11.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-11 +description: > + Object.defineProperty throws TypeError if setter is not callable + but not undefined (Boolean)(8.10.5 step 8.b) +---*/ + +var o = {}; + +// dummy setter +var setter = true; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-110.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-110.js new file mode 100644 index 0000000000..91d47c027a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-110.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. + +/*--- +es5id: 15.2.3.6-3-110 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a non-empty string (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: " " +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-111.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-111.js new file mode 100644 index 0000000000..3a85f1b1c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-111.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. + +/*--- +es5id: 15.2.3.6-3-111 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a Function object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: function() {} +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-112.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-112.js new file mode 100644 index 0000000000..82fc78a52e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-112.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. + +/*--- +es5id: 15.2.3.6-3-112 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + an Array object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: [1, 2, 3] +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-113.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-113.js new file mode 100644 index 0000000000..a60d3b36db --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-113.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. + +/*--- +es5id: 15.2.3.6-3-113 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a String object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: new String("bbq") +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-114.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-114.js new file mode 100644 index 0000000000..f826c3cd04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-114.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. + +/*--- +es5id: 15.2.3.6-3-114 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a Boolean object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: new Boolean(true) +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-115.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-115.js new file mode 100644 index 0000000000..50baf89ad8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-115.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. + +/*--- +es5id: 15.2.3.6-3-115 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a Number object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: new Number(0) +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-116.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-116.js new file mode 100644 index 0000000000..136912c9c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-116.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. + +/*--- +es5id: 15.2.3.6-3-116 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + the Math object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: Math +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-117.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-117.js new file mode 100644 index 0000000000..5b8ab322a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-117.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. + +/*--- +es5id: 15.2.3.6-3-117 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a Date object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: new Date() +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-118.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-118.js new file mode 100644 index 0000000000..b344727eb1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-118.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. + +/*--- +es5id: 15.2.3.6-3-118 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a RegExp object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: new RegExp() +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-119.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-119.js new file mode 100644 index 0000000000..7aa8d47d3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-119.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. + +/*--- +es5id: 15.2.3.6-3-119 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + the JSON object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: JSON +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-12.js new file mode 100644 index 0000000000..709fc0f123 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-12.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-12 +description: > + Object.defineProperty throws TypeError if setter is not callable + but not undefined (String)(8.10.5 step 8.b) +---*/ + +var o = {}; + +// dummy setter +var setter = "abc"; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-120.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-120.js new file mode 100644 index 0000000000..73dcff62fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-120.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. + +/*--- +es5id: 15.2.3.6-3-120 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + a Error object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: new SyntaxError() +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-121.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-121.js new file mode 100644 index 0000000000..7f50d0f580 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-121.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. + +/*--- +es5id: 15.2.3.6-3-121 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + the Argument object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(1, true, "a"); + +var attr = { + configurable: argObj +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-123.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-123.js new file mode 100644 index 0000000000..52338365b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-123.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. + +/*--- +es5id: 15.2.3.6-3-123 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + the global object (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: this +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-124.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-124.js new file mode 100644 index 0000000000..a4122cb888 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-124.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-124 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + treated as true when it is a string (value is 'false') (8.10.5 + step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: "false" +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-125.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-125.js new file mode 100644 index 0000000000..1c8e4c8e52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-125.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. + +/*--- +es5id: 15.2.3.6-3-125 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + treated as true when it is new Boolean(false) (8.10.5 step 4.b) +---*/ + +var obj = {}; + +var attr = { + configurable: new Boolean(false) +}; + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-126.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-126.js new file mode 100644 index 0000000000..dbebc69ca8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-126.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. + +/*--- +es5id: 15.2.3.6-3-126 +description: > + Object.defineProperty - 'value' property in 'Attributes' is + present (8.10.5 step 5) +---*/ + +var obj = {}; + +var attr = { + value: 100 +}; + +Object.defineProperty(obj, "property", attr); + +assert.sameValue(obj.property, 100, 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-127.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-127.js new file mode 100644 index 0000000000..0ca5fc444a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-127.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: 15.2.3.6-3-127 +description: > + Object.defineProperty - 'value' property in 'Attributes' is not + present (8.10.5 step 5) +---*/ + +var obj = {}; + +var attr = { + writable: true +}; + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-129.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-129.js new file mode 100644 index 0000000000..205e077f24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-129.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. + +/*--- +es5id: 15.2.3.6-3-129 +description: > + Object.defineProperty - 'value' property in 'Attributes' is an + inherited data property (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = { + value: "inheritedDataProperty" +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "inheritedDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-13.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-13.js new file mode 100644 index 0000000000..b70fcee363 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-13.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-13 +description: > + Object.defineProperty throws TypeError if the setter in desc is + not callable (Null)(8.10.5 step 8.b) +---*/ + +var o = {}; + +// dummy setter +var setter = null; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-130.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-130.js new file mode 100644 index 0000000000..84be9fed20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-130.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-130 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + data property that overrides an inherited data property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var proto = { + value: "inheritedDataProperty" +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +child.value = "ownDataProperty"; + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-131.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-131.js new file mode 100644 index 0000000000..97807b1632 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-131.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-131 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + data property that overrides an inherited accessor property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = {}; + +Object.defineProperty(proto, "value", { + get: function() { + return "inheritedAccessorProperty"; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "value", { + value: "ownDataProperty" +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-132.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-132.js new file mode 100644 index 0000000000..b4ed5928eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-132.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. + +/*--- +es5id: 15.2.3.6-3-132 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + accessor property (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "value", { + get: function() { + return "ownAccessorProperty"; + } +}); + +Object.defineProperty(obj, "property", attr); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-133.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-133.js new file mode 100644 index 0000000000..88dc6a0f73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-133.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-133 +description: > + Object.defineProperty - 'value' property in 'Attributes' is an + inherited accessor property (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "value", { + get: function() { + return "inheritedAccessorProperty"; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "inheritedAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-134.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-134.js new file mode 100644 index 0000000000..3a25f765fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-134.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. + +/*--- +es5id: 15.2.3.6-3-134 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + accessor property that overrides an inherited data property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = { + value: "inheritedDataProperty" +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "value", { + get: function() { + return "ownAccessorProperty"; + } +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-135.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-135.js new file mode 100644 index 0000000000..50198c5ae7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-135.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-135 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + accessor property that overrides an inherited accessor property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "value", { + get: function() { + return "inheritedAccessorProperty"; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "value", { + get: function() { + return "ownAccessorProperty"; + } +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-136.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-136.js new file mode 100644 index 0000000000..9be927b53b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-136.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. + +/*--- +es5id: 15.2.3.6-3-136 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + accessor property without a get function (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "value", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-137.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-137.js new file mode 100644 index 0000000000..1f44e0f8a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-137.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-137 +description: > + Object.defineProperty - 'value' property in 'Attributes' is own + accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "value", { + get: function() { + return "inheritedAccessorProperty"; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "value", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-138.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-138.js new file mode 100644 index 0000000000..a9d91855d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-138.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-138 +description: > + Object.defineProperty - 'value' property in 'Attributes' is an + inherited accessor property without a get function (8.10.5 step + 5.a) +---*/ + +var obj = { + property: 120 +}; + +var proto = {}; +Object.defineProperty(proto, "value", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139-1.js new file mode 100644 index 0000000000..444ee5bac7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139-1.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. + +/*--- +es5id: 15.2.3.6-3-139-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'value' property + of prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Function.prototype.value = "Function"; +var funObj = function(a, b) { + return a + b; +}; + +Object.defineProperty(obj, "property", funObj); + +assert.sameValue(obj.property, "Function", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139.js new file mode 100644 index 0000000000..4f6f504d65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-139.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. + +/*--- +es5id: 15.2.3.6-3-139 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'value' property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var funObj = function(a, b) { + return a + b; +}; + +funObj.value = "Function"; + +Object.defineProperty(obj, "property", funObj); + +assert.sameValue(obj.property, "Function", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-14.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-14.js new file mode 100644 index 0000000000..4cb226bb24 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-14.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-14 +description: > + Object.defineProperty throws TypeError if setter is not callable + but not undefined (Object)(8.10.5 step 8.b) +---*/ + +var o = {}; + +// dummy getter +var setter = { + a: 1 +}; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140-1.js new file mode 100644 index 0000000000..4ca9143203 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140-1.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. + +/*--- +es5id: 15.2.3.6-3-140-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Array.prototype.value = "Array"; +var arrObj = [1, 2, 3]; + +Object.defineProperty(obj, "property", arrObj); + +assert.sameValue(obj.property, "Array", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140.js new file mode 100644 index 0000000000..6751452791 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-140.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: 15.2.3.6-3-140 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var arrObj = [1, 2, 3]; + +arrObj.value = "Array"; + +Object.defineProperty(obj, "property", arrObj); + +assert.sameValue(obj.property, "Array", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141-1.js new file mode 100644 index 0000000000..0dbe8517ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141-1.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. + +/*--- +es5id: 15.2.3.6-3-141-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +String.prototype.value = "String"; +var strObj = new String("abc"); + +Object.defineProperty(obj, "property", strObj); + +assert.sameValue(obj.property, "String", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141.js new file mode 100644 index 0000000000..25318a61b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-141.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: 15.2.3.6-3-141 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var strObj = new String("abc"); + +strObj.value = "String"; + +Object.defineProperty(obj, "property", strObj); + +assert.sameValue(obj.property, "String", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142-1.js new file mode 100644 index 0000000000..afbc09f3c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142-1.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. + +/*--- +es5id: 15.2.3.6-3-142-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Boolean.prototype.value = "Boolean"; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); + +assert.sameValue(obj.property, "Boolean", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142.js new file mode 100644 index 0000000000..e74f960115 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-142.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: 15.2.3.6-3-142 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var boolObj = new Boolean(true); + +boolObj.value = "Boolean"; + +Object.defineProperty(obj, "property", boolObj); + +assert.sameValue(obj.property, "Boolean", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143-1.js new file mode 100644 index 0000000000..056d1095e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143-1.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. + +/*--- +es5id: 15.2.3.6-3-143-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Number.prototype.value = "Number"; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); + +assert.sameValue(obj.property, "Number", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143.js new file mode 100644 index 0000000000..5b6908dcba --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-143.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: 15.2.3.6-3-143 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var numObj = new Number(-2); + +numObj.value = "Number"; + +Object.defineProperty(obj, "property", numObj); + +assert.sameValue(obj.property, "Number", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144-1.js new file mode 100644 index 0000000000..76dca84b34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144-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. + +/*--- +es5id: 15.2.3.6-3-144-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Object.prototype.value = "Math"; + +Object.defineProperty(obj, "property", Math); + +assert.sameValue(obj.property, "Math", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144.js new file mode 100644 index 0000000000..8c5e882947 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-144.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: 15.2.3.6-3-144 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +Math.value = "Math"; + +Object.defineProperty(obj, "property", Math); + +assert.sameValue(obj.property, "Math", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145-1.js new file mode 100644 index 0000000000..facae33e0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145-1.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. + +/*--- +es5id: 15.2.3.6-3-145-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Date.prototype.value = "Date"; +var dateObj = new Date(); + +Object.defineProperty(obj, "property", dateObj); + +assert.sameValue(obj.property, "Date", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145.js new file mode 100644 index 0000000000..ea29c759b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-145.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: 15.2.3.6-3-145 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var dateObj = new Date(); + +dateObj.value = "Date"; + +Object.defineProperty(obj, "property", dateObj); + +assert.sameValue(obj.property, "Date", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146-1.js new file mode 100644 index 0000000000..f6a8b72fd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146-1.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. + +/*--- +es5id: 15.2.3.6-3-146-1 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +RegExp.prototype.value = "RegExp"; +var regObj = new RegExp(); + +Object.defineProperty(obj, "property", regObj); + +assert.sameValue(obj.property, "RegExp", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146.js new file mode 100644 index 0000000000..dde77d28c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-146.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: 15.2.3.6-3-146 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var regObj = new RegExp(); + +regObj.value = "RegExp"; + +Object.defineProperty(obj, "property", regObj); + +assert.sameValue(obj.property, "RegExp", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147-1.js new file mode 100644 index 0000000000..3d8d1d19fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147-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. + +/*--- +es5id: 15.2.3.6-3-147-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Object.prototype.value = "JSON"; + +Object.defineProperty(obj, "property", JSON); + +assert.sameValue(obj.property, "JSON", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147.js new file mode 100644 index 0000000000..c9d65ab79c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-147.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: 15.2.3.6-3-147 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +JSON.value = "JSON"; + +Object.defineProperty(obj, "property", JSON); + +assert.sameValue(obj.property, "JSON", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148-1.js new file mode 100644 index 0000000000..ca65bd3788 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148-1.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. + +/*--- +es5id: 15.2.3.6-3-148-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'value' property of + prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Error.prototype.value = "Error"; +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); + +assert.sameValue(obj.property, "Error", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148.js new file mode 100644 index 0000000000..9b5367a1f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-148.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: 15.2.3.6-3-148 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'value' property (8.10.5 + step 5.a) +---*/ + +var obj = {}; + +var errObj = new Error(); + +errObj.value = "Error"; + +Object.defineProperty(obj, "property", errObj); + +assert.sameValue(obj.property, "Error", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149-1.js new file mode 100644 index 0000000000..77cbf27119 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149-1.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. + +/*--- +es5id: 15.2.3.6-3-149-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'value' property + of prototype object (8.10.5 step 5.a) +---*/ + +var obj = {}; + +Object.prototype.value = "arguments"; +var argObj = (function() { + return arguments; +})(); + + +Object.defineProperty(obj, "property", argObj); + +assert.sameValue(obj.property, "arguments", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149.js new file mode 100644 index 0000000000..ec0ba3354a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-149.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. + +/*--- +es5id: 15.2.3.6-3-149 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'value' property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(); + +argObj.value = "arguments"; + +Object.defineProperty(obj, "property", argObj); + +assert.sameValue(obj.property, "arguments", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-15.js new file mode 100644 index 0000000000..9cefe1867a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-15.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. + +/*--- +es5id: 15.2.3.6-3-15 +description: Object.defineProperty - 'Attributes' is undefined (8.10.5 step 1) +---*/ + +var obj = {}; +assert.throws(TypeError, function() { + Object.defineProperty(obj, "property", undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-151.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-151.js new file mode 100644 index 0000000000..0b2c843f70 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-151.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: 15.2.3.6-3-151 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'value' property + (8.10.5 step 5.a) +---*/ + +var obj = {}; + +this.value = "global"; + +Object.defineProperty(obj, "property", this); + +assert.sameValue(obj.property, "global", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.js new file mode 100644 index 0000000000..87913b2d2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-152.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. + +/*--- +es5id: 15.2.3.6-3-152 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + present (8.10.5 step 6) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var attr = { + writable: false +}; + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.js new file mode 100644 index 0000000000..20c3e5c191 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-153.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. + +/*--- +es5id: 15.2.3.6-3-153 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is not + present (8.10.5 step 6) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var attr = { + value: 100 +}; + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-154.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-154.js new file mode 100644 index 0000000000..cb9d525c84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-154.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. + +/*--- +es5id: 15.2.3.6-3-154 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + data property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var attr = { + writable: true +}; + +Object.defineProperty(obj, "property", attr); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-155.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-155.js new file mode 100644 index 0000000000..c263509dc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-155.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-155 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is an + inherited data property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var proto = { + writable: true +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-156.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-156.js new file mode 100644 index 0000000000..92a5f4b5d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-156.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-156 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + data property that overrides an inherited data property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var proto = { + writable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.writable = true; + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-157.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-157.js new file mode 100644 index 0000000000..53ab93c445 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-157.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-157 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + data property that overrides an inherited accessor property + (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "writable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "writable", { + value: true +}); + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-158.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-158.js new file mode 100644 index 0000000000..066e92a946 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-158.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-158 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + accessor property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "writable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", attr); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-159.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-159.js new file mode 100644 index 0000000000..409c2ba6c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-159.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-159 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is an + inherited accessor property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "writable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-16.js new file mode 100644 index 0000000000..f1a398eb31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-16.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-16 +description: Object.defineProperty - 'Attributes' is null (8.10.5 step 1) +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty({}, "property", null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-160.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-160.js new file mode 100644 index 0000000000..a95d0134bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-160.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-160 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + accessor property that overrides an inherited data property + (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var proto = { + writable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "writable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-161.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-161.js new file mode 100644 index 0000000000..6d4f5298e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-161.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-161 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + accessor property that overrides an inherited accessor property + (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "writable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "writable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.js new file mode 100644 index 0000000000..088bb9d5d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-162.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. + +/*--- +es5id: 15.2.3.6-3-162 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + accessor property without a get function (8.10.5 step 6.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "writable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js new file mode 100644 index 0000000000..bfd2ff3dfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-163.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-163 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is own + accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 6.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "writable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "writable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js new file mode 100644 index 0000000000..61fe9a5583 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-164.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-164 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is an + inherited accessor property without a get function (8.10.5 step + 6.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "writable", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165-1.js new file mode 100644 index 0000000000..2821ab6772 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-165-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'writable' + property of prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Function.prototype.writable = true; +var funObj = function(a, b) { + return a + b; +}; + +Object.defineProperty(obj, "property", funObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165.js new file mode 100644 index 0000000000..368e30b6cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-165.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-165 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'writable' + property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var funObj = function(a, b) { + return a + b; +}; + +funObj.writable = true; + +Object.defineProperty(obj, "property", funObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166-1.js new file mode 100644 index 0000000000..a53286acdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166-1.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. + +/*--- +es5id: 15.2.3.6-3-166-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Array.prototype.writable = true; +var arrObj = [1, 2, 3]; + +Object.defineProperty(obj, "property", arrObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166.js new file mode 100644 index 0000000000..80704d9996 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-166.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-166 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var arrObj = [1, 2, 3]; + +arrObj.writable = true; + +Object.defineProperty(obj, "property", arrObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167-1.js new file mode 100644 index 0000000000..ff940f03d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167-1.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. + +/*--- +es5id: 15.2.3.6-3-167-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +String.prototype.writable = true; +var strObj = new String("abc"); + +Object.defineProperty(obj, "property", strObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167.js new file mode 100644 index 0000000000..0f02dbc091 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-167.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-167 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var strObj = new String("abc"); + +strObj.writable = true; + +Object.defineProperty(obj, "property", strObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168-1.js new file mode 100644 index 0000000000..61dfd5e523 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168-1.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. + +/*--- +es5id: 15.2.3.6-3-168-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Boolean.prototype.writable = true; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168.js new file mode 100644 index 0000000000..99020bc751 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-168.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-168 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var boolObj = new Boolean(true); + +boolObj.writable = true; + +Object.defineProperty(obj, "property", boolObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169-1.js new file mode 100644 index 0000000000..19b93a5881 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169-1.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. + +/*--- +es5id: 15.2.3.6-3-169-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Number.prototype.writable = true; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169.js new file mode 100644 index 0000000000..ea310b7838 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-169.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-169 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var numObj = new Number(-2); + +numObj.writable = true; + +Object.defineProperty(obj, "property", numObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-17.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-17.js new file mode 100644 index 0000000000..620d5c9a68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-17.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: 15.2.3.6-3-17 +description: > + Object.defineProperty - 'Attributes' is a boolean primitive + (8.10.5 step 1) +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty({}, "property", true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170-1.js new file mode 100644 index 0000000000..f17040876f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170-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. + +/*--- +es5id: 15.2.3.6-3-170-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.prototype.writable = true; + +Object.defineProperty(obj, "property", Math); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170.js new file mode 100644 index 0000000000..d51097d001 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-170.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. + +/*--- +es5id: 15.2.3.6-3-170 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +Math.writable = true; + +Object.defineProperty(obj, "property", Math); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.js new file mode 100644 index 0000000000..d8ee8da884 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171-1.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. + +/*--- +es5id: 15.2.3.6-3-171-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +try { + Date.prototype.writable = true; + + var dateObj = new Date(); + + Object.defineProperty(obj, "property", dateObj); + verifyWritable(obj, "property"); + +} finally { + delete Date.prototype.writable; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171.js new file mode 100644 index 0000000000..c1ca15e585 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-171.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-171 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var dateObj = new Date(); + +dateObj.writable = true; + +Object.defineProperty(obj, "property", dateObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172-1.js new file mode 100644 index 0000000000..23ae06bbcb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-172-1 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +RegExp.prototype.writable = true; + +var regObj = new RegExp(); + +Object.defineProperty(obj, "property", regObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172.js new file mode 100644 index 0000000000..842cc036b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-172.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-172 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var regObj = new RegExp(); + +regObj.writable = true; + +Object.defineProperty(obj, "property", regObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173-1.js new file mode 100644 index 0000000000..612e7243a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173-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. + +/*--- +es5id: 15.2.3.6-3-173-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.prototype.writable = true; + +Object.defineProperty(obj, "property", JSON); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173.js new file mode 100644 index 0000000000..5a836a9f7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-173.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. + +/*--- +es5id: 15.2.3.6-3-173 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +JSON.writable = true; + +Object.defineProperty(obj, "property", JSON); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174-1.js new file mode 100644 index 0000000000..1ffb4062a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-174-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'writable' property of + prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Error.prototype.writable = true; + +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174.js new file mode 100644 index 0000000000..382ae8cef5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-174.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-174 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'writable' property (8.10.5 + step 6.a) +---*/ + +var obj = {}; + +var errObj = new Error(); + +errObj.writable = true; + +Object.defineProperty(obj, "property", errObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175-1.js new file mode 100644 index 0000000000..42774ad55e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175-1.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-175-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'writable' + property of prototype object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.prototype.writable = true; + +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(obj, "property", argObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175.js new file mode 100644 index 0000000000..4c4579eab8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-175.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-175 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'writable' + property (8.10.5 step 6.a) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(); + +argObj.writable = true; + +Object.defineProperty(obj, "property", argObj); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-177.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-177.js new file mode 100644 index 0000000000..02ca9f73e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-177.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. + +/*--- +es5id: 15.2.3.6-3-177 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'writable' property + (8.10.5 step 6.a) +---*/ + +var obj = {}; + +this.writable = true; + +Object.defineProperty(obj, "property", this); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.js new file mode 100644 index 0000000000..42ab36b422 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-178.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. + +/*--- +es5id: 15.2.3.6-3-178 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + undefined (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: undefined +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.js new file mode 100644 index 0000000000..be0fca785e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-179.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. + +/*--- +es5id: 15.2.3.6-3-179 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + null (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: null +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-18.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-18.js new file mode 100644 index 0000000000..ac40d86a66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-18.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: 15.2.3.6-3-18 +description: > + Object.defineProperty - 'Attributes' is a number primitive (8.10.5 + step 1) +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty({}, "property", 12); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-180.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-180.js new file mode 100644 index 0000000000..fcab783b53 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-180.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. + +/*--- +es5id: 15.2.3.6-3-180 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + true (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: true +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.js new file mode 100644 index 0000000000..04a60062e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-181.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. + +/*--- +es5id: 15.2.3.6-3-181 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + false (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: false +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.js new file mode 100644 index 0000000000..e1506931c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-182.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. + +/*--- +es5id: 15.2.3.6-3-182 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is 0 + (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: 0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.js new file mode 100644 index 0000000000..08b46c555a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-183.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. + +/*--- +es5id: 15.2.3.6-3-183 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is +0 + (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: +0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.js new file mode 100644 index 0000000000..d456fbeb38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-184.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. + +/*--- +es5id: 15.2.3.6-3-184 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is -0 + (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: -0 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.js new file mode 100644 index 0000000000..81061f91f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-185.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. + +/*--- +es5id: 15.2.3.6-3-185 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + NaN (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: NaN +}); + +assert(obj.hasOwnProperty("property")); + +verifyNotWritable(obj, "property"); + +assert.sameValue(typeof(obj.property), "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-186.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-186.js new file mode 100644 index 0000000000..37100e18ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-186.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. + +/*--- +es5id: 15.2.3.6-3-186 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + positive number (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: 12345 +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-187.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-187.js new file mode 100644 index 0000000000..39948162d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-187.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. + +/*--- +es5id: 15.2.3.6-3-187 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + negative number (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: -12345 +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.js new file mode 100644 index 0000000000..29e6a06d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-188.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. + +/*--- +es5id: 15.2.3.6-3-188 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is an + empty string (8.10.5 step 6.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: "" +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-189.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-189.js new file mode 100644 index 0000000000..4061bc2094 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-189.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. + +/*--- +es5id: 15.2.3.6-3-189 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + non-empty string (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: " " +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-19.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-19.js new file mode 100644 index 0000000000..4206cc47c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-19.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: 15.2.3.6-3-19 +description: > + Object.defineProperty - 'Attributes' is a string primitive (8.10.5 + step 1) +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty({}, "property", "abc"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-190.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-190.js new file mode 100644 index 0000000000..e00b66381d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-190.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. + +/*--- +es5id: 15.2.3.6-3-190 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + Function object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: function() {} +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-191.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-191.js new file mode 100644 index 0000000000..d06e87dbc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-191.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. + +/*--- +es5id: 15.2.3.6-3-191 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is an + Array object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: [1, 2, 3] +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-192.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-192.js new file mode 100644 index 0000000000..e54f72a7a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-192.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. + +/*--- +es5id: 15.2.3.6-3-192 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + String object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new String("bbq") +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-193.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-193.js new file mode 100644 index 0000000000..00d785d147 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-193.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. + +/*--- +es5id: 15.2.3.6-3-193 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + Boolean object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new Boolean(true) +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-194.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-194.js new file mode 100644 index 0000000000..15730be9a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-194.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. + +/*--- +es5id: 15.2.3.6-3-194 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + Number object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new Number(123) +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-195.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-195.js new file mode 100644 index 0000000000..d0372c657a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-195.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. + +/*--- +es5id: 15.2.3.6-3-195 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is the + Math object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: Math +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-196.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-196.js new file mode 100644 index 0000000000..708f889f58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-196.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. + +/*--- +es5id: 15.2.3.6-3-196 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + Date object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new Date() +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-197.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-197.js new file mode 100644 index 0000000000..e08574efe0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-197.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. + +/*--- +es5id: 15.2.3.6-3-197 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + RegExp object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new RegExp() +}); + +var beforeWrite = obj.hasOwnProperty("property") && typeof obj.property === "undefined"; + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert(beforeWrite, 'beforeWrite !== true'); +assert(afterWrite, 'afterWrite !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-198.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-198.js new file mode 100644 index 0000000000..795b03e85f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-198.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. + +/*--- +es5id: 15.2.3.6-3-198 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is the + JSON object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: JSON +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-199.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-199.js new file mode 100644 index 0000000000..787cb597ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-199.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. + +/*--- +es5id: 15.2.3.6-3-199 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is a + Error object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new SyntaxError() +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-2.js new file mode 100644 index 0000000000..8d02967050 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-2.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-2 +description: > + Object.defineProperty throws TypeError if desc has 'get' and + 'writable' present(8.10.5 step 9.a) +---*/ + +var o = {}; + +// dummy getter +var getter = function() { + return 1; +} +var desc = { + get: getter, + writable: false +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-20.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-20.js new file mode 100644 index 0000000000..3abd3c77bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-20.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. + +/*--- +es5id: 15.2.3.6-3-20 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + present (8.10.5 step 3) +---*/ + +var obj = {}; + +var accessed = false; +Object.defineProperty(obj, "property", { + enumerable: false +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-200.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-200.js new file mode 100644 index 0000000000..6c4e3f8a8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-200.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-200 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is the + Argument object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(1, true, "a"); + +Object.defineProperty(obj, "property", { + writable: argObj +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-202.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-202.js new file mode 100644 index 0000000000..4758c979ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-202.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. + +/*--- +es5id: 15.2.3.6-3-202 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is the + global object (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: this +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-203.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-203.js new file mode 100644 index 0000000000..fe8837e340 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-203.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. + +/*--- +es5id: 15.2.3.6-3-203 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + treated as true when it is a string(value is 'false') (8.10.5 step + 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: "false" +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-204.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-204.js new file mode 100644 index 0000000000..ccc4a78caa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-204.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. + +/*--- +es5id: 15.2.3.6-3-204 +description: > + Object.defineProperty - 'writable' property in 'Attributes' is + treated as true when it is new Boolean(false) (8.10.5 step 6.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: new Boolean(false) +}); + +var beforeWrite = obj.hasOwnProperty("property"); + +obj.property = "isWritable"; + +var afterWrite = (obj.property === "isWritable"); + +assert.sameValue(beforeWrite, true, 'beforeWrite'); +assert.sameValue(afterWrite, true, 'afterWrite'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-205.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-205.js new file mode 100644 index 0000000000..a7b8b486c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-205.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. + +/*--- +es5id: 15.2.3.6-3-205 +description: > + Object.defineProperty - 'get' property in 'Attributes' is present + (8.10.5 step 7) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: function() { + return "present"; + } +}); + +assert.sameValue(obj.property, "present", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-206.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-206.js new file mode 100644 index 0000000000..f13597bebb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-206.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: 15.2.3.6-3-206 +description: > + Object.defineProperty - 'get' property in 'Attributes' is not + present (8.10.5 step 7) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + set: function() {} +}); + +assert.sameValue(typeof obj.property, "undefined", 'typeof obj.property'); +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-207.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-207.js new file mode 100644 index 0000000000..d5da5ab911 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-207.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: 15.2.3.6-3-207 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own data + property (8.10.5 step 7.a) +---*/ + +var obj = {}; +var attributes = { + get: function() { + return "ownDataProperty"; + } +}; + +Object.defineProperty(obj, "property", attributes); + +assert.sameValue(obj.property, "ownDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-208.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-208.js new file mode 100644 index 0000000000..7891396a3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-208.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. + +/*--- +es5id: 15.2.3.6-3-208 +description: > + Object.defineProperty - 'get' property in 'Attributes' is an + inherited data property (8.10.5 step 7.a) +---*/ + +var obj = {}; +var proto = { + get: function() { + return "inheritedDataProperty"; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "inheritedDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-209.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-209.js new file mode 100644 index 0000000000..07927d8efa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-209.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-209 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own data + property that overrides an inherited data property (8.10.5 step + 7.a) +---*/ + +var obj = {}; +var proto = { + get: function() { + return "inheritedDataProperty"; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.get = function() { + return "ownDataProperty"; +}; + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-21.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-21.js new file mode 100644 index 0000000000..1225bd4913 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-21.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. + +/*--- +es5id: 15.2.3.6-3-21 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + not present (8.10.5 step 3) +---*/ + +var obj = {}; + +var attr = {}; +var accessed = false; +Object.defineProperty(obj, "property", attr); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-210.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-210.js new file mode 100644 index 0000000000..c1f4d2c7a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-210.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-210 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own data + property that overrides an inherited accessor property (8.10.5 + step 7.a) +---*/ + +var obj = {}; +var proto = {}; +var fun = function() { + return "inheritedAccessorProperty"; +}; +Object.defineProperty(proto, "get", { + get: function() { + return fun; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "get", { + value: function() { + return "ownDataProperty"; + } +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownDataProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-211.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-211.js new file mode 100644 index 0000000000..0dfa711f7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-211.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. + +/*--- +es5id: 15.2.3.6-3-211 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own + accessor property (8.10.5 step 7.a) +---*/ + +var obj = {}; + +var attributes = {}; +Object.defineProperty(attributes, "get", { + get: function() { + return function() { + return "ownAccessorProperty"; + }; + } +}); + +Object.defineProperty(obj, "property", attributes); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-212.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-212.js new file mode 100644 index 0000000000..657d936f65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-212.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-212 +description: > + Object.defineProperty - 'get' property in 'Attributes' is an + inherited accessor property (8.10.5 step 7.a) +---*/ + +var obj = {}; +var proto = {}; +Object.defineProperty(proto, "get", { + get: function() { + return function() { + return "inheritedAccessorProperty"; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "inheritedAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-213.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-213.js new file mode 100644 index 0000000000..59e03352dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-213.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-213 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own + accessor property that overrides an inherited data property + (8.10.5 step 7.a) +---*/ + +var obj = {}; +var proto = { + get: function() { + return "inheritedDataProperty"; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "get", { + get: function() { + return function() { + return "ownAccessorProperty"; + }; + } +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-214.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-214.js new file mode 100644 index 0000000000..2306097d3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-214.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-214 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own + accessor property that overrides an inherited accessor property + (8.10.5 step 7.a) +---*/ + +var obj = {}; +var proto = {}; +Object.defineProperty(proto, "get", { + get: function() { + return function() { + return "inheritedAccessorProperty"; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "get", { + get: function() { + return function() { + return "ownAccessorProperty"; + }; + } +}); + +Object.defineProperty(obj, "property", child); + +assert.sameValue(obj.property, "ownAccessorProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-215.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-215.js new file mode 100644 index 0000000000..14e442c9da --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-215.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. + +/*--- +es5id: 15.2.3.6-3-215 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own + accessor property without a get function (8.10.5 step 7.a) +---*/ + +var obj = {}; + +var attributes = {}; +Object.defineProperty(attributes, "get", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attributes); + +assert.sameValue(typeof obj.property, "undefined", 'typeof obj.property'); +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-216.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-216.js new file mode 100644 index 0000000000..77017b73bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-216.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-216 +description: > + Object.defineProperty - 'get' property in 'Attributes' is own + accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 7.a) +---*/ + +var obj = {}; +var proto = {}; +Object.defineProperty(proto, "get", { + get: function() { + return function() { + return "inheritedAccessorProperty"; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "get", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof obj.property, "undefined", 'typeof obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-217.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-217.js new file mode 100644 index 0000000000..4acef5e27a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-217.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. + +/*--- +es5id: 15.2.3.6-3-217 +description: > + Object.defineProperty - 'get' property in 'Attributes' is an + inherited accessor property without a get function (8.10.5 step + 7.a) +---*/ + +var obj = {}; +var proto = {}; +Object.defineProperty(proto, "get", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof obj.property, "undefined", 'typeof obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218-1.js new file mode 100644 index 0000000000..cb6e82d1df --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218-1.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. + +/*--- +es5id: 15.2.3.6-3-218-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'get' property of + prototype object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Function.prototype.get = function() { + return "functionGetProperty"; +}; +var funObj = function() {}; + +Object.defineProperty(obj, "property", funObj); + +assert.sameValue(obj.property, "functionGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218.js new file mode 100644 index 0000000000..bcb7d2e737 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-218.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. + +/*--- +es5id: 15.2.3.6-3-218 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'get' property + (8.10.5 step 7.a) +---*/ + +var obj = {}; + +var funObj = function() {}; + +funObj.get = function() { + return "functionGetProperty"; +}; + +Object.defineProperty(obj, "property", funObj); + +assert.sameValue(obj.property, "functionGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219-1.js new file mode 100644 index 0000000000..929f61b361 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219-1.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. + +/*--- +es5id: 15.2.3.6-3-219-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Array.prototype.get = function() { + return "arrayGetProperty"; +}; +var arrObj = []; + +Object.defineProperty(obj, "property", arrObj); + +assert.sameValue(obj.property, "arrayGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219.js new file mode 100644 index 0000000000..f896351a4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-219.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. + +/*--- +es5id: 15.2.3.6-3-219 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var arrObj = []; + +arrObj.get = function() { + return "arrayGetProperty"; +}; + +Object.defineProperty(obj, "property", arrObj); + +assert.sameValue(obj.property, "arrayGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-22.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-22.js new file mode 100644 index 0000000000..76730e0b8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-22.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. + +/*--- +es5id: 15.2.3.6-3-22 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own data property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: true +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220-1.js new file mode 100644 index 0000000000..3abc78124e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220-1.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. + +/*--- +es5id: 15.2.3.6-3-220-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +String.prototype.get = function() { + return "stringGetProperty"; +}; +var strObj = new String(); + +Object.defineProperty(obj, "property", strObj); + +assert.sameValue(obj.property, "stringGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220.js new file mode 100644 index 0000000000..b98621c995 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-220.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. + +/*--- +es5id: 15.2.3.6-3-220 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var strObj = new String(); + +strObj.get = function() { + return "stringGetProperty"; +}; + +Object.defineProperty(obj, "property", strObj); + +assert.sameValue(obj.property, "stringGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221-1.js new file mode 100644 index 0000000000..b7c4695599 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221-1.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. + +/*--- +es5id: 15.2.3.6-3-221-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Boolean.prototype.get = function() { + return "booleanGetProperty"; +}; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); + +assert.sameValue(obj.property, "booleanGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221.js new file mode 100644 index 0000000000..b8f1d5f22f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-221.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. + +/*--- +es5id: 15.2.3.6-3-221 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var boolObj = new Boolean(true); + +boolObj.get = function() { + return "booleanGetProperty"; +}; + +Object.defineProperty(obj, "property", boolObj); + +assert.sameValue(obj.property, "booleanGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222-1.js new file mode 100644 index 0000000000..654421a5f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222-1.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. + +/*--- +es5id: 15.2.3.6-3-222-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Number.prototype.get = function() { + return "numberGetProperty"; +}; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); + +assert.sameValue(obj.property, "numberGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222.js new file mode 100644 index 0000000000..2a47af48ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-222.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. + +/*--- +es5id: 15.2.3.6-3-222 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var numObj = new Number(-2); + +numObj.get = function() { + return "numberGetProperty"; +}; + +Object.defineProperty(obj, "property", numObj); + +assert.sameValue(obj.property, "numberGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223-1.js new file mode 100644 index 0000000000..d594d21a61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223-1.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: 15.2.3.6-3-223-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Object.prototype.get = function() { + return "mathGetProperty"; +}; + +Object.defineProperty(obj, "property", Math); + +assert.sameValue(obj.property, "mathGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223.js new file mode 100644 index 0000000000..650493171d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-223.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: 15.2.3.6-3-223 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +Math.get = function() { + return "mathGetProperty"; +}; + +Object.defineProperty(obj, "property", Math); + +assert.sameValue(obj.property, "mathGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224-1.js new file mode 100644 index 0000000000..a3511a42d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224-1.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. + +/*--- +es5id: 15.2.3.6-3-224-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Date.prototype.get = function() { + return "dateGetProperty"; +}; +var dateObj = new Date(); + +Object.defineProperty(obj, "property", dateObj); + +assert.sameValue(obj.property, "dateGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224.js new file mode 100644 index 0000000000..6a1c6b279a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-224.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. + +/*--- +es5id: 15.2.3.6-3-224 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var dateObj = new Date(); + +dateObj.get = function() { + return "dateGetProperty"; +}; + +Object.defineProperty(obj, "property", dateObj); + +assert.sameValue(obj.property, "dateGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225-1.js new file mode 100644 index 0000000000..72106eb354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225-1.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. + +/*--- +es5id: 15.2.3.6-3-225-1 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +RegExp.prototype.get = function() { + return "regExpGetProperty"; +}; +var regObj = new RegExp(); + + +Object.defineProperty(obj, "property", regObj); + +assert.sameValue(obj.property, "regExpGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225.js new file mode 100644 index 0000000000..5008c418f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-225.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. + +/*--- +es5id: 15.2.3.6-3-225 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var regObj = new RegExp(); + +regObj.get = function() { + return "regExpGetProperty"; +}; + +Object.defineProperty(obj, "property", regObj); + +assert.sameValue(obj.property, "regExpGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226-1.js new file mode 100644 index 0000000000..199d32a914 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226-1.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: 15.2.3.6-3-226-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Object.prototype.get = function() { + return "jsonGetProperty"; +}; + +Object.defineProperty(obj, "property", JSON); + +assert.sameValue(obj.property, "jsonGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226.js new file mode 100644 index 0000000000..6d6cbb3f28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-226.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: 15.2.3.6-3-226 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +JSON.get = function() { + return "jsonGetProperty"; +}; + +Object.defineProperty(obj, "property", JSON); + +assert.sameValue(obj.property, "jsonGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227-1.js new file mode 100644 index 0000000000..24644f07ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227-1.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. + +/*--- +es5id: 15.2.3.6-3-227-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'get' property of prototype + object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Error.prototype.get = function() { + return "errorGetProperty"; +}; +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); + +assert.sameValue(obj.property, "errorGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227.js new file mode 100644 index 0000000000..97591f9929 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-227.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. + +/*--- +es5id: 15.2.3.6-3-227 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'get' property (8.10.5 step + 7.a) +---*/ + +var obj = {}; + +var errObj = new Error(); + +errObj.get = function() { + return "errorGetProperty"; +}; + +Object.defineProperty(obj, "property", errObj); + +assert.sameValue(obj.property, "errorGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228-1.js new file mode 100644 index 0000000000..4f61cdd4f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228-1.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. + +/*--- +es5id: 15.2.3.6-3-228-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'get' property of + prototype object (8.10.5 step 7.a) +---*/ + +var obj = {}; + +Object.prototype.get = function() { + return "argumentGetProperty"; +}; +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(obj, "property", argObj); + +assert.sameValue(obj.property, "argumentGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228.js new file mode 100644 index 0000000000..c160ec3db7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-228.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. + +/*--- +es5id: 15.2.3.6-3-228 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'get' property + (8.10.5 step 7.a) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(); + +argObj.get = function() { + return "argumentGetProperty"; +}; + +Object.defineProperty(obj, "property", argObj); + +assert.sameValue(obj.property, "argumentGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-23.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-23.js new file mode 100644 index 0000000000..4cba7def73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-23.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-23 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + an inherited data property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var proto = {}; +Object.defineProperty(proto, "enumerable", { + value: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-230.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-230.js new file mode 100644 index 0000000000..29aa610879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-230.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: 15.2.3.6-3-230 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'get' property (8.10.5 + step 7.a) +---*/ + +var obj = {}; + +this.get = function() { + return "globalGetProperty"; +}; + +Object.defineProperty(obj, "property", this); + +assert.sameValue(obj.property, "globalGetProperty", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-231.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-231.js new file mode 100644 index 0000000000..93e561661f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-231.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: 15.2.3.6-3-231 +description: > + Object.defineProperty - value of 'get' property in 'Attributes' is + undefined (8.10.5 step 7.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: undefined +}); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof obj.property, "undefined", 'typeof obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-232.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-232.js new file mode 100644 index 0000000000..16b31733f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-232.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: 15.2.3.6-3-232 +description: > + Object.defineProperty - value of 'get' property in 'Attributes' is + a function (8.10.5 step 7.b) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: function() { + return "getFunction"; + } +}); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(obj.property, "getFunction", 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-235.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-235.js new file mode 100644 index 0000000000..4f661cd7e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-235.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. + +/*--- +es5id: 15.2.3.6-3-235 +description: > + Object.defineProperty - 'set' property in 'Attributes' is present + (8.10.5 step 8) +---*/ + +var obj = {}; +var data = "data"; + +Object.defineProperty(obj, "property", { + set: function(value) { + data = value; + } +}); + +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-236.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-236.js new file mode 100644 index 0000000000..1aade5cdb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-236.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. + +/*--- +es5id: 15.2.3.6-3-236 +description: > + Object.defineProperty - 'set' property in 'Attributes' is not + present (8.10.5 step 8) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: function() { + return 11; + } +}); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-237.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-237.js new file mode 100644 index 0000000000..9f8700c8bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-237.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. + +/*--- +es5id: 15.2.3.6-3-237 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own data + property (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Object.defineProperty(obj, "property", { + set: function(value) { + data = value; + } +}); + +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-238.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-238.js new file mode 100644 index 0000000000..843bb131ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-238.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-238 +description: > + Object.defineProperty - 'set' property in 'Attributes' is an + inherited data property (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; +var proto = { + set: function(value) { + data = value; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-239.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-239.js new file mode 100644 index 0000000000..03fdde5785 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-239.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-239 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own data + property that overrides an inherited data property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data1 = "data"; +var data2 = "data"; +var proto = { + set: function(value) { + data1 = value; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.set = function(value) { + data2 = value; +}; + +Object.defineProperty(obj, "property", child); + +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data1, "data", 'data1'); +assert.sameValue(data2, "overrideData", 'data2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-24.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-24.js new file mode 100644 index 0000000000..6de470315b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-24.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-24 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own data property that overrides an inherited data property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var proto = {}; +Object.defineProperty(proto, "enumerable", { + value: false +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "enumerable", { + value: true +}); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-240.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-240.js new file mode 100644 index 0000000000..3c46844005 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-240.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-240 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own data + property that overrides an inherited accessor property (8.10.5 + step 8.a) +---*/ + +var obj = {}; +var proto = {}; +var data1 = "data"; +var data2 = "data"; + +Object.defineProperty(proto, "set", { + get: function() { + return function(value) { + data1 = value; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "set", { + value: function(value) { + data2 = value; + } +}); + +Object.defineProperty(obj, "property", child); + +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data1, "data", 'data1'); +assert.sameValue(data2, "overrideData", 'data2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-241.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-241.js new file mode 100644 index 0000000000..25a5bcf665 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-241.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. + +/*--- +es5id: 15.2.3.6-3-241 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own + accessor property (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; +var attributes = {}; +Object.defineProperty(attributes, "set", { + get: function() { + return function(value) { + data = value; + }; + } +}); + +Object.defineProperty(obj, "property", attributes); +obj.property = "ownAccessorProperty"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "ownAccessorProperty", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-242.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-242.js new file mode 100644 index 0000000000..96f28c5b37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-242.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-242 +description: > + Object.defineProperty - 'set' property in 'Attributes' is an + inherited accessor property (8.10.5 step 8.a) +---*/ + +var obj = {}; +var proto = {}; +var data = "data"; +Object.defineProperty(proto, "set", { + get: function() { + return function(value) { + data = value; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); +obj.property = "inheritedAccessorProperty"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "inheritedAccessorProperty", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-243.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-243.js new file mode 100644 index 0000000000..b959e3aca5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-243.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-243 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own + accessor property that overrides an inherited data property + (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data1 = "data"; +var data2 = "data"; + +var proto = { + set: function(value) { + data1 = value; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "set", { + get: function() { + return function(value) { + data2 = value; + }; + } +}); + +Object.defineProperty(obj, "property", child); +obj.property = "ownAccessorProperty"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data1, "data", 'data1'); +assert.sameValue(data2, "ownAccessorProperty", 'data2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-244.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-244.js new file mode 100644 index 0000000000..418a65251f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-244.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-244 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own + accessor property that overrides an inherited accessor property + (8.10.5 step 8.a) +---*/ + +var obj = {}; +var proto = {}; +var data1 = "data"; +var data2 = "data"; +Object.defineProperty(proto, "set", { + get: function() { + return function(value) { + data1 = value; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "set", { + get: function() { + return function(value) { + data2 = value; + }; + } +}); + +Object.defineProperty(obj, "property", child); +obj.property = "ownAccessorProperty"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data1, "data", 'data1'); +assert.sameValue(data2, "ownAccessorProperty", 'data2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-245.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-245.js new file mode 100644 index 0000000000..f7e231e45e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-245.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-245 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own + accessor property without a get function (8.10.5 step 8.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var attributes = {}; +Object.defineProperty(attributes, "set", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attributes); + +verifyNotWritable(obj, "property"); + +var desc = Object.getOwnPropertyDescriptor(obj, "property"); + +assert(obj.hasOwnProperty("property")); +assert.sameValue(typeof obj.property, "undefined"); +assert.sameValue(typeof desc.set, "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-246.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-246.js new file mode 100644 index 0000000000..1ac0edb30b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-246.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-246 +description: > + Object.defineProperty - 'set' property in 'Attributes' is own + accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 8.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var proto = {}; +var data = "data"; +Object.defineProperty(proto, "set", { + get: function() { + return function(value) { + data = value; + }; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "set", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +verifyNotWritable(obj, "property"); + +assert.sameValue(typeof obj.property, "undefined"); +assert.sameValue(data, "data"); + +assert(obj.hasOwnProperty("property")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-247.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-247.js new file mode 100644 index 0000000000..7c3f46d87c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-247.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-247 +description: > + Object.defineProperty - 'set' property in 'Attributes' is an + inherited accessor property without a get function (8.10.5 step + 8.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var proto = {}; +Object.defineProperty(proto, "set", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248-1.js new file mode 100644 index 0000000000..4edb6fabed --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248-1.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. + +/*--- +es5id: 15.2.3.6-3-248-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'set' property of + prototype object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Function.prototype.set = function(value) { + data = value; +}; +var funObj = function() {}; + +Object.defineProperty(obj, "property", funObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248.js new file mode 100644 index 0000000000..22da395e54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-248.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. + +/*--- +es5id: 15.2.3.6-3-248 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'set' property + (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; +var funObj = function() {}; + +funObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", funObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249-1.js new file mode 100644 index 0000000000..de80096156 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249-1.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. + +/*--- +es5id: 15.2.3.6-3-249-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Array.prototype.set = function(value) { + data = value; +}; +var arrObj = []; + +Object.defineProperty(obj, "property", arrObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249.js new file mode 100644 index 0000000000..d18e24c996 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-249.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. + +/*--- +es5id: 15.2.3.6-3-249 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var arrObj = []; + +arrObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", arrObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-25.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-25.js new file mode 100644 index 0000000000..09d3f967ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-25.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-25 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own data property that overrides an inherited accessor property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var proto = {}; +Object.defineProperty(proto, "enumerable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "enumerable", { + value: true +}); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250-1.js new file mode 100644 index 0000000000..f3f6bba2f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250-1.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. + +/*--- +es5id: 15.2.3.6-3-250-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; + +String.prototype.set = function(value) { + data = value; +}; +var strObj = new String(); +var data = "data"; + +Object.defineProperty(obj, "property", strObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250.js new file mode 100644 index 0000000000..e8874f6c3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-250.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. + +/*--- +es5id: 15.2.3.6-3-250 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var strObj = new String(); +var data = "data"; + +strObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", strObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251-1.js new file mode 100644 index 0000000000..e5046e9b66 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251-1.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. + +/*--- +es5id: 15.2.3.6-3-251-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Boolean.prototype.set = function(value) { + data = value; +}; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251.js new file mode 100644 index 0000000000..3993d7c82a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-251.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. + +/*--- +es5id: 15.2.3.6-3-251 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var boolObj = new Boolean(true); + +boolObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", boolObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252-1.js new file mode 100644 index 0000000000..07a7559276 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252-1.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. + +/*--- +es5id: 15.2.3.6-3-252-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Number.prototype.set = function(value) { + data = value; +}; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252.js new file mode 100644 index 0000000000..479421c879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-252.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. + +/*--- +es5id: 15.2.3.6-3-252 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var numObj = new Number(-2); + +numObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", numObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253-1.js new file mode 100644 index 0000000000..7327a3e7af --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253-1.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. + +/*--- +es5id: 15.2.3.6-3-253-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Object.prototype.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", Math); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253.js new file mode 100644 index 0000000000..1367770594 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-253.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. + +/*--- +es5id: 15.2.3.6-3-253 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Math.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", Math); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254-1.js new file mode 100644 index 0000000000..03a59fe2ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254-1.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. + +/*--- +es5id: 15.2.3.6-3-254-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Date.prototype.set = function(value) { + data = value; +}; +var dateObj = new Date(); + +Object.defineProperty(obj, "property", dateObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254.js new file mode 100644 index 0000000000..53010e849a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-254.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. + +/*--- +es5id: 15.2.3.6-3-254 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var dateObj = new Date(); + +dateObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", dateObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255-1.js new file mode 100644 index 0000000000..01c9632dcd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255-1.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. + +/*--- +es5id: 15.2.3.6-3-255-1 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +RegExp.prototype.set = function(value) { + data = value; +}; +var regObj = new RegExp(); + +Object.defineProperty(obj, "property", regObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255.js new file mode 100644 index 0000000000..b51f9ee021 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-255.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. + +/*--- +es5id: 15.2.3.6-3-255 +description: > + Object.defineProperty - 'Attributes' is a RegExp object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var regObj = new RegExp(); + +regObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", regObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256-1.js new file mode 100644 index 0000000000..f619c3c185 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256-1.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. + +/*--- +es5id: 15.2.3.6-3-256-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Object.prototype.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", JSON); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256.js new file mode 100644 index 0000000000..af2d5c27b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-256.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. + +/*--- +es5id: 15.2.3.6-3-256 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; + +JSON.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", JSON); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257-1.js new file mode 100644 index 0000000000..a7c7f0dd85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257-1.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. + +/*--- +es5id: 15.2.3.6-3-257-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'set' property of prototype + object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Error.prototype.set = function(value) { + data = value; +}; +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257.js new file mode 100644 index 0000000000..ead729262a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-257.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. + +/*--- +es5id: 15.2.3.6-3-257 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'set' property (8.10.5 step + 8.a) +---*/ + +var obj = {}; +var data = "data"; +var errObj = new Error(); + +errObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", errObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258-1.js new file mode 100644 index 0000000000..5d8cdec335 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258-1.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. + +/*--- +es5id: 15.2.3.6-3-258-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'set' property of + prototype object (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +Object.prototype.set = function(value) { + data = value; +}; +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(obj, "property", argObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258.js new file mode 100644 index 0000000000..c614237e87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-258.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. + +/*--- +es5id: 15.2.3.6-3-258 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'set' property + (8.10.5 step 8.a) +---*/ + +var obj = {}; +var data = "data"; +var argObj = (function() { + return arguments; +})(); +argObj.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", argObj); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-26.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-26.js new file mode 100644 index 0000000000..17e26a9259 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-26.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-26 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own accessor property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var attr = {}; +Object.defineProperty(attr, "enumerable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", attr); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-260.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-260.js new file mode 100644 index 0000000000..cee78d4f73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-260.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. + +/*--- +es5id: 15.2.3.6-3-260 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'set' property (8.10.5 + step 8.a) +---*/ + +var obj = {}; +var data = "data"; + +this.set = function(value) { + data = value; +}; + +Object.defineProperty(obj, "property", this); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-261.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-261.js new file mode 100644 index 0000000000..dbb19915e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-261.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. + +/*--- +es5id: 15.2.3.6-3-261 +description: > + Object.defineProperty - value of 'set' property in 'Attributes' is + undefined (8.10.5 step 8.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + set: undefined +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "property"); + +assert(obj.hasOwnProperty("property")); +verifyNotWritable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-262.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-262.js new file mode 100644 index 0000000000..4c3cb62889 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-262.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. + +/*--- +es5id: 15.2.3.6-3-262 +description: > + Object.defineProperty - value of 'set' property in 'Attributes' is + a function (8.10.5 step 8.b) +---*/ + +var obj = {}; +var data = "data"; + +Object.defineProperty(obj, "property", { + set: function(value) { + data = value; + } +}); +obj.property = "overrideData"; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(data, "overrideData", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-27.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-27.js new file mode 100644 index 0000000000..9644362ff2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-27.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-27 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + an inherited accessor property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var proto = {}; +Object.defineProperty(proto, "enumerable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-28.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-28.js new file mode 100644 index 0000000000..3a9f78a675 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-28.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-28 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own accessor property that overrides an inherited data property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var proto = { + enumerable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(child, "enumerable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-29.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-29.js new file mode 100644 index 0000000000..34ef15fee6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-29.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-29 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own accessor property that overrides an inherited accessor + property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; +var proto = {}; + +Object.defineProperty(proto, "enumerable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(child, "enumerable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-3.js new file mode 100644 index 0000000000..b881b648a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-3 +description: > + Object.defineProperty throws TypeError if desc has 'set' and + 'value' present(8.10.5 step 9.a) +---*/ + +var o = {}; + +// dummy setter +var setter = function() {} +var desc = { + set: setter, + value: 101 +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-30.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-30.js new file mode 100644 index 0000000000..829bb02117 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-30.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-30 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own accessor property without a get function (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var attr = {}; +Object.defineProperty(attr, "enumerable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attr); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-31.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-31.js new file mode 100644 index 0000000000..b343002b64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-31.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-31 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + own accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; +var proto = {}; + +Object.defineProperty(proto, "enumerable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(child, "enumerable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-32.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-32.js new file mode 100644 index 0000000000..a938c27750 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-32.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-32 +description: > + Object.defineProperty - 'enumerable' property in 'Attributes' is + an inherited accessor property without a get function (8.10.5 step + 3.a) +---*/ + +var obj = {}; +var accessed = false; +var proto = {}; + +Object.defineProperty(proto, "enumerable", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33-1.js new file mode 100644 index 0000000000..08b05b45b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33-1.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. + +/*--- +es5id: 15.2.3.6-3-33-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'enumerable' + property of prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Function.prototype.enumerable = true; +var fun = function() {}; + +Object.defineProperty(obj, "property", fun); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33.js new file mode 100644 index 0000000000..253bbd6fa8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-33.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. + +/*--- +es5id: 15.2.3.6-3-33 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'enumerable' + property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var fun = function() {}; +fun.enumerable = true; + +Object.defineProperty(obj, "property", fun); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34-1.js new file mode 100644 index 0000000000..02574877dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34-1.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. + +/*--- +es5id: 15.2.3.6-3-34-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Array.prototype.enumerable = true; +var arrObj = []; + +Object.defineProperty(obj, "property", arrObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34.js new file mode 100644 index 0000000000..c3db1bb320 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-34.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. + +/*--- +es5id: 15.2.3.6-3-34 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var arrObj = []; +arrObj.enumerable = true; + +Object.defineProperty(obj, "property", arrObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35-1.js new file mode 100644 index 0000000000..0319b48ac4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35-1.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. + +/*--- +es5id: 15.2.3.6-3-35-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +String.prototype.enumerable = true; +var strObj = new String(); + +Object.defineProperty(obj, "property", strObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35.js new file mode 100644 index 0000000000..2d4a51c83a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-35.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. + +/*--- +es5id: 15.2.3.6-3-35 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var strObj = new String(); +strObj.enumerable = true; + +Object.defineProperty(obj, "property", strObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36-1.js new file mode 100644 index 0000000000..3d75971d5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36-1.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. + +/*--- +es5id: 15.2.3.6-3-36-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Boolean.prototype.enumerable = true; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36.js new file mode 100644 index 0000000000..1ac0a9a31b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-36.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. + +/*--- +es5id: 15.2.3.6-3-36 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var boolObj = new Boolean(true); +boolObj.enumerable = true; + +Object.defineProperty(obj, "property", boolObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37-1.js new file mode 100644 index 0000000000..abd72173c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37-1.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. + +/*--- +es5id: 15.2.3.6-3-37-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Number.prototype.enumerable = true; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37.js new file mode 100644 index 0000000000..8b781bf354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-37.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. + +/*--- +es5id: 15.2.3.6-3-37 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var numObj = new Number(-2); +numObj.enumerable = true; + +Object.defineProperty(obj, "property", numObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38-1.js new file mode 100644 index 0000000000..216e127165 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38-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. + +/*--- +es5id: 15.2.3.6-3-38-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Object.prototype.enumerable = true; + +Object.defineProperty(obj, "property", Math); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38.js new file mode 100644 index 0000000000..fc7ca0931a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-38.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. + +/*--- +es5id: 15.2.3.6-3-38 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Math.enumerable = true; + +Object.defineProperty(obj, "property", Math); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39-1.js new file mode 100644 index 0000000000..af264b53d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39-1.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. + +/*--- +es5id: 15.2.3.6-3-39-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Date.prototype.enumerable = true; +var dateObj = new Date(); + +Object.defineProperty(obj, "property", dateObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39.js new file mode 100644 index 0000000000..6dff863697 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-39.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. + +/*--- +es5id: 15.2.3.6-3-39 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var dateObj = new Date(); +dateObj.enumerable = true; + +Object.defineProperty(obj, "property", dateObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-4.js new file mode 100644 index 0000000000..6094fafa1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-4.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-4 +description: > + Object.defineProperty throws TypeError if desc has 'set' and + 'writable' present(8.10.5 step 9.a) +---*/ + +var o = {}; + +// dummy getter +var setter = function() {} +var desc = { + set: setter, + writable: false +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40-1.js new file mode 100644 index 0000000000..3825e62f47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40-1.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. + +/*--- +es5id: 15.2.3.6-3-40-1 +description: > + Object.defineProperty - 'Attributes' is an RegExp object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +RegExp.prototype.enumerable = true; +var regObj = new RegExp(); + +Object.defineProperty(obj, "property", regObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40.js new file mode 100644 index 0000000000..3f2272f1e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-40.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. + +/*--- +es5id: 15.2.3.6-3-40 +description: > + Object.defineProperty - 'Attributes' is an RegExp object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var regObj = new RegExp(); +regObj.enumerable = true; + +Object.defineProperty(obj, "property", regObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41-1.js new file mode 100644 index 0000000000..92b5b52a77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41-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. + +/*--- +es5id: 15.2.3.6-3-41-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Object.prototype.enumerable = true; + +Object.defineProperty(obj, "property", JSON); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41.js new file mode 100644 index 0000000000..64b6bdc293 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-41.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. + +/*--- +es5id: 15.2.3.6-3-41 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +JSON.enumerable = true; + +Object.defineProperty(obj, "property", JSON); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42-1.js new file mode 100644 index 0000000000..14fe43adf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42-1.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. + +/*--- +es5id: 15.2.3.6-3-42-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'enumerable' property of + prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Error.prototype.enumerable = true; +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42.js new file mode 100644 index 0000000000..f5781ac3e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-42.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. + +/*--- +es5id: 15.2.3.6-3-42 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var errObj = new Error(); +errObj.enumerable = true; + +Object.defineProperty(obj, "property", errObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43-1.js new file mode 100644 index 0000000000..6e64e8f305 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-43-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'enumerable' + property of prototype object (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +Object.prototype.enumerable = true; +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(obj, "property", argObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43.js new file mode 100644 index 0000000000..a9b9271c3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-43.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-43 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'enumerable' + property (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +var argObj = (function() { + return arguments; +})(); +argObj.enumerable = true; + +Object.defineProperty(obj, "property", argObj); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-45.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-45.js new file mode 100644 index 0000000000..ef414a936b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-45.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. + +/*--- +es5id: 15.2.3.6-3-45 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'enumerable' property + (8.10.5 step 3.a) +---*/ + +var obj = {}; +var accessed = false; + +this.enumerable = true; + +Object.defineProperty(obj, "property", this); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-46.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-46.js new file mode 100644 index 0000000000..60c0e62cbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-46.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. + +/*--- +es5id: 15.2.3.6-3-46 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is undefined (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: undefined +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-47.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-47.js new file mode 100644 index 0000000000..7c91011d9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-47.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. + +/*--- +es5id: 15.2.3.6-3-47 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is null (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: null +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-48.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-48.js new file mode 100644 index 0000000000..f35549a3a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-48.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. + +/*--- +es5id: 15.2.3.6-3-48 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is true (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: true +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-49.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-49.js new file mode 100644 index 0000000000..0456d9e3d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-49.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. + +/*--- +es5id: 15.2.3.6-3-49 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is false (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: false +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-5.js new file mode 100644 index 0000000000..33c8ea9c23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-5.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-5 +description: > + Object.defineProperty throws TypeError if getter is not callable + but not undefined (Number)(8.10.5 step 7.b) +---*/ + +var o = {}; + +// dummy getter +var getter = 42; +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-50.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-50.js new file mode 100644 index 0000000000..736d97a926 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-50.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. + +/*--- +es5id: 15.2.3.6-3-50 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is 0 (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: 0 +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-51.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-51.js new file mode 100644 index 0000000000..1c625e8fb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-51.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. + +/*--- +es5id: 15.2.3.6-3-51 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is +0 (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: +0 +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-52.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-52.js new file mode 100644 index 0000000000..5ff4156232 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-52.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. + +/*--- +es5id: 15.2.3.6-3-52 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is -0 (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: -0 +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-53.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-53.js new file mode 100644 index 0000000000..e00a220d0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-53.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. + +/*--- +es5id: 15.2.3.6-3-53 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is NaN (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: NaN +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-54.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-54.js new file mode 100644 index 0000000000..088f3f85b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-54.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. + +/*--- +es5id: 15.2.3.6-3-54 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a positive number (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: 12 +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-55.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-55.js new file mode 100644 index 0000000000..4a34e236a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-55.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. + +/*--- +es5id: 15.2.3.6-3-55 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a negative number (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: -2 +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-56.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-56.js new file mode 100644 index 0000000000..a31c78e9df --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-56.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. + +/*--- +es5id: 15.2.3.6-3-56 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is an empty string (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: "" +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-57.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-57.js new file mode 100644 index 0000000000..a23c65c9d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-57.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. + +/*--- +es5id: 15.2.3.6-3-57 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a non-empty string (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: "AB\n\\cd" +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-58.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-58.js new file mode 100644 index 0000000000..e3cf96af5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-58.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. + +/*--- +es5id: 15.2.3.6-3-58 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a Function object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: function() {} +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-59.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-59.js new file mode 100644 index 0000000000..4fff4bae8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-59.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. + +/*--- +es5id: 15.2.3.6-3-59 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is an Array object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: [] +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-6.js new file mode 100644 index 0000000000..dc5da2297a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-6.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-6 +description: > + Object.defineProperty throws TypeError if getter is not callable + but not undefined (Boolean)(8.10.5 step 7.b) +---*/ + +var o = {}; + +// dummy getter +var getter = true; +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-60.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-60.js new file mode 100644 index 0000000000..caf4c81fea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-60.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. + +/*--- +es5id: 15.2.3.6-3-60 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a String Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new String() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-61.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-61.js new file mode 100644 index 0000000000..182996fca8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-61.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. + +/*--- +es5id: 15.2.3.6-3-61 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a Boolean Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new Boolean() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-62.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-62.js new file mode 100644 index 0000000000..6c21bd9bff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-62.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. + +/*--- +es5id: 15.2.3.6-3-62 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a Number Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new Number() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-63.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-63.js new file mode 100644 index 0000000000..95c7bdf415 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-63.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. + +/*--- +es5id: 15.2.3.6-3-63 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is the Math Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: Math +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-64.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-64.js new file mode 100644 index 0000000000..12fbea3f87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-64.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. + +/*--- +es5id: 15.2.3.6-3-64 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a Date Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new Date() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-65.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-65.js new file mode 100644 index 0000000000..169cd7a1ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-65.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. + +/*--- +es5id: 15.2.3.6-3-65 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is a RegExp Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new RegExp() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-66.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-66.js new file mode 100644 index 0000000000..2da5cc0042 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-66.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. + +/*--- +es5id: 15.2.3.6-3-66 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is the JSON Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: JSON +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-67.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-67.js new file mode 100644 index 0000000000..e544a3e756 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-67.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. + +/*--- +es5id: 15.2.3.6-3-67 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is an Error Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new Error() +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-68.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-68.js new file mode 100644 index 0000000000..37721703e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-68.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-68 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is an Arguments Object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; +var argObj = (function() { + return arguments; +})(0, 1, 2); + +Object.defineProperty(obj, "property", { + enumerable: argObj +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-7.js new file mode 100644 index 0000000000..22b52bdb59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-7.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-7 +description: > + Object.defineProperty throws TypeError if getter is not callable + but not undefined (String)(8.10.5 step 7.b) +---*/ + +var o = {}; + +// dummy getter +var getter = "abc"; +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-70.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-70.js new file mode 100644 index 0000000000..f2f6860918 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-70.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. + +/*--- +es5id: 15.2.3.6-3-70 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is the global object (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: this +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-71.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-71.js new file mode 100644 index 0000000000..26c910d1c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-71.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. + +/*--- +es5id: 15.2.3.6-3-71 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is treated as true when it is a string (value is + 'false') (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: "false" +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-72.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-72.js new file mode 100644 index 0000000000..35004b426f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-72.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. + +/*--- +es5id: 15.2.3.6-3-72 +description: > + Object.defineProperty - value of 'enumerable' property in + 'Attributes' is new Boolean(false) which is treated as true value + (8.10.5 step 3.b) +---*/ + +var obj = {}; +var accessed = false; + +Object.defineProperty(obj, "property", { + enumerable: new Boolean(false) +}); + +for (var prop in obj) { + if (prop === "property") { + accessed = true; + } +} + +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.js new file mode 100644 index 0000000000..965fa44537 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-73.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. + +/*--- +es5id: 15.2.3.6-3-73 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + present (8.10.5 step 4) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: false +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.js new file mode 100644 index 0000000000..443d61a4a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-74.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. + +/*--- +es5id: 15.2.3.6-3-74 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + not present (8.10.5 step 4) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 100 +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-75.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-75.js new file mode 100644 index 0000000000..30c5d53090 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-75.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. + +/*--- +es5id: 15.2.3.6-3-75 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own data property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: true +}); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js new file mode 100644 index 0000000000..076c86ede5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-76.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-76 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + an inherited data property (8.10.5 step 4.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var proto = { + configurable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); + +verifyNotConfigurable(obj, "property"); + +assert(obj.hasOwnProperty("property")); + +assert.sameValue(typeof(obj.property), "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-77.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-77.js new file mode 100644 index 0000000000..d5b38d7c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-77.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-77 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own data property that overrides an inherited data property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var proto = { + configurable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.configurable = true; + +Object.defineProperty(obj, "property", child); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-78.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-78.js new file mode 100644 index 0000000000..d61327b686 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-78.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-78 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own data property that overrides an inherited accessor property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var proto = {}; + +Object.defineProperty(proto, "configurable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "configurable", { + value: true +}); + +Object.defineProperty(obj, "property", child); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-79.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-79.js new file mode 100644 index 0000000000..962fd06375 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-79.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-79 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own accessor property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "configurable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", attr); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-8.js new file mode 100644 index 0000000000..65baf21693 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-8.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: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-8 +description: > + Object.defineProperty throws TypeError if getter is not callable + but not undefined (Null)(8.10.5 step 7.b) +---*/ + +var o = {}; + +// dummy getter +var getter = null; +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-80.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-80.js new file mode 100644 index 0000000000..a15e67824a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-80.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-80 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + an inherited accessor property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "configurable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-81.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-81.js new file mode 100644 index 0000000000..7ce29be186 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-81.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-81 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own accessor property that overrides an inherited data property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var proto = { + configurable: false +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "configurable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-82.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-82.js new file mode 100644 index 0000000000..de771e073a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-82.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-82 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own accessor property that overrides an inherited accessor + property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "configurable", { + get: function() { + return false; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "configurable", { + get: function() { + return true; + } +}); + +Object.defineProperty(obj, "property", child); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.js new file mode 100644 index 0000000000..1ab0672165 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-83.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. + +/*--- +es5id: 15.2.3.6-3-83 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own accessor property without a get function (8.10.5 step 4.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var attr = {}; +Object.defineProperty(attr, "configurable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", attr); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js new file mode 100644 index 0000000000..2361aa0708 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-84.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-84 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + own accessor property(without a get function) that overrides an + inherited accessor property (8.10.5 step 4.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "configurable", { + get: function() { + return true; + } +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +Object.defineProperty(child, "configurable", { + set: function() {} +}); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js new file mode 100644 index 0000000000..0b0868625f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-85.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-85 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + an inherited accessor property without a get function (8.10.5 step + 4.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var proto = {}; +Object.defineProperty(proto, "configurable", { + set: function() {} +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); + +Object.defineProperty(obj, "property", child); + +assert(obj.hasOwnProperty("property")); + +verifyNotConfigurable(obj, "property"); + +assert(obj.hasOwnProperty("property")); +assert.sameValue(typeof(obj.property), "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86-1.js new file mode 100644 index 0000000000..2024068458 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-86-1 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'configurable' + property of prototype object (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Function.prototype.configurable = true; +var funObj = function(a, b) { + return a + b; +}; + +Object.defineProperty(obj, "property", funObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86.js new file mode 100644 index 0000000000..512a37fafa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-86.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-86 +description: > + Object.defineProperty - 'Attributes' is a Function object which + implements its own [[Get]] method to access the 'configurable' + property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var funObj = function(a, b) { + return a + b; +}; + +funObj.configurable = true; + +Object.defineProperty(obj, "property", funObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87-1.js new file mode 100644 index 0000000000..6bbf484f20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87-1.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. + +/*--- +es5id: 15.2.3.6-3-87-1 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Array.prototype.configurable = true; +var arrObj = [1, 2, 3]; + +Object.defineProperty(obj, "property", arrObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87.js new file mode 100644 index 0000000000..0462349a5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-87.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-87 +description: > + Object.defineProperty - 'Attributes' is an Array object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var arrObj = [1, 2, 3]; + +arrObj.configurable = true; + +Object.defineProperty(obj, "property", arrObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88-1.js new file mode 100644 index 0000000000..005a7544ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88-1.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. + +/*--- +es5id: 15.2.3.6-3-88-1 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +String.prototype.configurable = true; +var strObj = new String("abc"); + +Object.defineProperty(obj, "property", strObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88.js new file mode 100644 index 0000000000..cfef428e43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-88.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-88 +description: > + Object.defineProperty - 'Attributes' is a String object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var strObj = new String("abc"); + +strObj.configurable = true; + +Object.defineProperty(obj, "property", strObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89-1.js new file mode 100644 index 0000000000..a2e0e0af99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89-1.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. + +/*--- +es5id: 15.2.3.6-3-89-1 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Boolean.prototype.configurable = true; +var boolObj = new Boolean(true); + +Object.defineProperty(obj, "property", boolObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89.js new file mode 100644 index 0000000000..44df1b6e3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-89.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-89 +description: > + Object.defineProperty - 'Attributes' is a Boolean object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var boolObj = new Boolean(true); + +boolObj.configurable = true; + +Object.defineProperty(obj, "property", boolObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-9.js new file mode 100644 index 0000000000..5a9310275b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-9.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The abtract operation ToPropertyDescriptor is used to package the + into a property desc. Step 10 of ToPropertyDescriptor throws a TypeError + if the property desc ends up having a mix of accessor and data property elements. +es5id: 15.2.3.6-3-9 +description: > + Object.defineProperty throws TypeError if getter is not callable + but not undefined (Object)(8.10.5 step 7.b) +---*/ + +var o = {}; + +// dummy getter +var getter = { + a: 1 +}; +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90-1.js new file mode 100644 index 0000000000..6079a53c82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90-1.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. + +/*--- +es5id: 15.2.3.6-3-90-1 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Number.prototype.configurable = true; +var numObj = new Number(-2); + +Object.defineProperty(obj, "property", numObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90.js new file mode 100644 index 0000000000..d684335835 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-90.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-90 +description: > + Object.defineProperty - 'Attributes' is a Number object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var numObj = new Number(-2); + +numObj.configurable = true; + +Object.defineProperty(obj, "property", numObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91-1.js new file mode 100644 index 0000000000..567248b150 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91-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. + +/*--- +es5id: 15.2.3.6-3-91-1 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Object.prototype.configurable = true; + +Object.defineProperty(obj, "property", Math); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91.js new file mode 100644 index 0000000000..302774537c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-91.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. + +/*--- +es5id: 15.2.3.6-3-91 +description: > + Object.defineProperty - 'Attributes' is the Math object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Math.configurable = true; + +Object.defineProperty(obj, "property", Math); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92-1.js new file mode 100644 index 0000000000..7bb3580ce5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92-1.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. + +/*--- +es5id: 15.2.3.6-3-92-1 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Date.prototype.configurable = true; +var dateObj = new Date(); + +Object.defineProperty(obj, "property", dateObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92.js new file mode 100644 index 0000000000..cd9bf29b9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-92.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-92 +description: > + Object.defineProperty - 'Attributes' is a Date object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var dateObj = new Date(); + +dateObj.configurable = true; + +Object.defineProperty(obj, "property", dateObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93-1.js new file mode 100644 index 0000000000..f5736ccaa5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93-1.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. + +/*--- +es5id: 15.2.3.6-3-93-1 +description: > + Object.defineProperty - 'Attributes' is an RegExp object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +RegExp.prototype.configurable = true; +var regObj = new RegExp(); + +Object.defineProperty(obj, "property", regObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93.js new file mode 100644 index 0000000000..595a3b6857 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-93.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-93 +description: > + Object.defineProperty - 'Attributes' is an RegExp object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var regObj = new RegExp(); + +regObj.configurable = true; + +Object.defineProperty(obj, "property", regObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94-1.js new file mode 100644 index 0000000000..d0b6c4dadf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94-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. + +/*--- +es5id: 15.2.3.6-3-94-1 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Object.prototype.configurable = true; + +Object.defineProperty(obj, "property", JSON); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94.js new file mode 100644 index 0000000000..f5b58f85f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-94.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. + +/*--- +es5id: 15.2.3.6-3-94 +description: > + Object.defineProperty - 'Attributes' is the JSON object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +JSON.configurable = true; + +Object.defineProperty(obj, "property", JSON); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95-1.js new file mode 100644 index 0000000000..2a06a28507 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95-1.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. + +/*--- +es5id: 15.2.3.6-3-95-1 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Error.prototype.configurable = true; +var errObj = new Error(); + +Object.defineProperty(obj, "property", errObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95.js new file mode 100644 index 0000000000..b17895a478 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-95.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-95 +description: > + Object.defineProperty - 'Attributes' is an Error object that uses + Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var errObj = new Error(); + +errObj.configurable = true; + +Object.defineProperty(obj, "property", errObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96-1.js new file mode 100644 index 0000000000..29f10ca5cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-96-1 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'configurable' + property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +Object.prototype.configurable = true; +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(obj, "property", argObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96.js new file mode 100644 index 0000000000..8c54cf0175 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-96.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-3-96 +description: > + Object.defineProperty - 'Attributes' is an Arguments object which + implements its own [[Get]] method to access the 'configurable' + property (8.10.5 step 4.a) +---*/ + +var obj = {}; + +var argObj = (function() { + return arguments; +})(); +argObj.configurable = true; + +Object.defineProperty(obj, "property", argObj); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-98.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-98.js new file mode 100644 index 0000000000..5079bbd85b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-98.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. + +/*--- +es5id: 15.2.3.6-3-98 +description: > + Object.defineProperty - 'Attributes' is the global object that + uses Object's [[Get]] method to access the 'configurable' property + (8.10.5 step 4.a) +---*/ + +var obj = {}; + +this.configurable = true; + +Object.defineProperty(obj, "property", this); + +var beforeDeleted = obj.hasOwnProperty("property"); + +delete obj.property; + +var afterDeleted = obj.hasOwnProperty("property"); + +assert.sameValue(beforeDeleted, true, 'beforeDeleted'); +assert.sameValue(afterDeleted, false, 'afterDeleted'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.js new file mode 100644 index 0000000000..aabe445bef --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-3-99.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. + +/*--- +es5id: 15.2.3.6-3-99 +description: > + Object.defineProperty - 'configurable' property in 'Attributes' is + undefined (8.10.5 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + configurable: undefined +}); + +assert(obj.hasOwnProperty("property")); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-1.js new file mode 100644 index 0000000000..2ec7824d67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-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: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O passing 'true' for the Throw flag. In this case, step 3 of + [[DefineOwnProperty]] requires that it throw a TypeError exception when + current is undefined and extensible is false. The value of desc does not + matter. +es5id: 15.2.3.6-4-1 +description: > + Object.defineProperty throws TypeError when adding properties to + non-extensible objects(8.12.9 step 3) +---*/ + +var o = {}; +Object.preventExtensions(o); +assert.throws(TypeError, function() { + var desc = { + value: 1 + }; + Object.defineProperty(o, "foo", desc); +}); +assert.sameValue(o.hasOwnProperty("foo"), false, 'o.hasOwnProperty("foo")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-10.js new file mode 100644 index 0000000000..732b55062c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-10.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 7b of [[DefineOwnProperty]] rejects if + current.[[Enumerable]] and desc.[[Enumerable]] are the boolean negations + of each other. +es5id: 15.2.3.6-4-10 +description: > + Object.defineProperty throws TypeError when changing + [[Enumerable]] from false to true on non-configurable accessor + properties +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter, + enumerable: false, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// now, setting enumerable to true should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + get: getter, + enumerable: true +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.js new file mode 100644 index 0000000000..34c2f090cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-100.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. + +/*--- +es5id: 15.2.3.6-4-100 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + desc.value and name.value are two different values (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.foo = 100; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: 200 +}); +verifyEqualTo(obj, "foo", 200); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.js new file mode 100644 index 0000000000..1da7826cf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-101.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. + +/*--- +es5id: 15.2.3.6-4-101 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + name.value is present and desc.value is undefined (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.foo = 100; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: undefined +}); +verifyEqualTo(obj, "foo", undefined); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.js new file mode 100644 index 0000000000..33d84c9f53 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-102.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. + +/*--- +es5id: 15.2.3.6-4-102 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + desc.value is present and name.value is undefined (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.foo = undefined; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: 100 +}); +verifyEqualTo(obj, "foo", 100); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js new file mode 100644 index 0000000000..b98b2837f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-103.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-103 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + name.writable and desc.writable are different values (8.12.9 step + 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + writable: true +}); +verifyEqualTo(obj, "foo", undefined); + +verifyWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js new file mode 100644 index 0000000000..28de47218b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-104.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-104 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + name.enumerable and desc.enumerable are different values (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js new file mode 100644 index 0000000000..d1c51afdd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-105.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-105 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + name.configurable = true and desc.configurable = false (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 200, + enumerable: true, + writable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + configurable: false +}); + +verifyEqualTo(obj, "foo", 200); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js new file mode 100644 index 0000000000..9d726fe9c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-106.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-106 +description: > + Object.defineProperty - 'name' and 'desc' are data properties, + several attributes values of name and desc are different (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 100, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + value: 200, + writable: false, + enumerable: false +}); +verifyEqualTo(obj, "foo", 200); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js new file mode 100644 index 0000000000..949c297366 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-107.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-107 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + both desc.[[Get]] and name.[[Get]] are two different values + (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc, + configurable: true +}); + +function getFunc2() { + return 20; +} + +Object.defineProperty(obj, "foo", { + get: getFunc2 +}); +verifyEqualTo(obj, "foo", getFunc2()); + +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js new file mode 100644 index 0000000000..c9f5864973 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-108.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-108 +description: > + Object.defineProperty - 'name' and 'desc' are accessor + properties, name.[[Get]] is present and desc.[[Get]] is undefined + (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + set: setFunc, + get: undefined +}); +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js new file mode 100644 index 0000000000..8093ffd718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-109.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-109 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + name.[[Get]] is undefined and desc.[[Get]] is function (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc, + get: undefined, + enumerable: true, + configurable: true +}); + +function getFunc() { + return 10; +} + +Object.defineProperty(obj, "foo", { + get: getFunc +}); +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-11.js new file mode 100644 index 0000000000..e1eb427683 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-11.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 7b of [[DefineOwnProperty]] rejects if + current.[[Enumerable]] and desc.[[Enumerable]] are the boolean negations + of each other. +es5id: 15.2.3.6-4-11 +description: > + Object.defineProperty throws TypeError when changing + [[Enumerable]] from true to false on non-configurable accessor + properties +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter, + enumerable: true, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// now, setting enumerable to true should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + get: getter, + enumerable: false +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.enumerable, true, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js new file mode 100644 index 0000000000..c94fbc8af0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-110.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-110 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + both desc.[[Set]] and name.[[Set]] are two different values + (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc1() { + return 10; +} + +Object.defineProperty(obj, "foo", { + set: setFunc1, + enumerable: true, + configurable: true +}); + +function setFunc2(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc2 +}); +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-111.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-111.js new file mode 100644 index 0000000000..80b0489702 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-111.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-111 +description: > + Object.defineProperty - 'name' and 'desc' are accessor + properties, name.[[Set]] is present and desc.[[Set]] is undefined + (8.12.9 step 12) +---*/ + +var obj = {}; + +function getFunc() { + return 10; +} + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + set: undefined, + get: getFunc +}); + + +var desc = Object.getOwnPropertyDescriptor(obj, "foo"); + +assert(obj.hasOwnProperty("foo"), 'obj.hasOwnProperty("foo") !== true'); +assert.sameValue(typeof(desc.set), "undefined", 'typeof (desc.set)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js new file mode 100644 index 0000000000..4a80f6b084 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-112.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-112 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + name.[[Set]] is undefined and desc.[[Set]] is function (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +Object.defineProperty(obj, "foo", { + set: undefined, + get: getFunc, + enumerable: true, + configurable: true +}); + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc +}); +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js new file mode 100644 index 0000000000..48e4fa7f6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-113.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-113 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + name.enumerable and desc.enumerable are different values (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + get: getFunc, + enumerable: false +}); + +verifyEqualTo(obj, "foo", getFunc()); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js new file mode 100644 index 0000000000..a0a8bc367d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-114.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-114 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + name.configurable = true and desc.configurable = false (8.12.9 + step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +function getFunc() { + return 10; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + get: getFunc, + configurable: false +}); +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js new file mode 100644 index 0000000000..5481206420 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-115.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-115 +description: > + Object.defineProperty - 'name' and 'desc' are accessor properties, + several attributes values of 'name' and 'desc' are different + (8.12.9 step 12) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc1() { + return 10; +} + +function setFunc1() {} + +Object.defineProperty(obj, "foo", { + get: getFunc1, + set: setFunc1, + enumerable: true, + configurable: true +}); + +function getFunc2() { + return 20; +} + +function setFunc2(value) { + obj.setVerifyHelpProp = value; +} +Object.defineProperty(obj, "foo", { + get: getFunc2, + set: setFunc2, + enumerable: false +}); +verifyEqualTo(obj, "foo", getFunc2()); + +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-116.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-116.js new file mode 100644 index 0000000000..d3ef817243 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-116.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-116 +description: > + Object.defineProperty - 'O' is an Array, test the length property + of 'O' is own data property (15.4.5.1 step 1) +includes: [propertyHelper.js] +---*/ + +var arrObj = [0, 1]; +Object.defineProperty(arrObj, "1", { + value: 1, + configurable: false +}); + +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); + +verifyProperty(arrObj, "length", { + value: 2, + writable: true, + configurable: false, + enumerable: false, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-117.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-117.js new file mode 100644 index 0000000000..96989d3052 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-117.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-117 +description: > + Object.defineProperty - 'O' is an Array, test the length property + of 'O' is own data property that overrides an inherited data + property (15.4.5.1 step 1) +---*/ + +var arrObj = [0, 1, 2]; +var arrProtoLen; + +assert.throws(TypeError, function() { + arrProtoLen = Array.prototype.length; + Array.prototype.length = 0; + + + Object.defineProperty(arrObj, "2", { + configurable: false + }); + + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 3, 'arrObj.length'); +assert.sameValue(Array.prototype.length, 0, 'Array.prototype.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.js new file mode 100644 index 0000000000..47a6508761 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-118.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. + +/*--- +es5id: 15.2.3.6-4-118 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + every field in 'desc' is absent (15.4.5.1 step 3.a.i) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", {}); + +assert.sameValue(arrObj.length, 0); +arrObj.length = 2; +assert.sameValue(arrObj.length, 2); +verifyNotEnumerable(arrObj, "length"); +verifyNotConfigurable(arrObj, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.js new file mode 100644 index 0000000000..0c07b625e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-119.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. + +/*--- +es5id: 15.2.3.6-4-119 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + every field in 'desc' is same with corresponding attribute value + of the length property in 'O' (15.4.5.1 step 3.a.i) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; +Object.defineProperty(arrObj, "length", { + writable: true, + enumerable: false, + configurable: false +}); + +assert.sameValue(arrObj.length, 0); +arrObj.length = 2; +assert.sameValue(arrObj.length, 2); +verifyNotEnumerable(arrObj, "length"); +verifyNotConfigurable(arrObj, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-12.js new file mode 100644 index 0000000000..b823076eda --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-12.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 9a of + [[DefineOwnProperty]] rejects changing the kind of a property. +es5id: 15.2.3.6-4-12 +description: > + Object.defineProperty throws TypeError when changing + non-configurable data properties to accessor properties +---*/ + +var o = {}; + +// create a data valued property; all other attributes default to false. +var d1 = { + value: 101, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// changing "foo" to be an accessor should fail, since [[Configurable]] +// on the original property will be false. + +// dummy getter +var getter = function() { + return 1; +} + +var desc = { + get: getter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain a data valued property. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.writable, false, 'd2.writable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-120.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-120.js new file mode 100644 index 0000000000..b346edeaa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-120.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: 15.2.3.6-4-120 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + TypeError is thrown when updating the [[Configurable]] attribute + of the length property from false to true (15.4.5.1 step 3.a.i) +---*/ + +var arrObj = []; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-121.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-121.js new file mode 100644 index 0000000000..89ecc7b1d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-121.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: 15.2.3.6-4-121 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + TypeError is thrown when updating the [[Enumerable]] attribute of + the length property from false to true (15.4.5.1 step 3.a.i) +---*/ + +var arrObj = []; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + enumerable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-122.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-122.js new file mode 100644 index 0000000000..e8ee0f856f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-122.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. + +/*--- +es5id: 15.2.3.6-4-122 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test TypeError is thrown when 'desc' is accessor + descriptor (15.4.5.1 step 3.a.i) +---*/ + +var arrObj = []; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + get: function() { + return 2; + } + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-123.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-123.js new file mode 100644 index 0000000000..019be751a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-123.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. + +/*--- +es5id: 15.2.3.6-4-123 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + TypeError is thrown when updating the [[Writable]] attribute of + the length property from false to true (15.4.5.1 step 3.a.i) +---*/ + +var arrObj = []; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + writable: false + }); + Object.defineProperty(arrObj, "length", { + writable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.js new file mode 100644 index 0000000000..1dce4ea87c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-124.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. + +/*--- +es5id: 15.2.3.6-4-124 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is absent, test + updating the [[Writable]] attribute of the length property from + true to false (15.4.5.1 step 3.a.i) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + writable: false +}); +verifyEqualTo(arrObj, "length", 0); + +verifyNotWritable(arrObj, "length"); + +verifyNotEnumerable(arrObj, "length"); + +verifyNotConfigurable(arrObj, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-125.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-125.js new file mode 100644 index 0000000000..04afc2ed1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-125.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. + +/*--- +es5id: 15.2.3.6-4-125 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test that RangeError exception is thrown when + [[Value]] field of 'desc' is undefined (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: undefined + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-126.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-126.js new file mode 100644 index 0000000000..37e3e1fccd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-126.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: 15.2.3.6-4-126 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is null + (15.4.5.1 step 3.c) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: null +}); + +assert.sameValue(arrObj.length, 0, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-127.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-127.js new file mode 100644 index 0000000000..5fe718c75d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-127.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: 15.2.3.6-4-127 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is a boolean + with value false (15.4.5.1 step 3.c) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: false +}); + +assert.sameValue(arrObj.length, 0, 'arrObj.length'); +assert.sameValue(arrObj.hasOwnProperty("0"), false, 'arrObj.hasOwnProperty("0")'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-128.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-128.js new file mode 100644 index 0000000000..2a97e81a32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-128.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: 15.2.3.6-4-128 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is a boolean + with value true (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: true +}); + +assert.sameValue(arrObj.length, 1, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-129.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-129.js new file mode 100644 index 0000000000..d98863c616 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-129.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: 15.2.3.6-4-129 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is not thrown when the + [[Value]] field of 'desc' is 0 (15.4.5.1 step 3.c) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 0 +}); + +assert.sameValue(arrObj.length, 0, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-13.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-13.js new file mode 100644 index 0000000000..8be4d52236 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-13.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 9a of + [[DefineOwnProperty]] rejects changing the kind of a property. +es5id: 15.2.3.6-4-13 +description: > + Object.defineProperty throws TypeError when changing + non-configurable accessor properties to data properties +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. + +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// changing "foo" to be a data property should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + value: 101 +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain an accessor property. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-130.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-130.js new file mode 100644 index 0000000000..7591d9c343 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-130.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: 15.2.3.6-4-130 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is not thrown when the + [[Value]] field of 'desc' is +0 (15.4.5.1 step 3.c) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: +0 +}); + +assert.sameValue(arrObj.length, 0, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-131.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-131.js new file mode 100644 index 0000000000..7c81479205 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-131.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: 15.2.3.6-4-131 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is not thrown when the + [[Value]] field of 'desc' is -0 (15.4.5.1 step 3.c) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: -0 +}); + +assert.sameValue(arrObj.length, 0, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-132.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-132.js new file mode 100644 index 0000000000..517fda892f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-132.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: 15.2.3.6-4-132 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is not thrown when the + [[Value]] field of 'desc' is a positive number (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: 12 +}); + +assert.sameValue(arrObj.length, 12, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-133.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-133.js new file mode 100644 index 0000000000..047b6aaec3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-133.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. + +/*--- +es5id: 15.2.3.6-4-133 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a negative number (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: -9 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-134.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-134.js new file mode 100644 index 0000000000..c8a5ec719d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-134.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. + +/*--- +es5id: 15.2.3.6-4-134 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is +Infinity (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: +Infinity + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-135.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-135.js new file mode 100644 index 0000000000..52130077e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-135.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. + +/*--- +es5id: 15.2.3.6-4-135 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is -Infinity (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: -Infinity + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-136.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-136.js new file mode 100644 index 0000000000..e025c7bca1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-136.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. + +/*--- +es5id: 15.2.3.6-4-136 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is NaN (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: NaN + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-137.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-137.js new file mode 100644 index 0000000000..a0f59409bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-137.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. + +/*--- +es5id: 15.2.3.6-4-137 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is not thrown when the + [[Value]] field of 'desc' is a string containing a positive number + (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: "2" +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-138.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-138.js new file mode 100644 index 0000000000..4f7df20288 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-138.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: 15.2.3.6-4-138 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a string containing a negative number + (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: "-42" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-139.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-139.js new file mode 100644 index 0000000000..e3cbaca429 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-139.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: 15.2.3.6-4-139 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a string containing a decimal number + (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: "200.59" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-14.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-14.js new file mode 100644 index 0000000000..f84d14edad --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-14.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For configurable properties, step 9b of + [[DefineOwnProperty]] permits changing the kind of a property. +es5id: 15.2.3.6-4-14 +description: > + Object.defineProperty permits changing data property to accessor + property for configurable properties +---*/ + +var o = {}; + +// create a data property. In this case, +// [[Enumerable]] and [[Configurable]] are true +o["foo"] = 101; + +// changing "foo" to be an accessor should succeed, since [[Configurable]] +// on the original property will be true. Existing values of [[Configurable]] +// and [[Enumerable]] need to be preserved and the rest need to be set to +// their default values + +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter +}; +Object.defineProperty(o, "foo", d1); + +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.enumerable, true, 'd2.enumerable'); +assert.sameValue(d2.configurable, true, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-140.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-140.js new file mode 100644 index 0000000000..e17d87caaf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-140.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: 15.2.3.6-4-140 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a string containing +Infinity + (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: "+Infinity" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-141.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-141.js new file mode 100644 index 0000000000..aad7e6a6a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-141.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: 15.2.3.6-4-141 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a string containing -Infinity + (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: "-Infinity" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-142.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-142.js new file mode 100644 index 0000000000..de827ec701 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-142.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: 15.2.3.6-4-142 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is a string + containing an exponential number (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: "2E3" +}); + +assert.sameValue(arrObj.length, 2E3, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-143.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-143.js new file mode 100644 index 0000000000..289bfd819e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-143.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: 15.2.3.6-4-143 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is a string + containing a hex number (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: "0x00B" +}); + +assert.sameValue(arrObj.length, 0x00B, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-144.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-144.js new file mode 100644 index 0000000000..dcd4edafec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-144.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: 15.2.3.6-4-144 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is a string + containing a number with leading zeros (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: "0002.0" +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-145.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-145.js new file mode 100644 index 0000000000..b20705a9bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-145.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: 15.2.3.6-4-145 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError exception is thrown when the + [[Value]] field of 'desc' is a string which doesn't convert to a + number (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: "two" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-146.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-146.js new file mode 100644 index 0000000000..0ace2a69e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-146.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. + +/*--- +es5id: 15.2.3.6-4-146 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is an object + which has an own toString method (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: { + toString: function() { + return '2'; + } + } +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-147.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-147.js new file mode 100644 index 0000000000..6e7906bb72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-147.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. + +/*--- +es5id: 15.2.3.6-4-147 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is an Object + which has an own valueOf method (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: { + valueOf: function() { + return 2; + } + } +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-148.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-148.js new file mode 100644 index 0000000000..6b52e81756 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-148.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-148 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is an Object + which has an own valueOf method that returns an object and + toString method that returns a string (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +var toStringAccessed = false; +var valueOfAccessed = false; + +Object.defineProperty(arrObj, "length", { + value: { + toString: function() { + toStringAccessed = true; + return '2'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-149.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-149.js new file mode 100644 index 0000000000..9926f307f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-149.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-149 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is an Object + which has an own toString and valueOf method (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +var toStringAccessed = false; +var valueOfAccessed = false; + +Object.defineProperty(arrObj, "length", { + value: { + toString: function() { + toStringAccessed = true; + return '2'; + }, + + valueOf: function() { + valueOfAccessed = true; + return 3; + } + } +}); + +assert.sameValue(arrObj.length, 3, 'arrObj.length'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-15.js new file mode 100644 index 0000000000..a79cef36b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-15.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For configurable properties, step 9c of + [[DefineOwnProperty]] permits changing the kind of a property. +es5id: 15.2.3.6-4-15 +description: > + Object.defineProperty permits changing accessor property to data + property for configurable properties +---*/ + +var o = {}; + +// define an accessor property +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter, + configurable: true +}; +Object.defineProperty(o, "foo", d1); + +// changing "foo" to be a data valued property should succeed, since +// [[Configurable]] on the original property will be true. Existing +// values of [[Configurable]] and [[Enumerable]] need to be preserved +// and the rest need to be set to their default values. +var desc = { + value: 101 +}; +Object.defineProperty(o, "foo", desc); +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.writable, false, 'd2.writable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, true, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-150.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-150.js new file mode 100644 index 0000000000..644d864cc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-150.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-150 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test TypeError is thrown when the [[Value]] field + of 'desc' is an Object that both toString and valueOf wouldn't + return primitive value (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +var toStringAccessed = false; +var valueOfAccessed = false; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + value: { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } + }); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-151.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-151.js new file mode 100644 index 0000000000..fc0f440498 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-151.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-151 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', and the [[Value]] field of 'desc' is an Object + with an own toString method and an inherited valueOf method + (15.4.5.1 step 3.c), test that the inherited valueOf method is used +---*/ + +var arrObj = []; +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; + +var child = new ConstructFun(); +child.toString = function() { + toStringAccessed = true; + return 3; +}; + +Object.defineProperty(arrObj, "length", { + value: child +}); + +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-152.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-152.js new file mode 100644 index 0000000000..afe5f79092 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-152.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: 15.2.3.6-4-152 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError is thrown when the [[Value]] + field of 'desc' is a positive non-integer values (15.4.5.1 step + 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: 123.5 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-153.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-153.js new file mode 100644 index 0000000000..5482b5345a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-153.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: 15.2.3.6-4-153 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError is thrown when the [[Value]] + field of 'desc' is a negative non-integer values (15.4.5.1 step + 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: -4294967294.5 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-154.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-154.js new file mode 100644 index 0000000000..35466aea65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-154.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: 15.2.3.6-4-154 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is boundary + value 2^32 - 2 (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: 4294967294 +}); + +assert.sameValue(arrObj.length, 4294967294, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-155.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-155.js new file mode 100644 index 0000000000..4cc37d22d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-155.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: 15.2.3.6-4-155 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test the [[Value]] field of 'desc' is boundary + value 2^32 - 1 (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + value: 4294967295 +}); + +assert.sameValue(arrObj.length, 4294967295, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-156.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-156.js new file mode 100644 index 0000000000..2d9440ecd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-156.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. + +/*--- +es5id: 15.2.3.6-4-156 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError is thrown when the [[Value]] + field of 'desc' is boundary value 2^32 (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: 4294967296 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-157.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-157.js new file mode 100644 index 0000000000..fc1324bc48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-157.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. + +/*--- +es5id: 15.2.3.6-4-157 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', test RangeError is thrown when the [[Value]] + field of 'desc' is boundary value 2^32 + 1 (15.4.5.1 step 3.c) +---*/ + +var arrObj = []; +assert.throws(RangeError, function() { + Object.defineProperty(arrObj, "length", { + value: 4294967297 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-159.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-159.js new file mode 100644 index 0000000000..7e61a82e42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-159.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. + +/*--- +es5id: 15.2.3.6-4-159 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', set the [[Value]] field of 'desc' to a value + greater than the existing value of length (15.4.5.1 step 3.f) +---*/ + +var arrObj = [0, , 2]; + +Object.defineProperty(arrObj, "length", { + value: 5 +}); + +assert.sameValue(arrObj.length, 5, 'arrObj.length'); +assert.sameValue(arrObj[0], 0, 'arrObj[0]'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); +assert.sameValue(arrObj[2], 2, 'arrObj[2]'); +assert.sameValue(arrObj.hasOwnProperty("4"), false, 'arrObj.hasOwnProperty("4")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-16.js new file mode 100644 index 0000000000..a6bc962c84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-16.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 10.a.i + of [[DefineOwnProperty]] rejects if relaxing the [[Writable]] attribute. +es5id: 15.2.3.6-4-16 +description: > + Object.defineProperty throws TypeError when relaxing [[Writable]] + on non-configurable data properties +---*/ + +var o = {}; + +// create a data valued property; all other attributes default to false. +var d1 = { + value: 101 +}; +Object.defineProperty(o, "foo", d1); + +// now, relaxing [[Writable]] on "foo" should fail, since both +// [[Configurable]] and [[Writable]] on the original property will be false. +var desc = { + value: 101, + writable: true +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.writable, false, 'd2.writable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-160.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-160.js new file mode 100644 index 0000000000..6fd7dc5419 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-160.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. + +/*--- +es5id: 15.2.3.6-4-160 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', set the [[Value]] field of 'desc' to a value + equal to the existing value of length (15.4.5.1 step 3.f) +---*/ + +var arrObj = [0, , 2]; + +Object.defineProperty(arrObj, "length", { + value: 3 +}); + +assert.sameValue(arrObj.length, 3, 'arrObj.length'); +assert.sameValue(arrObj[0], 0, 'arrObj[0]'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); +assert.sameValue(arrObj[2], 2, 'arrObj[2]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-161.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-161.js new file mode 100644 index 0000000000..7dbf220d08 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-161.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: 15.2.3.6-4-161 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', set the [[Value]] field of 'desc' to a value + lesser than the existing value of length and test that indexes + beyond the new length are deleted(15.4.5.1 step 3.f) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 1 +}); + +assert.sameValue(arrObj.length, 1, 'arrObj.length'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-162.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-162.js new file mode 100644 index 0000000000..9f95f2a88c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-162.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. + +/*--- +es5id: 15.2.3.6-4-162 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is greater than + value of the length property, test TypeError is thrown when the + length property is not writable (15.4.5.1 step 3.f.i) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + writable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + value: 12 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-163.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-163.js new file mode 100644 index 0000000000..b11428d19a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-163.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. + +/*--- +es5id: 15.2.3.6-4-163 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' equals to value of + the length property, test no TypeError is thrown when the length + property is not writable (15.4.5.1 step 3.f.i) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "length", { + writable: false +}); + +Object.defineProperty(arrObj, "length", { + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-164.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-164.js new file mode 100644 index 0000000000..39c4562f65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-164.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. + +/*--- +es5id: 15.2.3.6-4-164 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test TypeError is thrown when the + [[Writable]] attribute of the length property is false (15.4.5.1 + step 3.g) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + writable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + value: 0 + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-165.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-165.js new file mode 100644 index 0000000000..ac1b8394c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-165.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. + +/*--- +es5id: 15.2.3.6-4-165 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Writable]] attribute of the + length property is set to true after deleting properties with + large index named if the [[Writable]] field of 'desc' is absent + (15.4.5.1 step 3.h) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 1 +}); + +var indexDeleted = !arrObj.hasOwnProperty("1"); + +arrObj.length = 10; + +assert(indexDeleted, 'indexDeleted !== true'); +assert.sameValue(arrObj.length, 10, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-166.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-166.js new file mode 100644 index 0000000000..7fcec19a4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-166.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-166 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Writable]] attribute of the + length property is set to true after deleting properties with + large index named if the [[Writable]] field of 'desc' is true + (15.4.5.1 step 3.h) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 1, + writable: true +}); + +var indexDeleted = !arrObj.hasOwnProperty("1"); + +arrObj.length = 10; + +assert(indexDeleted, 'indexDeleted !== true'); +assert.sameValue(arrObj.length, 10, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.js new file mode 100644 index 0000000000..8c51484bd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-167.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. + +/*--- +es5id: 15.2.3.6-4-167 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Writable]] attribute of the + length property is set to false after deleting properties with + large index named if the [[Writable]] field of 'desc' is false + (15.4.5.1 step 3.i.ii) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 1, + writable: false +}); + +assert(!arrObj.hasOwnProperty("1")) +assert.sameValue(arrObj.length, 1); +verifyNotWritable(arrObj, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-168.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-168.js new file mode 100644 index 0000000000..89f38d9721 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-168.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-168 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', whose writable attribute is being changed to + false and the [[Value]] field of 'desc' is less than value of the + length property and also lesser than an index of the array which + is set to configurable:false, test that new length is set to a + value greater than the non-deletable index by 1, writable + attribute of length is set to false and TypeError exception is + thrown (15.4.5.1 step 3.i.iii) +---*/ + +var arrObj = [0, 1, 2]; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + configurable: false + }); + + Object.defineProperty(arrObj, "length", { + value: 0, + writable: false + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-169.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-169.js new file mode 100644 index 0000000000..6c9cdc648b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-169.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. + +/*--- +es5id: 15.2.3.6-4-169 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property and also lesser than an index of the array + which is set to configurable: false, test that new length is set + to a value greater than the non-deletable index by 1, and + TypeError is thrown (15.4.5.1 step 3.l.i) +---*/ + +var arrObj = [0, 1, 2]; + +Object.defineProperty(arrObj, "1", { + configurable: false +}); + +Object.defineProperty(arrObj, "2", { + configurable: true +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert.sameValue(arrObj.hasOwnProperty("2"), false, 'arrObj.hasOwnProperty("2")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-17.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-17.js new file mode 100644 index 0000000000..28ba9fae71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-17.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 10.a.ii.1 + of [[DefineOwnProperty]] rejects changing the value of non-writable properties. +es5id: 15.2.3.6-4-17 +description: > + Object.defineProperty throws TypeError when changing value of + non-writable non-configurable data properties +---*/ + +var o = {}; + +// create a data valued property; all other attributes default to false. +var d1 = { + value: 101 +}; +Object.defineProperty(o, "foo", d1); + +// now, trying to change the value of "foo" should fail, since both +// [[Configurable]] and [[Writable]] on the original property will be false. +var desc = { + value: 102 +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.writable, false, 'd2.writable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-170.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-170.js new file mode 100644 index 0000000000..0dbe772bdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-170.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-170 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property and also lesser than an index of the array + which is set to configurable: false, test that new length is set + to a value greater than the non-deletable index by 1, writable + attribute of length is set to false and TypeError exception is + thrown (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + configurable: false + }); + + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-171.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-171.js new file mode 100644 index 0000000000..c6732ffecc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-171.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. + +/*--- +es5id: 15.2.3.6-4-171 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of an + inherited data property with large index named in 'O' can't stop + deleting index named properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +Array.prototype[1] = 2; // Not setting the [[Configurable]] attribute of property "1" to false here, since Array.prototype is a global object, and non-configurbale property can't revert to configurable +Object.defineProperty(arrObj, "length", { + value: 1 +}); + +assert.sameValue(arrObj.length, 1, 'arrObj.length'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-172.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-172.js new file mode 100644 index 0000000000..c26d21a80d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-172.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-172 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of + own data property with large index named in 'O' that overrides an + inherited data property can stop deleting index named properties + (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + configurable: false + }); + + Array.prototype[1] = 2; + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-173.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-173.js new file mode 100644 index 0000000000..4abc8e4730 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-173.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-173 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of + own data property with large index named in 'O' that overrides an + inherited accessor property can stop deleting index named + properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + configurable: false + }); + + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 2; + }, + configurable: true + }); + + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-174.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-174.js new file mode 100644 index 0000000000..168a30e73d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-174.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-174 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of + own accessor property with large index named in 'O' can stop + deleting index named properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + get: function() { + return 1; + }, + configurable: false + }); + + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-175.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-175.js new file mode 100644 index 0000000000..2be4dea4f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-175.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-175 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of an + inherited accessor property with large index named in 'O' can't + stop deleting index named properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 1; + }, + configurable: true // Not setting the [[Configurable]] attribute of property "1" to false here, since Array.prototype is a global object, and non-configurbale property can't revert to configurable +}); + +Object.defineProperty(arrObj, "length", { + value: 1 +}); + +assert.sameValue(arrObj.length, 1, 'arrObj.length'); +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-176.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-176.js new file mode 100644 index 0000000000..7463cbce32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-176.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-176 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of + own accessor property with large index named in 'O' that overrides + an inherited data property can stop deleting index named + properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + get: function() { + return 2; + }, + configurable: false + }); + + Array.prototype[1] = 2; + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-177.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-177.js new file mode 100644 index 0000000000..60bbee3532 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-177.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-177 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Configurable]] attribute of + own accessor property with large index named in 'O' that overrides + an inherited accessor property can stop deleting index named + properties (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "1", { + get: function() { + return 1; + }, + configurable: false + }); + + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 2; + }, + configurable: true + }); + + Object.defineProperty(arrObj, "length", { + value: 1 + }); +}); +assert.sameValue(arrObj.length, 2, 'arrObj.length'); +assert(arrObj.hasOwnProperty("1"), 'arrObj.hasOwnProperty("1") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-178.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-178.js new file mode 100644 index 0000000000..690b57fe2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-178.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. + +/*--- +es5id: 15.2.3.6-4-178 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the configurable large index named + property of 'O' is deleted (15.4.5.1 step 3.l.ii) +---*/ + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 1 +}); + +assert.sameValue(arrObj.hasOwnProperty("1"), false, 'arrObj.hasOwnProperty("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-179-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-179-1.js new file mode 100644 index 0000000000..5b6a6d6da9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-179-1.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. + +/*--- +es5id: 15.2.3.6-4-179-1 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is greater than + value of the length property, test value of the length property + is same as [[Value]] (15.4.5.1 step 3.l.iii.1) +---*/ + +var arrObj = [0, 1, 2, 3]; + +Object.defineProperty(arrObj, "1", { + configurable: false +}); + +Object.defineProperty(arrObj, "length", { + value: 3 +}); + +assert.sameValue(arrObj.length, 3, 'arrObj.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-18.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-18.js new file mode 100644 index 0000000000..bf8a2dc3ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-18.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 11.a.i + of [[DefineOwnProperty]] rejects changing the setter if present. +es5id: 15.2.3.6-4-18 +description: > + Object.defineProperty throws TypeError when changing setter of + non-configurable accessor properties(8.12.9 step 11.a.i) +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter +}; +Object.defineProperty(o, "foo", d1); + +// now, trying to change the setter should fail, since [[Configurable]] +// on the original property will be false. +var setter = function(x) {}; +var desc = { + set: setter +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js new file mode 100644 index 0000000000..26f0e3e3cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-181.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-181 +description: > + Object.defineProperty - 'O' is an Array, 'name' is the length + property of 'O', the [[Value]] field of 'desc' is less than value + of the length property, test the [[Writable]] attribute of the + length property is set to false at last when the [[Writable]] + field of 'desc' is false and 'O' doesn't contain non-configurable + large index named property (15.4.5.1 step 3.m) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [0, 1]; + +Object.defineProperty(arrObj, "length", { + value: 0, + writable: false +}); + +verifyNotWritable(arrObj, "length"); + +assert(!arrObj.hasOwnProperty("1")); +assert.sameValue(arrObj.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-182.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-182.js new file mode 100644 index 0000000000..bd662904ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-182.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: 15.2.3.6-4-182 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is available String values that convert to + numbers (15.4.5.1 step 4.a) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: 12 +}); + +assert.sameValue(arrObj[0], 12, 'arrObj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-183.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-183.js new file mode 100644 index 0000000000..0548d23453 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-183.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: 15.2.3.6-4-183 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is boundary value 2^32 - 2 (15.4.5.1 step + 4.a) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 4294967294, { + value: 100 +}); + +assert(arrObj.hasOwnProperty("4294967294"), 'arrObj.hasOwnProperty("4294967294") !== true'); +assert.sameValue(arrObj.length, 4294967295, 'arrObj.length'); +assert.sameValue(arrObj[4294967294], 100, 'arrObj[4294967294]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-184.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-184.js new file mode 100644 index 0000000000..d9ac8f433a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-184.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: 15.2.3.6-4-184 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is boundary value 2^32 - 1 (15.4.5.1 step + 4.a) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 4294967295, { + value: 100 +}); + +assert(arrObj.hasOwnProperty("4294967295"), 'arrObj.hasOwnProperty("4294967295") !== true'); +assert.sameValue(arrObj.length, 0, 'arrObj.length'); +assert.sameValue(arrObj[4294967295], 100, 'arrObj[4294967295]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-185.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-185.js new file mode 100644 index 0000000000..135d52b2d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-185.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. + +/*--- +es5id: 15.2.3.6-4-185 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is boundary value 2^32 (15.4.5.1 step 4.a) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 4294967296, { + value: 100 +}); + +assert(arrObj.hasOwnProperty("4294967296"), 'arrObj.hasOwnProperty("4294967296") !== true'); +assert.sameValue(arrObj.length, 0, 'arrObj.length'); +assert.sameValue(arrObj[4294967296], 100, 'arrObj[4294967296]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-186.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-186.js new file mode 100644 index 0000000000..24e3880dcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-186.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: 15.2.3.6-4-186 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is boundary value 2^32 + 1 (15.4.5.1 step + 4.a) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 4294967297, { + value: 100 +}); + +assert(arrObj.hasOwnProperty("4294967297"), 'arrObj.hasOwnProperty("4294967297") !== true'); +assert.sameValue(arrObj.length, 0, 'arrObj.length'); +assert.sameValue(arrObj[4294967297], 100, 'arrObj[4294967297]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-187.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-187.js new file mode 100644 index 0000000000..253d472e4a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-187.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. + +/*--- +es5id: 15.2.3.6-4-187 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test TypeError is not thrown if the [[Writable]] + attribute of the length property in 'O' is false and value of + 'name' is less than value of the length property (15.4.5.1 step + 4.b) +---*/ + +var arrObj = [1, 2, 3]; + +Object.defineProperty(arrObj, "length", { + writable: false +}); + +Object.defineProperty(arrObj, 1, { + value: "abc" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-188.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-188.js new file mode 100644 index 0000000000..ff82432f6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-188.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. + +/*--- +es5id: 15.2.3.6-4-188 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test TypeError is thrown if the [[Writable]] + attribute of the length property in 'O' is false and value of + 'name' equals to value of the length property (15.4.5.1 step 4.b) +---*/ + +var arrObj = [1, 2, 3]; + +Object.defineProperty(arrObj, "length", { + writable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, 3, { + value: "abc" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-189.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-189.js new file mode 100644 index 0000000000..566916b271 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-189.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. + +/*--- +es5id: 15.2.3.6-4-189 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test TypeError is thrown if the [[Writable]] + attribute of the length property in 'O' is false and value of + 'name' is greater than value of the length property (15.4.5.1 step + 4.b) +---*/ + +var arrObj = [1, 2, 3]; + +Object.defineProperty(arrObj, "length", { + writable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, 4, { + value: "abc" + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-19.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-19.js new file mode 100644 index 0000000000..276d8dc60c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-19.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 11.a.i + of [[DefineOwnProperty]] permits setting a setter (if absent). +es5id: 15.2.3.6-4-19 +description: > + Object.defineProperty permits setting a setter (if absent) of + non-configurable accessor properties(8.12.9 step 10.a.ii.1) +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy getter +var getter = function() { + return 1; +} +var d1 = { + get: getter +}; +Object.defineProperty(o, "foo", d1); + +// now, trying to set the setter should succeed even though [[Configurable]] +// on the original property will be false. +var desc = { + set: undefined +}; +Object.defineProperty(o, "foo", desc); + +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.set, undefined, 'd2.set'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js new file mode 100644 index 0000000000..e9f7f17e6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-190.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-190 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own data property, test TypeError is + thrown on updating the configurable attribute from false to true + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 0, { + value: "ownDataProperty", + configurable: false +}); + +try { + Object.defineProperty(arrObj, 0, { + configurable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", "ownDataProperty"); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-191.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-191.js new file mode 100644 index 0000000000..c2c3f7b45f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-191.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-191 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is an inherited data property, test that + defining own index named property is successful (15.4.5.1 step 4.c) +---*/ + +try { + Object.defineProperty(Array.prototype, "0", { + value: 11, + configurable: true + }); + + var arrObj = []; + + Object.defineProperty(arrObj, "0", { + configurable: false + }); + + if (!arrObj.hasOwnProperty("0")) { + throw new Test262Error("Expected arrObj.hasOwnProperty('0') === true, actually " + arrObj.hasOwnProperty("0")); + } + if (Array.prototype[0] !== 11) { + throw new Test262Error("Expected Array.prototype[0] === 11), actually " + Array.prototype[0]); + } + if (typeof arrObj[0] !== "undefined") { + throw new Test262Error("Expected typeof arrObj[0] === 'undefined'), actually " + typeof arrObj[0]); + } + +} finally { + delete Array.prototype[0]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-192.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-192.js new file mode 100644 index 0000000000..3914db9592 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-192.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-192 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own data property that overrides an + inherited data property, test TypeError is thrown on updating the + [[Configurable]] attribute from false to true (15.4.5.1 step 4.c) +---*/ + +var arrObj = []; + +assert.throws(TypeError, function() { + Object.defineProperty(Array.prototype, "0", { + value: 11, + configurable: true + }); + + Object.defineProperty(arrObj, "0", { + value: 12, + configurable: false + }); + + Object.defineProperty(arrObj, "0", { + configurable: true + }); +}); +assert.sameValue(Array.prototype[0], 11, 'Array.prototype[0]'); +assert.sameValue(arrObj[0], 12, 'arrObj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-193.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-193.js new file mode 100644 index 0000000000..d9c51ebd90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-193.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-193 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own data property that overrides an + inherited accessor property, test TypeError is thrown when update + the [[Configurable]] attribute to true and value of + [[Configurable]] attribute of original is false (15.4.5.1 step + 4.c) +---*/ + +var arrObj = []; + +assert.throws(TypeError, function() { + Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true + }); + + Object.defineProperty(arrObj, "0", { + value: 12, + configurable: false + }); + + Object.defineProperty(arrObj, "0", { + configurable: true + }); +}); +assert.sameValue(Array.prototype[0], 11, 'Array.prototype[0]'); +assert.sameValue(arrObj[0], 12, 'arrObj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js new file mode 100644 index 0000000000..c69f78bdbc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-194.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-194 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own accessor property, test TypeError is + thrown on updating the configurable attribute from false to true + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var getFunc = function() { + return 11; +}; + +Object.defineProperty(arrObj, "0", { + get: getFunc, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", getFunc()); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e.name); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js new file mode 100644 index 0000000000..56e50846b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-195.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-195 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is an inherited accessor property (15.4.5.1 + step 4.c) +includes: [propertyHelper.js] +---*/ + +function getFunc() { + return arrObj.helpVerifySet; +} + +function setFunc(value) { + arrObj.helpVerifySet = value; +} + +try { + Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true + }); + + var arrObj = []; + + + Object.defineProperty(arrObj, "0", { + get: getFunc, + set: setFunc, + configurable: false + }); + + arrObj[0] = 13; + + verifyEqualTo(arrObj, "0", getFunc()); + + verifyWritable(arrObj, "0", "helpVerifySet"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); +} finally { + delete Array.prototype[0]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-196.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-196.js new file mode 100644 index 0000000000..2c494aae84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-196.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-196 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own accessor property that overrides an + inherited data property (15.4.5.1 step 4.c) +---*/ + + +assert.throws(TypeError, function() { + Object.defineProperty(Array.prototype, "0", { + value: 11, + configurable: true + }); + + var arrObj = []; + Object.defineProperty(arrObj, "0", { + get: function() {}, + configurable: false + }); + + Object.defineProperty(arrObj, "0", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-197.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-197.js new file mode 100644 index 0000000000..c9e2feaf5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-197.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-197 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is own accessor property that overrides an + inherited accessor property (15.4.5.1 step 4.c) +---*/ + + +assert.throws(TypeError, function() { + Object.defineProperty(Array.prototype, "0", { + get: function() {}, + configurable: true + }); + + var arrObj = []; + Object.defineProperty(arrObj, "0", { + get: function() {}, + configurable: false + }); + + Object.defineProperty(arrObj, "0", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-198.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-198.js new file mode 100644 index 0000000000..526ebadfdf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-198.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: 15.2.3.6-4-198 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O', test + TypeError is thrown when 'O' is not extensible (15.4.5.1 step 4.c) +---*/ + +var arrObj = []; +Object.preventExtensions(arrObj); +assert.throws(TypeError, function() { + var desc = { + value: 1 + }; + Object.defineProperty(arrObj, "0", desc); +}); +assert.sameValue(arrObj.hasOwnProperty("0"), false, 'arrObj.hasOwnProperty("0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.js new file mode 100644 index 0000000000..98cefd1ded --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-199.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. + +/*--- +es5id: 15.2.3.6-4-199 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O', test 'name' + is defined as data property when 'desc' is generic descriptor + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + enumerable: true +}); + +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-2.js new file mode 100644 index 0000000000..115e9bdda5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-2.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For newly defined data properties, attributes + missing from desc should have values set to the defaults from 8.6.1. +es5id: 15.2.3.6-4-2 +description: > + Object.defineProperty sets missing attributes to their default + values (data properties)(8.12.9 step 4.a.i) +---*/ + +var o = {}; + +var desc = { + value: 1 +}; +Object.defineProperty(o, "foo", desc); + +var propDesc = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(propDesc.value, 1, 'propDesc.value'); // this is the value that was set +assert.sameValue(propDesc.writable, false, 'propDesc.writable'); // false by default +assert.sameValue(propDesc.enumerable, false, 'propDesc.enumerable'); // false by default +assert.sameValue(propDesc.configurable, false, 'propDesc.configurable'); // false by default + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-20.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-20.js new file mode 100644 index 0000000000..7814434368 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-20.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 11.a.ii + of [[DefineOwnProperty]] rejects changing the getter if present. +es5id: 15.2.3.6-4-20 +description: > + Object.defineProperty throws TypeError when changing getter (if + present) of non-configurable accessor properties(8.12.9 step + 11.a.ii) +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy getter/setter +var getter = function() { + return 1; +} +var d1 = { + get: getter, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// now, trying to change the setter should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + get: undefined +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js new file mode 100644 index 0000000000..2c0632c716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-200.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-200 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O', test + [[Value]] of 'name' property of 'Attributes' is set as undefined + if [[Value]] is absent in data descriptor 'desc' (15.4.5.1 step + 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + writable: true, + enumerable: true, + configurable: false +}); + +verifyEqualTo(arrObj, "0", undefined); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js new file mode 100644 index 0000000000..ab771a71c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-201.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-201 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and + [[Writable]] is absent in data descriptor 'desc', test + [[Writable]] attribute of property 'name' is set to false + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: 1001, + enumerable: true, + configurable: false +}); +verifyEqualTo(arrObj, "0", 1001); + +verifyNotWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js new file mode 100644 index 0000000000..f6fe819199 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-202.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-202 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and + [[Enumerable]] is absent in data descriptor 'desc', test + [[Enumerable]] of property 'name' is set to false (15.4.5.1 step + 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: 1001, + writable: true, + configurable: true +}); +verifyEqualTo(arrObj, "0", 1001); + +verifyWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js new file mode 100644 index 0000000000..9e6cad35fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-203.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-203 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and + [[Configurable]] is absent in data descriptor 'desc', test + [[Configurable]] of property 'name' is set to false (15.4.5.1 step + 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: 1001, + writable: true, + enumerable: true +}); +verifyEqualTo(arrObj, "0", 1001); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js new file mode 100644 index 0000000000..b513a1dbb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-204.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-204 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'desc' is data descriptor, test updating all + attribute values of 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = [1]; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(arrObj, "0", { + value: 1001, + writable: false, + enumerable: false, + configurable: false +}); + +verifyEqualTo(arrObj, "0", 1001); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js new file mode 100644 index 0000000000..72e179ef74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-205.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-205 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and [[Get]] + is absent in accessor descriptor 'desc', test [[Get]] attribute of + property 'name' is set to undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var setFunc = function(value) { + arrObj.setVerifyHelpProp = value; +}; + +Object.defineProperty(arrObj, "0", { + set: setFunc, + enumerable: true, + configurable: true +}); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-206.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-206.js new file mode 100644 index 0000000000..124b0f9a43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-206.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. + +/*--- +es5id: 15.2.3.6-4-206 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O', test [[Set]] + of 'name' property in 'Attributes' is set as undefined if [[Set]] + is absent in accessor descriptor 'desc' (15.4.5.1 step 4.c) +---*/ + +var arrObj = []; +var getFunc = function() {}; + +Object.defineProperty(arrObj, "0", { + get: getFunc, + enumerable: true, + configurable: true +}); + +var desc = Object.getOwnPropertyDescriptor(arrObj, "0"); + +assert(arrObj.hasOwnProperty("0"), 'arrObj.hasOwnProperty("0") !== true'); +assert(desc.hasOwnProperty("set"), 'desc.hasOwnProperty("set") !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js new file mode 100644 index 0000000000..966b1744bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-207.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-207 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and + [[Enumerable]] is absent in accessor descriptor 'desc', test + [[Enumerable]] attribute of property 'name' is set to false + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +var setFunc = function(value) { + arrObj.setVerifyHelpProp = value; +}; +var getFunc = function() {}; + +Object.defineProperty(arrObj, "0", { + set: setFunc, + get: getFunc, + configurable: true +}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js new file mode 100644 index 0000000000..ba15c84b8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-208.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-208 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' property doesn't exist in 'O' and + [[Configurable]] is absent in accessor descriptor 'desc', test + [[Configurable]] attribute of property 'name' is set to false + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var setFunc = function(value) { + arrObj.setVerifyHelpProp = value; +}; +var getFunc = function() {}; + +Object.defineProperty(arrObj, "0", { + set: setFunc, + get: getFunc, + enumerable: true +}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js new file mode 100644 index 0000000000..cdefdc539e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-209.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-209 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'desc' is accessor descriptor, test updating all + attribute values of 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var setFunc = function(value) { + arrObj.setVerifyHelpProp = value; +}; +var getFunc = function() { + return 14; +}; + +Object.defineProperty(arrObj, "0", { + get: function() { + return 11; + }, + set: function() {}, + configurable: true, + enumerable: true +}); + +Object.defineProperty(arrObj, "0", { + get: getFunc, + set: setFunc, + configurable: false, + enumerable: false +}); + +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-21.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-21.js new file mode 100644 index 0000000000..1ffe487dd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-21.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For non-configurable properties, step 11.a.ii + of [[DefineOwnProperty]] permits setting a getter if absent. +es5id: 15.2.3.6-4-21 +description: > + Object.defineProperty permits setting a getter (if absent) of + non-configurable accessor properties(8.12.9 step 11.a.ii) +---*/ + +var o = {}; + +// create an accessor property; all other attributes default to false. +// dummy setter +var setter = function(x) {} +var d1 = { + set: setter +}; +Object.defineProperty(o, "foo", d1); + +// now, trying to set the getter should succeed even though [[Configurable]] +// on the original property will be false. Existing values of need to be preserved. +var getter = undefined; +var desc = { + get: getter +}; + +Object.defineProperty(o, "foo", desc); +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(d2.get, getter, 'd2.get'); +assert.sameValue(d2.set, setter, 'd2.set'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.js new file mode 100644 index 0000000000..3d5614db18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-210.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. + +/*--- +es5id: 15.2.3.6-4-210 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' makes no change if every field in 'desc' is + absent (name is data property) (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +arrObj[0] = 101; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(arrObj, "0", {}); +verifyEqualTo(arrObj, "0", 101); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js new file mode 100644 index 0000000000..74773a8b8c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-211.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-211 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' makes no change if every field in 'desc' is + absent(name is accessor property) (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function getFunc() { + return 11; +} + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(arrObj, "0", {}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js new file mode 100644 index 0000000000..60a73af96b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-212.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-212 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' makes no change if the value of every field + in 'desc' is the same value as the corresponding field in + 'name'(desc is data property) (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +arrObj[0] = 100; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(arrObj, "0", { + value: 100, + writable: true, + enumerable: true, + configurable: true +}); + +verifyEqualTo(arrObj, "0", 100); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js new file mode 100644 index 0000000000..aba7e1fb85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-213.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-213 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' makes no change if the value of every field + in 'desc' is the same value as the corresponding field in + 'name'(desc is accessor property) (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var getFunc = function() { + return "100"; +}; +var setFunc = function(value) { + arrObj.setVerifyHelpProp = value; +}; + +var desc = { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}; + +Object.defineProperty(arrObj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(arrObj, "0", desc); + +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js new file mode 100644 index 0000000000..a68119a095 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-214.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-214 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property and its configurable and writable attributes are set to + false, test TypeError is thrown when the type of the [[Value]] + field of 'desc' is different from the type of the [[Value]] + attribute value of 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 0, { + value: 101, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "0", { + value: "abc" + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", 101); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js new file mode 100644 index 0000000000..f6fccd3a61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-215.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-215 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, both the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: undefined +}); + +Object.defineProperty(arrObj, "0", { + value: undefined +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js new file mode 100644 index 0000000000..ac7099d2bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-216.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-216 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, both the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are null (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: null +}); + +Object.defineProperty(arrObj, "0", { + value: null +}); +verifyEqualTo(arrObj, "0", null); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js new file mode 100644 index 0000000000..3b9df95a20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-217.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-217 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, both the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are NaN (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: NaN +}); + +Object.defineProperty(arrObj, "0", { + value: NaN +}); + +assert(arrObj.hasOwnProperty("0")); +assert(arrObj[0] !== arrObj[0]); + +verifyNotWritable(arrObj, "0"); +verifyNotEnumerable(arrObj, "0"); +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js new file mode 100644 index 0000000000..f9e2e8c567 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-218.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-218 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' is +0, and the [[Value]] attribute value of 'name' is -0 + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: -0 +}); + +try { + Object.defineProperty(arrObj, "0", { + value: +0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", -0); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js new file mode 100644 index 0000000000..627a70f3ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-219.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-219 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' is -0, and the [[Value]] attribute value of 'name' is +0 + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: +0 +}); + +try { + Object.defineProperty(arrObj, "0", { + value: -0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", +0); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-22.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-22.js new file mode 100644 index 0000000000..b43c7308e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-22.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. + +/*--- +es5id: 15.2.3.6-4-22 +description: > + Object.defineProperty - 'name' is existing own data property + (8.12.9 step 1) +---*/ + +var obj = {}; +Object.defineProperty(obj, "foo", { + value: 11, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + value: 12, + configurable: true + }); +}); +assert.sameValue(obj.foo, 11, 'obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js new file mode 100644 index 0000000000..1e3d4a2d4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-220.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-220 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are two numbers with same vaule + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: 101 +}); + +Object.defineProperty(arrObj, "0", { + value: 101 +}); +verifyEqualTo(arrObj, "0", 101); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js new file mode 100644 index 0000000000..00732ff7be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-221.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-221 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' and the [[Value]] attribute value of 'name' are two numbers + with different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 0, { + value: 101, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "0", { + value: 123 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", 101); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js new file mode 100644 index 0000000000..88d73c0af9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-222.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-222 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are two strings which have same length + and same characters in corresponding positions (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: "abcd" +}); + +Object.defineProperty(arrObj, "0", { + value: "abcd" +}); +verifyEqualTo(arrObj, "0", "abcd"); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js new file mode 100644 index 0000000000..7177f6a39a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-223.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-223 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' and the [[Value]] attribute value of 'name' are two strings + with different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 0, { + value: "abcd", + writable: false, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "0", { + value: "fghj" + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", "abcd"); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js new file mode 100644 index 0000000000..91cac8ffdc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-224.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-224 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are two booleans with same value + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + value: true +}); + +Object.defineProperty(arrObj, "0", { + value: true +}); +verifyEqualTo(arrObj, "0", true); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js new file mode 100644 index 0000000000..28d8f74f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-225.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-225 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' and the [[Value]] attribute value of 'name' are two + booleans with different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, 0, { + value: true, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "0", { + value: false + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", true); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js new file mode 100644 index 0000000000..d766b26449 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-226.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-226 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Value]] field of 'desc' and the [[Value]] + attribute value of 'name' are two objects which refer to the same + object (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +var obj1 = { + length: 10 +}; + +Object.defineProperty(arrObj, "0", { + value: obj1 +}); + +Object.defineProperty(arrObj, "0", { + value: obj1 +}); +verifyEqualTo(arrObj, "0", obj1); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js new file mode 100644 index 0000000000..1834373563 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-227.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-227 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, test TypeError is thrown when the [[Value]] field of + 'desc' and the [[Value]] attribute value of 'name' are two objects + which refer to two different objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +var obj1 = { + length: 10 +}; +Object.defineProperty(arrObj, 0, { + value: obj1, + writable: false, + configurable: false +}); + +var obj2 = { + length: 20 +}; + +try { + Object.defineProperty(arrObj, "0", { + value: obj2 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "0", obj1); + + verifyNotWritable(arrObj, "0"); + + verifyNotEnumerable(arrObj, "0"); + + verifyNotConfigurable(arrObj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js new file mode 100644 index 0000000000..9316e59db2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-228.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-228 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Writable]] field of 'desc' and the [[Writable]] + attribute value of 'name' are two booleans with same value + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + writable: false +}); + +Object.defineProperty(arrObj, "0", { + writable: false +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.js new file mode 100644 index 0000000000..e1dead5a60 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-229.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. + +/*--- +es5id: 15.2.3.6-4-229 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Writable]] field of 'desc' and the [[Writable]] + attribute value of 'name' are two booleans with different values + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + writable: false, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + writable: true +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-23.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-23.js new file mode 100644 index 0000000000..c4d0277445 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-23.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. + +/*--- +es5id: 15.2.3.6-4-23 +description: > + Object.defineProperty - 'name' is existing an inherited data + property (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + value: 11, + configurable: false +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); + +Object.defineProperty(obj, "foo", { + configurable: true +}); + +assert(obj.hasOwnProperty("foo"), 'obj.hasOwnProperty("foo") !== true'); +assert.sameValue(typeof obj.foo, "undefined", 'typeof obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js new file mode 100644 index 0000000000..61d0187d81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-230.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-230 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Get]] field of 'desc' and the [[Get]] attribute + value of 'name' are two objects which refer to the same object + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +arrObj.helpVerifySet = 10; + +function getFunc() { + return arrObj.helpVerifySet; +} + +function setFunc(value) { + arrObj.helpVerifySet = value; +} + +Object.defineProperty(arrObj, "0", { + get: getFunc, + set: setFunc +}); + +Object.defineProperty(arrObj, "0", { + get: getFunc +}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyWritable(arrObj, "0", "helpVerifySet"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js new file mode 100644 index 0000000000..40199bd209 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-231.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-231 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Get]] field of 'desc' and the [[Get]] attribute + value of 'name' are two objects which refer to the different + objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +arrObj.helpVerifySet = 10; + +function getFunc1() { + return 20; +} + +function getFunc2() { + return arrObj.helpVerifySet; +} + +function setFunc(value) { + arrObj.helpVerifySet = value; +} + +Object.defineProperty(arrObj, "0", { + get: getFunc1, + set: setFunc, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + get: getFunc2 +}); + +verifyEqualTo(arrObj, "0", getFunc2()); + +verifyWritable(arrObj, "0", "helpVerifySet"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js new file mode 100644 index 0000000000..d22adbe6f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-232.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-232 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Set]] field of 'desc' and the [[Set]] attribute + value of 'name' are two objects which refer to the same object + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + set: setFunc +}); + +Object.defineProperty(arrObj, "0", { + set: setFunc +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js new file mode 100644 index 0000000000..bd2f68977e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-233.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-233 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Set]] field of 'desc' and the [[Set]] attribute + value of 'name' are two objects which refer to the different + objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function setFunc1() {} + +Object.defineProperty(arrObj, "0", { + set: setFunc1, + configurable: true +}); + +function setFunc2(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + set: setFunc2 +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js new file mode 100644 index 0000000000..b67690ecd5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-234.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-234 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Enumerable]] field of 'desc' and the + [[Enumerable]] attribute value of 'name' are two booleans with + same value (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + enumerable: false +}); + +Object.defineProperty(arrObj, "0", { + enumerable: false +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.js new file mode 100644 index 0000000000..d10baaf8d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-235.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. + +/*--- +es5id: 15.2.3.6-4-235 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Enumerable]] field of 'desc' and the + [[Enumerable]] attribute value of 'name' are two booleans with + different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + enumerable: false, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + enumerable: true +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js new file mode 100644 index 0000000000..b7df65b72a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-236.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-236 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Configurable]] field of 'desc' and the + [[Configurable]] attribute value of 'name' are two booleans with + same value (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + configurable: false +}); + +Object.defineProperty(arrObj, "0", { + configurable: false +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js new file mode 100644 index 0000000000..59d2e8c84e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-237.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-237 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + property, the [[Configurable]] field of 'desc' and the + [[Configurable]] attribute value of 'name' are two booleans with + different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + configurable: false +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js new file mode 100644 index 0000000000..9708bd0766 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-238.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-238 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, TypeError is thrown if the [[Configurable]] + attribute value of 'name' is false and the [[Configurable]] field + of 'desc' is true (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: 3, + writable: true, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "1", { + value: 13, + writable: true, + configurable: true + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyEqualTo(arrObj, "1", 3); + + verifyWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js new file mode 100644 index 0000000000..16a8aa0b1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-239.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-239 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, TypeError is thrown if the [[Configurable]] + attribute value of 'name' is false, and [[Enumerable]] of 'desc' + is present and its value is different from the [[Enumerable]] + attribute value of 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: 3, + writable: true, + configurable: false, + enumerable: false +}); + +try { + Object.defineProperty(arrObj, "1", { + value: 13, + writable: true, + enumerable: true + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyEqualTo(arrObj, "1", 3); + + verifyWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-24.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-24.js new file mode 100644 index 0000000000..0254703005 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-24.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-24 +description: > + Object.defineProperty - 'name' is own data property that overrides + an inherited data property (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + value: 12, + configurable: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); +Object.defineProperty(obj, "foo", { + value: 11, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); +assert.sameValue(obj.foo, 11, 'obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js new file mode 100644 index 0000000000..e74b2479d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-240.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-240 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, TypeError is thrown if 'name' is accessor + property, and 'desc' is data descriptor, and the [[Configurable]] + attribute value of 'name' is false (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "1", { + set: setFunc, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "1", { + value: 13 + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyWritable(arrObj, "1", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js new file mode 100644 index 0000000000..8923abc966 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-241.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-241 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, TypeError is thrown if 'name' is data property, + and'desc' is accessor descriptor, and the [[Configurable]] + attribute value of 'name' is false (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: 3, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "1", { + set: function() {} + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyEqualTo(arrObj, "1", 3); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js new file mode 100644 index 0000000000..7c21f48ca5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242-1.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-242-1 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + true, test 'name' is updated successfully (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [3]; + +Object.defineProperty(arrObj, "0", { + value: 1001, + writable: false, + enumerable: false +}); + +verifyEqualTo(arrObj, "0", 1001); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js new file mode 100644 index 0000000000..5f1d4a8dce --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-242.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-242 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + true, test 'name' is converted from data property to accessor + property (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [3]; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "0", { + set: setFunc +}); + +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js new file mode 100644 index 0000000000..a87d6172ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-1.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-243-1 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and assignment to + the accessor property, fails to convert accessor property from + accessor property to data property (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + + +var arrObj = []; + +function getFunc() { + return 3; +} +Object.defineProperty(arrObj, "1", { + get: getFunc, + configurable: true +}); + +arrObj[1] = 4; + +verifyEqualTo(arrObj, "1", getFunc()); + +verifyNotEnumerable(arrObj, "1"); + +verifyConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js new file mode 100644 index 0000000000..ef5649662c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243-2-strict.js @@ -0,0 +1,36 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-243-2 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and assignment to + the accessor property, fails to convert accessor property from + accessor property to data property (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + + +var arrObj = []; + +function getFunc() { + return 3; +} +Object.defineProperty(arrObj, "1", { + get: getFunc, + configurable: true +}); + +assert.throws(TypeError, function() { + arrObj[1] = 4; +}); +verifyEqualTo(arrObj, "1", getFunc()); + +verifyNotEnumerable(arrObj, "1"); + +verifyConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js new file mode 100644 index 0000000000..08a11f8705 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-243.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-243 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + true, test 'name' is converted from accessor property to data + property (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 3; +} +Object.defineProperty(arrObj, "1", { + get: getFunc, + configurable: true +}); + +Object.defineProperty(arrObj, "1", { + value: 12 +}); + +verifyEqualTo(arrObj, "1", 12); + +verifyNotWritable(arrObj, "1"); + +verifyNotEnumerable(arrObj, "1"); + +verifyConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js new file mode 100644 index 0000000000..e5e1d30c7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-244.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-244 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false and the [[Writable]] field of 'desc' is + true (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + writable: false, + configurable: false +}); + +try { + + Object.defineProperty(arrObj, "1", { + writable: true + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyEqualTo(arrObj, "1", undefined); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js new file mode 100644 index 0000000000..eae22cfee2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-245.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-245 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the type of the [[Value]] field of + 'desc' is different from the type of the [[Value]] attribute value + of 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: 3, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(arrObj, "1", { + value: "abc" + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", 3); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js new file mode 100644 index 0000000000..dddbc50767 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-246.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-246 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' is +0, + and the [[Value]] attribute value of 'name' is -0 (15.4.5.1 step + 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: -0 + +}); + +try { + Object.defineProperty(arrObj, "1", { + value: +0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", -0); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js new file mode 100644 index 0000000000..1a3085a231 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-247.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-247 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' is -0, + and the [[Value]] attribute value of 'name' is +0 (15.4.5.1 step + 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: +0 +}); + +try { + + Object.defineProperty(arrObj, "1", { + value: -0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", +0); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js new file mode 100644 index 0000000000..b946c44ae1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-248.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-248 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' and + the [[Value]] attribute value of 'name' are two numbers with + different vaules (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: 12 +}); + +try { + Object.defineProperty(arrObj, "1", { + value: 15 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", 12); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js new file mode 100644 index 0000000000..9a7132c20f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-249.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-249 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' and + the [[Value]] attribute value of 'name' are two strings with + different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: "abc" +}); + +try { + Object.defineProperty(arrObj, "1", { + value: "fgh" + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", "abc"); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-25.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-25.js new file mode 100644 index 0000000000..dd8be9d5af --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-25.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-25 +description: > + Object.defineProperty - 'data' is own data property that overrides + an inherited accessor property (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + get: function() {}, + configurable: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); +Object.defineProperty(obj, "foo", { + value: 11, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); +assert.sameValue(obj.foo, 11, 'obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js new file mode 100644 index 0000000000..e4710d7ef8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-250.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-250 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' and + the [[Value]] attribute value of 'name' are two booleans with + different values (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + value: false +}); + +try { + Object.defineProperty(arrObj, "1", { + value: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", false); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js new file mode 100644 index 0000000000..594cb3a3ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-251 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is data property and 'desc' is data + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Writable]] attribute + value of 'name' is false, and the [[Value]] field of 'desc' and + the [[Value]] attribute value of 'name' are two objects which + refer to the different objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; +var obj = { + length: 10 +}; + +Object.defineProperty(arrObj, "1", { + value: obj +}); + +try { + Object.defineProperty(arrObj, "1", { + value: {} + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", obj); + + verifyNotWritable(arrObj, "1"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js new file mode 100644 index 0000000000..ab56258dc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-252.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-252 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Set]] field of 'desc' is + present, and the [[Set]] field of 'desc' and the [[Set]] attribute + value of 'name' are two objects which refer to the different + objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "1", { + set: setFunc +}); + +try { + Object.defineProperty(arrObj, "1", { + set: function() {} + }); + throw new Test262Error("Expected an exception."); + +} catch (e) { + verifyWritable(arrObj, "1", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js new file mode 100644 index 0000000000..a6fbb2221c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-253.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-253 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Set]] field of 'desc' is + present, and the [[Set]] field of 'desc' is an object and the + [[Set]] attribute value of 'name' is undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function getFunc() { + return 12; +} + +Object.defineProperty(arrObj, "1", { + get: getFunc, + set: undefined +}); + +try { + Object.defineProperty(arrObj, "1", { + set: function() {} + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "1", getFunc()); + + verifyNotEnumerable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js new file mode 100644 index 0000000000..857f5bd3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-254.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-254 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is not thrown if the [[Set]] field of 'desc' + is present, and the [[Set]] field of 'desc' and the [[Set]] + attribute value of 'name' are undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "1", { + set: undefined +}); +assert(arrObj.hasOwnProperty("1")); + +Object.defineProperty(arrObj, "1", { + set: undefined +}); + +var desc = Object.getOwnPropertyDescriptor(arrObj, "1"); + +assert(desc.hasOwnProperty("get") && typeof desc.get === "undefined"); +assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); + +verifyNotEnumerable(arrObj, "1"); +verifyNotConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js new file mode 100644 index 0000000000..03e3d8a268 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-255.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-255 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Get]] field of 'desc' is + present, and the [[Get]] field of 'desc' and the [[Get]] attribute + value of 'name' are two objects which refer to the different + objects (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function getFunc() { + return 12; +} +Object.defineProperty(arrObj, "1", { + get: getFunc +}); + +try { + Object.defineProperty(arrObj, "1", { + get: function() { + return 14; + } + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + assert(arrObj.hasOwnProperty("1")); + + var desc = Object.getOwnPropertyDescriptor(arrObj, "1"); + + assert(arrObj[1] === getFunc()); + + assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); + + verifyNotEnumerable(arrObj, "1"); + verifyNotConfigurable(arrObj, "1"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js new file mode 100644 index 0000000000..a015f2a9a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-256.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-256 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is thrown if the [[Get]] field of 'desc' is + present, and the [[Get]] field of 'desc' is an object and the + [[Get]] attribute value of 'name' is undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function getFunc() { + return 12; +} + +Object.defineProperty(arrObj, "1", { + get: getFunc +}); + +try { + Object.defineProperty(arrObj, "1", { + get: undefined + }); + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + assert(arrObj.hasOwnProperty("1")); + + var desc = Object.getOwnPropertyDescriptor(arrObj, "1"); + + assert(arrObj[1] === getFunc()); + assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); + + verifyNotWritable(arrObj, "1"); + + verifyNotConfigurable(arrObj, "1"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js new file mode 100644 index 0000000000..e6e8c2d369 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-257.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-257 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, 'name' is accessor property and 'desc' is accessor + descriptor, and the [[Configurable]] attribute value of 'name' is + false, test TypeError is not thrown if the [[Get]] field of 'desc' + is present, and the [[Get]] field of 'desc' and the [[Get]] + attribute value of 'name' are undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "1", { + get: undefined, + set: setFunc, + configurable: false +}); + +Object.defineProperty(arrObj, "1", { + get: undefined +}); + +verifyWritable(arrObj, "1", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "1"); + +verifyNotConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.js new file mode 100644 index 0000000000..9821d646bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-258.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. + +/*--- +es5id: 15.2.3.6-4-258 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test updating the [[Value]] attribute value of 'name' + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; + +Object.defineProperty(arrObj, "0", { + value: 200 +}); +verifyEqualTo(arrObj, "0", 200); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.js new file mode 100644 index 0000000000..b0fbd5e780 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-259.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. + +/*--- +es5id: 15.2.3.6-4-259 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test setting the [[Value]] attribute value of 'name' + as undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; + +Object.defineProperty(arrObj, "0", { + value: undefined +}); +verifyEqualTo(arrObj, "0", undefined); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-26.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-26.js new file mode 100644 index 0000000000..5f6f340564 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-26.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-26 +description: > + Object.defineProperty - 'name' is own accessor property (8.12.9 + step 1) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: function() { + return 11; + }, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "property", { + get: function() { + return 12; + }, + configurable: true + }); +}); +assert.sameValue(obj.property, 11, 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.js new file mode 100644 index 0000000000..5e2b69c160 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-260.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. + +/*--- +es5id: 15.2.3.6-4-260 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test setting the [[Value]] attribute value of 'name' + from undefined to number (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [undefined]; +Object.defineProperty(arrObj, "0", { + value: 100 +}); +verifyEqualTo(arrObj, "0", 100); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.js new file mode 100644 index 0000000000..e945f54eeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-261.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. + +/*--- +es5id: 15.2.3.6-4-261 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test updating the [[Writable]] attribute value of + 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; +Object.defineProperty(arrObj, "0", { + writable: false +}); +verifyEqualTo(arrObj, "0", 100); + +verifyNotWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.js new file mode 100644 index 0000000000..aed61cb5ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-262.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. + +/*--- +es5id: 15.2.3.6-4-262 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test updating the [[Enumerable]] attribute value of + 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; + +Object.defineProperty(arrObj, "0", { + enumerable: false +}); +verifyEqualTo(arrObj, "0", 100); + +verifyWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.js new file mode 100644 index 0000000000..b0b4ea2cc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-263.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. + +/*--- +es5id: 15.2.3.6-4-263 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test updating the [[Configurable]] attribute value of + 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; + +Object.defineProperty(arrObj, "0", { + configurable: false +}); +verifyEqualTo(arrObj, "0", 100); + +verifyWritable(arrObj, "0"); + +verifyEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js new file mode 100644 index 0000000000..a7d2eac7f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-264.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-264 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is data property and 'desc' is data + descriptor, test updating multiple attribute values of 'name' + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = [100]; +Object.defineProperty(arrObj, "0", { + writable: false, + enumerable: false, + configurable: false +}); +verifyEqualTo(arrObj, "0", 100); + +verifyNotWritable(arrObj, "0"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js new file mode 100644 index 0000000000..f68fdd93f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-265.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-265 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Get]] attribute value of 'name' + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 100; +} +Object.defineProperty(arrObj, "0", { + get: function() { + return 12; + }, + configurable: true +}); +Object.defineProperty(arrObj, "0", { + get: getFunc +}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js new file mode 100644 index 0000000000..98d664d424 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-266.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-266 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test setting the [[Get]] attribute value of 'name' as + undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 12; +} + +Object.defineProperty(arrObj, "0", { + get: getFunc, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + get: undefined +}); +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js new file mode 100644 index 0000000000..b1d1f3c19e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-267.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-267 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Get]] attribute value of 'name' + from undefined to function object (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 12; +} +Object.defineProperty(arrObj, "0", { + get: undefined, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + get: getFunc +}); +verifyEqualTo(arrObj, "0", getFunc()); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js new file mode 100644 index 0000000000..8f65ec43a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-268.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-268 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Set]] attribute value of 'name' + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + set: setFunc +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js new file mode 100644 index 0000000000..84be2830ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-269.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-269 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test setting the [[Set]] attribute value of 'name' as + undefined (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "0", { + set: function() {}, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + set: undefined +}); +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-27.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-27.js new file mode 100644 index 0000000000..44511c75b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-27.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-27 +description: > + Object.defineProperty - 'name' is an inherited accessor property + (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "property", { + get: function() { + return 11; + }, + configurable: false +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); + +Object.defineProperty(obj, "property", { + get: function() { + return 12; + }, + configurable: true +}); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(obj.property, 12, 'obj.property'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js new file mode 100644 index 0000000000..696ebb956a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-270.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-270 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Set]] attribute value of 'name' + from undefined to function object (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + set: undefined, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + set: setFunc +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js new file mode 100644 index 0000000000..e82084fe9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-271.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-271 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Enumerable]] attribute value of + 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + enumerable: false +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js new file mode 100644 index 0000000000..663614560e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-272.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-272 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating the [[Configurable]] attribute value of + 'name' (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "0", { + set: setFunc, + configurable: true +}); + +Object.defineProperty(arrObj, "0", { + configurable: false +}); +verifyWritable(arrObj, "0", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "0"); + +verifyNotConfigurable(arrObj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js new file mode 100644 index 0000000000..14d45dbbb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-273.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-273 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, name is accessor property and 'desc' is accessor + descriptor, test updating multiple attribute values of 'name' + (15.4.5.1 step 4.c) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +function getFunc() { + return 12; +} +Object.defineProperty(arrObj, "1", { + get: function() { + return 6; + }, + set: setFunc, + enumerable: true, + configurable: true +}); + +Object.defineProperty(arrObj, "1", { + get: getFunc, + enumerable: false, + configurable: false +}); +verifyEqualTo(arrObj, "1", getFunc()); + +verifyWritable(arrObj, "1", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "1"); + +verifyNotConfigurable(arrObj, "1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-274.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-274.js new file mode 100644 index 0000000000..39367644a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-274.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. + +/*--- +es5id: 15.2.3.6-4-274 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test the length property of 'O' is not changed if + ToUint32('name') is less than value of the length property in 'O' + (15.4.5.1 step 4.e) +---*/ + +var arrObj = []; +arrObj.length = 3; // default value of length: writable: true, configurable: false, enumerable: false + +Object.defineProperty(arrObj, "1", { + value: 14 +}); + +assert.sameValue(arrObj.length, 3, 'arrObj.length'); +assert.sameValue(arrObj[1], 14, 'arrObj[1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-275.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-275.js new file mode 100644 index 0000000000..ce176462cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-275.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. + +/*--- +es5id: 15.2.3.6-4-275 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test the length property of 'O' is set as + ToUint32('name') + 1 if ToUint32('name') equals to value of the + length property in 'O' (15.4.5.1 step 4.e.ii) +---*/ + +var arrObj = []; +arrObj.length = 3; // default value of length: writable: true, configurable: false, enumerable: false + +Object.defineProperty(arrObj, "3", { + value: 3 +}); + +assert.sameValue(arrObj.length, 4, 'arrObj.length'); +assert.sameValue(arrObj[3], 3, 'arrObj[3]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-276.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-276.js new file mode 100644 index 0000000000..a5b4616b80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-276.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: 15.2.3.6-4-276 +description: > + Object.defineProperty - 'O' is an Array, 'name' is an array index + named property, test the length property of 'O' is set as + ToUint32('name') + 1 if ToUint32('name') is greater than value of + the length property in 'O' (15.4.5.1 step 4.e.ii) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "5", { + value: 3 +}); + +assert.sameValue(arrObj.length, 6, 'arrObj.length'); +assert.sameValue(arrObj[5], 3, 'arrObj[5]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.js new file mode 100644 index 0000000000..825c594a6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-277.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. + +/*--- +es5id: 15.2.3.6-4-277 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic + property that won't exist on 'O', and 'desc' is data descriptor, + test 'name' is defined in 'O' with all correct attribute values + (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "property", { + value: 12, + writable: true, + enumerable: true, + configurable: true +}); + +verifyEqualTo(arrObj, "property", 12); + +verifyWritable(arrObj, "property"); + +verifyEnumerable(arrObj, "property"); + +verifyConfigurable(arrObj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js new file mode 100644 index 0000000000..4ad70e2558 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-278.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-278 +description: > + Object.defineProperty - 'name' is generic property that won't + exist on 'O', and 'desc' is accessor descriptor, test 'name' is + defined in 'O' with all correct attribute values (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 12; +} + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} + +Object.defineProperty(arrObj, "property", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +verifyEqualTo(arrObj, "property", getFunc()); + +verifyWritable(arrObj, "property", "setVerifyHelpProp"); + +verifyEnumerable(arrObj, "property"); + +verifyConfigurable(arrObj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js new file mode 100644 index 0000000000..9f78e7cc67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-279.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-279 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + accessor property of 'O', and 'desc' is accessor descriptor, test + updating multiple attribute values of 'name' (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 12; +} + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "property", { + get: function() { + return 24; + }, + enumerable: true, + configurable: true +}); +Object.defineProperty(arrObj, "property", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +verifyEqualTo(arrObj, "property", getFunc()); + +verifyWritable(arrObj, "property", "setVerifyHelpProp"); + +verifyNotEnumerable(arrObj, "property"); + +verifyNotConfigurable(arrObj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-28.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-28.js new file mode 100644 index 0000000000..12ce2647fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-28.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-28 +description: > + Object.defineProperty - 'name' is own accessor property that + overrides an inherited data property (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + value: 11, + configurable: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); +Object.defineProperty(obj, "foo", { + get: function() {}, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.js new file mode 100644 index 0000000000..7315c8c784 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-280.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. + +/*--- +es5id: 15.2.3.6-4-280 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + data property of 'O', and 'desc' is data descriptor, test updating + multiple attribute values of 'name' (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +arrObj.property = 12; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(arrObj, "property", { + writable: false, + enumerable: false, + configurable: false +}); + +verifyEqualTo(arrObj, "property", 12); + +verifyNotWritable(arrObj, "property"); + +verifyNotEnumerable(arrObj, "property"); + +verifyNotConfigurable(arrObj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js new file mode 100644 index 0000000000..67ec5776bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-281.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-281 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + data property of 'O', test TypeError is thrown when updating the + [[Value]] attribute value of 'name' which is defined as + non-writable and non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "property", { + value: 12 +}); +try { + Object.defineProperty(arrObj, "property", { + value: 36 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "property", 12); + + verifyNotWritable(arrObj, "property"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js new file mode 100644 index 0000000000..0b05899bc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-282.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-282 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + data property of 'O', test TypeError is thrown when updating the + [[Writable]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "property", { + writable: false +}); +try { + Object.defineProperty(arrObj, "property", { + writable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "property", undefined); + + verifyNotWritable(arrObj, "property"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js new file mode 100644 index 0000000000..7ca939b4f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-283.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-283 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + data property of 'O', test TypeError is thrown when updating the + [[Enumerable]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "property", { + value: 12, + enumerable: false +}); +try { + Object.defineProperty(arrObj, "property", { + enumerable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "property", 12); + + verifyNotWritable(arrObj, "property"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js new file mode 100644 index 0000000000..48bd118b9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-284.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-284 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + data property of 'O', test TypeError is thrown when updating the + [[Configurable]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +Object.defineProperty(arrObj, "property", { + value: 12 +}); +try { + Object.defineProperty(arrObj, "property", { + configurable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "property", 12); + + verifyNotWritable(arrObj, "property"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js new file mode 100644 index 0000000000..055d7d32d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-285.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-285 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + accessor property of 'O', test TypeError is thrown when updating + the [[Get]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function getFunc() { + return 12; +} + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "property", { + get: getFunc, + set: setFunc +}); +try { + Object.defineProperty(arrObj, "property", { + get: function() { + return 36; + } + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(arrObj, "property", getFunc()); + + verifyWritable(arrObj, "property", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js new file mode 100644 index 0000000000..ebf54b5e61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-286.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-286 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + accessor property of 'O', and 'desc' is accessor descriptor, test + TypeError is thrown when updating the [[Set]] attribute value of + 'name' (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "property", { + set: setFunc +}); +try { + Object.defineProperty(arrObj, "property", { + set: function() {} + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyWritable(arrObj, "property", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js new file mode 100644 index 0000000000..3aa609e301 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-287.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-287 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + accessor property of 'O', test TypeError is thrown when updating + the [[Enumerable]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "property", { + set: setFunc, + enumerable: false +}); +try { + Object.defineProperty(arrObj, "property", { + enumerable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyWritable(arrObj, "property", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js new file mode 100644 index 0000000000..99317bcbab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-288.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-288 +description: > + Object.defineProperty - 'O' is an Array, 'name' is generic own + accessor property of 'O', test TypeError is thrown when updating + the [[Configurable]] attribute value of 'name' which is defined as + non-configurable (15.4.5.1 step 5) +includes: [propertyHelper.js] +---*/ + + +var arrObj = []; + +function setFunc(value) { + arrObj.setVerifyHelpProp = value; +} +Object.defineProperty(arrObj, "property", { + set: setFunc, + configurable: false +}); +try { + Object.defineProperty(arrObj, "property", { + configurable: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyWritable(arrObj, "property", "setVerifyHelpProp"); + + verifyNotEnumerable(arrObj, "property"); + + verifyNotConfigurable(arrObj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js new file mode 100644 index 0000000000..9c16dbb07a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289-1.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-289-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own property which is + defined in both [[ParameterMap]] of 'O' and 'O', and is deleted + afterwards, and 'desc' is data descriptor, test 'name' is + redefined in 'O' with all correct attribute values (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +; +(function(a, b, c) { + delete arguments[0]; + + Object.defineProperty(arguments, "0", { + value: 10, + writable: true, + enumerable: true, + configurable: true + }); + + if (a !== 0) { + throw new Test262Error("Expected a === 0, actually " + a); + } + + verifyEqualTo(arguments, "0", 10); + + verifyWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js new file mode 100644 index 0000000000..4b90e38ef6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-289.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-289 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + property of 'O', and is deleted afterwards, and 'desc' is data + descriptor, test 'name' is redefined in 'O' with all correct + attribute values (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + delete arguments[0]; + Object.defineProperty(arguments, "0", { + value: 10, + writable: true, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "0", 10); + + verifyWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-29.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-29.js new file mode 100644 index 0000000000..4ffa113be7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-29.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-29 +description: > + Object.defineProperty - 'name' is own accessor property that + overrides an inherited accessor property (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + get: function() {}, + configurable: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); +Object.defineProperty(obj, "foo", { + get: function() {}, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js new file mode 100644 index 0000000000..71fa4baeff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290-1.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-290-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own property which is + defined in both [[ParameterMap]] of 'O' and 'O', is deleted + afterwards, and 'desc' is accessor descriptor, test 'name' is + redefined in 'O' with all correct attribute values (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + delete arguments[0]; + + function getFunc() { + return 10; + } + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true + }); + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + + verifyEqualTo(arguments, "0", getFunc()); + + verifyWritable(arguments, "0", "setVerifyHelpProp"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js new file mode 100644 index 0000000000..6b4d350268 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-290.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-290 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + property of 'O', and is deleted afterwards, and 'desc' is accessor + descriptor, test 'name' is redefined in 'O' with all correct + attribute values (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + delete arguments[0]; + + function getFunc() { + return 10; + } + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "0", getFunc()); + + verifyWritable(arguments, "0", "setVerifyHelpProp"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js new file mode 100644 index 0000000000..04faea4a9e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291-1.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-291-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own accessor property of 'O' + which is also defined in [[ParameterMap]] of 'O', and 'desc' is + accessor descriptor, test updating multiple attribute values of + 'name' (10.6 [[DefineOwnProperty]] step 3 and 5.a.i) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc1() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: true, + configurable: true + }); + + function getFunc2() { + return 20; + } + Object.defineProperty(arguments, "0", { + get: getFunc2, + enumerable: false, + configurable: false + }); + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + + verifyEqualTo(arguments, "0", getFunc2()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js new file mode 100644 index 0000000000..0d936a72a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-291.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-291 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + accessor property of 'O', and 'desc' is accessor descriptor, test + updating multiple attribute values of 'name' (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc1() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: true, + configurable: true + }); + + function getFunc2() { + return 20; + } + Object.defineProperty(arguments, "0", { + get: getFunc2, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", getFunc2()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js new file mode 100644 index 0000000000..124143b87c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-1.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-292-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own property of 'O' which is + also defined in [[ParameterMap]] of 'O', and 'desc' is data + descriptor, test updating multiple attribute values of 'name' + (10.6 [[DefineOwnProperty]] step 3 and 5.b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false + }); + + if (a !== 20) { + throw new Test262Error('Expected a === 20, actually ' + a); + } + + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js new file mode 100644 index 0000000000..5327e61f5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292-2-strict.js @@ -0,0 +1,38 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-292-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own property of 'O' which is + also defined in [[ParameterMap]] of 'O', and 'desc' is data + descriptor, test updating multiple attribute values of 'name' + (10.6 [[DefineOwnProperty]] step 3 and 5.b) +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false + }); + + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js new file mode 100644 index 0000000000..7091d42cf8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-292.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-292 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', and 'desc' is data descriptor, test updating + multiple attribute values of 'name' (10.6 [[DefineOwnProperty]] + step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.js new file mode 100644 index 0000000000..642e95f413 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-1.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. + +/*--- +es5id: 15.2.3.6-4-293-1 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', test TypeError is not thrown when updating + the [[Value]] attribute value of 'name' which is defined as + non-writable and configurable (10.6 [[DefineOwnProperty]] step 3 + and 5b) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false + }); + Object.defineProperty(arguments, "0", { + value: 20 + }); + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js new file mode 100644 index 0000000000..063ab121d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-2.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-293-2 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Value]] attribute value of 'name' + which is defined as unwritable and non-configurable (10.6 + [[DefineOwnProperty]] step 4 and step 5b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + value: 20 + }); + throw new Test262Error("Expected an exception."); + + } catch (e) { + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (a !== 10) { + throw new Test262Error('Expected "a === 10", actually ' + a); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js new file mode 100644 index 0000000000..a27f584a65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-293-3 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is not thrown when updating the [[Value]] attribute value of + 'name' which is defined as non-writable and configurable (10.6 + [[DefineOwnProperty]] step 3 and step 5.b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + }); + Object.defineProperty(arguments, "0", { + value: 20 + }); + if (a !== 10) { + throw new Test262Error('Expected "a === 10", actually ' + a); + } + + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js new file mode 100644 index 0000000000..03ace78694 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293-4-strict.js @@ -0,0 +1,39 @@ +'use strict'; +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-293-4 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is not thrown when updating the [[Value]] attribute value of + 'name' which is defined as non-writable and configurable (10.6 + [[DefineOwnProperty]] step 3 and step 5.b) +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + }); + Object.defineProperty(arguments, "0", { + value: 20 + }); + if (a !== 0) { + throw new Test262Error('Expected "a === 0", actually ' + a); + } + + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js new file mode 100644 index 0000000000..4ca208ba8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-293.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-293 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', test TypeError is thrown when updating the + [[Value]] attribute value of 'name' which is defined as + non-writable and non-configurable (10.6 [[DefineOwnProperty]] step + 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + value: 20 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js new file mode 100644 index 0000000000..e358ab75e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294-1.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-294-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Writable]] attribute value of 'name' + which is defined as non-configurable (10.6 [[DefineOwnProperty]] + step 4 and 5b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + writable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (a !== 10) { + throw new Test262Error('Expected "a === 10", actually ' + a); + } + + } + +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js new file mode 100644 index 0000000000..08c69e755e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-294.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-294 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', test TypeError is thrown when updating the + [[Writable]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + writable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js new file mode 100644 index 0000000000..394066dfc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295-1.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-295-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Enumerable]] attribute value of + 'name' which is defined as non-configurable (10.6 + [[DefineOwnProperty]] step 4 and step 5b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (a !== 10) { + throw new Test262Error('Expected "a === 10", actually ' + a); + } + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js new file mode 100644 index 0000000000..cd7eb340b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-295.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-295 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', test TypeError is thrown when updating the + [[Enumerable]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js new file mode 100644 index 0000000000..77e9fe1642 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296-1.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-296-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Configurable]] attribute value of + 'name' which is defined as non-configurable (10.6 + [[DefineOwnProperty]] step 4 and step 5b) +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (a !== 10) { + throw new Test262Error('Expected "a === 10", actually ' + a); + } + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js new file mode 100644 index 0000000000..8625821007 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-296.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-296 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + data property of 'O', test TypeError is thrown when updating the + [[Configurable]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js new file mode 100644 index 0000000000..8627560fa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297-1.js @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-297-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own accessor property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Get]] attribute value of 'name' + which is defined as non-configurable (10.6 [[DefineOwnProperty]] + step 4 and step 5a) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc1() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: false, + configurable: false + }); + + function getFunc2() { + return 20; + } + try { + Object.defineProperty(arguments, "0", { + get: getFunc2 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + + verifyEqualTo(arguments, "0", getFunc1()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js new file mode 100644 index 0000000000..e738fc84a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-297.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-297 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Get]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc1() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: false, + configurable: false + }); + + function getFunc2() { + return 20; + } + try { + Object.defineProperty(arguments, "0", { + get: getFunc2 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc1()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js new file mode 100644 index 0000000000..9cb976b0fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298-1.js @@ -0,0 +1,53 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-298-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own accessor property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Set]] attribute value of 'name' + which is defined as non-configurable (10.6 [[DefineOwnProperty]] + steps 4 and 5a) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false + }); + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + try { + Object.defineProperty(arguments, "0", { + set: setFunc + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + + verifyEqualTo(arguments, "0", getFunc()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js new file mode 100644 index 0000000000..651330f8f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-298.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-298 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Set]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false + }); + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + try { + Object.defineProperty(arguments, "0", { + set: setFunc + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js new file mode 100644 index 0000000000..2ef3e98416 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299-1.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-299-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own accessor property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Enumerable]] attribute value of + 'name' which is defined as non-configurable (10.6 + [[DefineOwnProperty]] steps 4 and 5a) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js new file mode 100644 index 0000000000..8294112d3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-299.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-299 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Enumerable]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-3.js new file mode 100644 index 0000000000..9273fd373c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-3.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For newly defined accessor properties, attributes + missing from desc should have values set to the defaults from 8.6.1. +es5id: 15.2.3.6-4-3 +description: > + Object.defineProperty sets missing attributes to their default + values (accessor)(8.12.9 step 4.b.i) +---*/ + +var o = {}; + +var getter = function() { + return 1; +}; +var desc = { + get: getter +}; + +Object.defineProperty(o, "foo", desc); + +var propDesc = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(typeof(propDesc.get), "function", 'typeof(propDesc.get)'); +assert.sameValue(propDesc.get, getter, 'propDesc.get'); // the getter must be the function that was provided +assert.sameValue(propDesc.set, undefined, 'propDesc.set'); // undefined by default +assert.sameValue(propDesc.enumerable, false, 'propDesc.enumerable'); // false by default +assert.sameValue(propDesc.configurable, false, 'propDesc.configurable'); // false by default + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-30.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-30.js new file mode 100644 index 0000000000..b86fe03227 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-30.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: 15.2.3.6-4-30 +description: > + Object.defineProperty - 'name' is own accessor property without a + get function (8.12.9 step 1) +---*/ + +var obj = {}; +Object.defineProperty(obj, "foo", { + set: function() {}, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js new file mode 100644 index 0000000000..802dd24613 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300-1.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-300-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own accessor property of 'O' + which is also defined in [[ParameterMap]] of 'O', test TypeError + is thrown when updating the [[Configurable]] attribute value of + 'name' which is defined as non-configurable (10.6 + [[DefineOwnProperty]] step 4 and step 5a) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc() { + return 0; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js new file mode 100644 index 0000000000..2341d87dca --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-300.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-300 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Configurable]] attribute value of 'name' which is defined as + non-configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js new file mode 100644 index 0000000000..50854b502f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301-1.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-301-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is an index named property of + 'O', and 'desc' is data descriptor, test 'name' is defined in 'O' + with all correct attribute values (10.6 [[DefineOwnProperty]] step + 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + delete arguments[0]; + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + if (a !== 0) { + throw new Test262Error("Expected a === 0, actually " + a); + } + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.js new file mode 100644 index 0000000000..6387b45b3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-301.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. + +/*--- +es5id: 15.2.3.6-4-301 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + array index named property of 'O' but not defined in + [[ParameterMap]] of 'O', and 'desc' is data descriptor, test + 'name' is defined in 'O' with all correct attribute values (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + delete arguments[0]; + Object.defineProperty(arguments, "0", { + value: 10, + writable: false, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", 10); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js new file mode 100644 index 0000000000..d9e24450e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302-1.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-302-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is an index named property of + 'O' but not defined in [[ParameterMap]] of 'O', and 'desc' is + accessor descriptor, test 'name' is defined in 'O' with all + correct attribute values (10.6 [[DefineOwnProperty]] step 3 and + step 5a) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + delete arguments[0]; + + function getFunc() { + return 10; + } + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false + }); + if (a !== 0) { + throw new Test262Error('Expected a === 0, actually ' + a); + } + verifyEqualTo(arguments, "0", getFunc()); + + verifyWritable(arguments, "0", "setVerifyHelpProp"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js new file mode 100644 index 0000000000..40fe4d4fcd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-302.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-302 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named property of 'O' but not defined in [[ParameterMap]] of + 'O', and 'desc' is accessor descriptor, test 'name' is defined in + 'O' with all correct attribute values (10.6 [[DefineOwnProperty]] + step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + delete arguments[0]; + + function getFunc() { + return 10; + } + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", getFunc()); + + verifyWritable(arguments, "0", "setVerifyHelpProp"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}(0, 1, 2)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js new file mode 100644 index 0000000000..e1d15a9dcd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-303.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-303 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named accessor property of 'O' but not defined in + [[ParameterMap]] of 'O', and 'desc' is accessor descriptor, test + updating multiple attribute values of 'name' (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc1() { + return 10; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: true, + configurable: true + }); + + function getFunc2() { + return 20; + } + Object.defineProperty(arguments, "0", { + get: getFunc2, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", getFunc2()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js new file mode 100644 index 0000000000..058949b82b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-304.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-304 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named data property of 'O' but not defined in + [[ParameterMap]] of 'O', and 'desc' is data descriptor, test + updating multiple attribute values of 'name' (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 20, + writable: false, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "0", 20); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js new file mode 100644 index 0000000000..88e3ea9526 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-305.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-305 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named data property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Value]] attribute value of 'name' which is not writable and + not configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 0, + writable: false, + configurable: false + }); + + try { + Object.defineProperty(arguments, "0", { + value: 10 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 0); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js new file mode 100644 index 0000000000..a33eff559b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-306.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-306 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named data property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Writable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + writable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 0); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js new file mode 100644 index 0000000000..c9fdf870ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-307.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-307 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named data property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Enumerable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 0); + + verifyNotWritable(arguments, "0"); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js new file mode 100644 index 0000000000..aceabc53a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-308.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-308 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named data property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Configurable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "0", { + value: 0, + writable: false, + enumerable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", 0); + + verifyNotWritable(arguments, "0"); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js new file mode 100644 index 0000000000..f1803f13cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-309.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-309 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named accessor property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Get]] attribute value of 'name' which is not configurable + (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc1() { + return 0; + } + Object.defineProperty(arguments, "0", { + get: getFunc1, + enumerable: false, + configurable: false + }); + + function getFunc2() { + return 10; + } + try { + Object.defineProperty(arguments, "0", { + get: getFunc2 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc1()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-31.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-31.js new file mode 100644 index 0000000000..bb0adb7433 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-31.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-31 +description: > + Object.defineProperty - 'name' is own accessor property without a + get function that overrides an inherited accessor property(8.12.9 + step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + get: function() {}, + configurable: true +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); +Object.defineProperty(obj, "foo", { + set: function() {}, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js new file mode 100644 index 0000000000..094229861a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-310.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-310 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named accessor property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Set]] attribute value of 'name' which is not configurable + (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return 0; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false + }); + + function setFunc(value) { + this.setVerifyHelpProp = value; + } + try { + Object.defineProperty(arguments, "0", { + set: setFunc + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyNotEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js new file mode 100644 index 0000000000..ede81f7918 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-311.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-311 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named accessor property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Enumerable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return 0; + } + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js new file mode 100644 index 0000000000..eaf2c27fab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-312.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-312 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is an + index named accessor property of 'O' but not defined in + [[ParameterMap]] of 'O', test TypeError is thrown when updating + the [[Configurable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() {} + Object.defineProperty(arguments, "0", { + get: getFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "0", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "0", getFunc()); + + verifyEnumerable(arguments, "0"); + + verifyNotConfigurable(arguments, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js new file mode 100644 index 0000000000..24f6b77d8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313-1.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-313-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own property, and 'desc' is + data descriptor, test 'P' is defined in 'O' with all correct + attribute values (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "genericProperty", 1001); + + verifyWritable(arguments, "genericProperty"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js new file mode 100644 index 0000000000..5f5650d942 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-313.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-313 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is generic + property, and 'desc' is data descriptor, test 'P' is defined in + 'O' with all correct attribute values (10.6 [[DefineOwnProperty]] + step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "genericProperty", 1001); + + verifyWritable(arguments, "genericProperty"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js new file mode 100644 index 0000000000..aaa4d6a0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314-1.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-314-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is property, and 'desc' is + accessor descriptor, test 'P' is defined in 'O' with all correct + attribute values (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc() { + return "getFunctionString"; + } + + function setFunc(value) { + this.testgetFunction = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "testgetFunction"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js new file mode 100644 index 0000000000..707689d404 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-314.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-314 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is generic + property, and 'desc' is accessor descriptor, test 'P' is defined + in 'O' with all correct attribute values (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return "getFunctionString"; + } + + function setFunc(value) { + this.testgetFunction = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true + }); + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "testgetFunction"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js new file mode 100644 index 0000000000..078b2b0c03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315-1.js @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-315-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own accessor property of 'O', + and 'desc' is accessor descriptor, test updating multiple + attribute values of 'P' (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + get: function() { + return 1001; + }, + set: function(value) { + this.testgetFunction1 = value; + }, + enumerable: true, + configurable: true + }); + + function getFunc() { + return "getFunctionString"; + } + + function setFunc(value) { + this.testgetFunction = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false + }); + if (c !== 3) { + throw new Test262Error('Expected c === 3, actually ' + c); + } + + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "testgetFunction"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js new file mode 100644 index 0000000000..f9e6b876a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-315.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-315 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is generic + own accessor property of 'O', and 'desc' is accessor descriptor, + test updating multiple attribute values of 'P' (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + get: function() { + return 1001; + }, + set: function(value) { + this.testgetFunction1 = value; + }, + enumerable: true, + configurable: true + }); + + function getFunc() { + return "getFunctionString"; + } + + function setFunc(value) { + this.testgetFunction = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "testgetFunction"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js new file mode 100644 index 0000000000..4c18c0b45c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316-1.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-316-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own data property of 'O', and + 'desc' is data descriptor, test updating multiple attribute values + of 'P' (10.6 [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true + }); + Object.defineProperty(arguments, "genericProperty", { + value: 1002, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "genericProperty", 1002); + + verifyWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js new file mode 100644 index 0000000000..6683891473 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-316.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-316 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is generic + own data property of 'O', and 'desc' is data descriptor, test + updating multiple attribute values of 'P' (10.6 + [[DefineOwnProperty]] step 3) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: true, + enumerable: true, + configurable: true + }); + Object.defineProperty(arguments, "genericProperty", { + value: 1002, + enumerable: false, + configurable: false + }); + verifyEqualTo(arguments, "genericProperty", 1002); + + verifyWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js new file mode 100644 index 0000000000..be820cbce1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317-1.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-317-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own data property of 'O', test + TypeError is thrown when updating the [[Value]] attribute value of + 'P' which is not writable and not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + value: 1002 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (b !== 2) { + throw new Test262Error('Expected "b === 2;", actually ' + b); + } + + verifyEqualTo(arguments, "genericProperty", 1001); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js new file mode 100644 index 0000000000..77ca0ba862 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-317.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-317 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is generic + own data property of 'O', test TypeError is thrown when updating + the [[Value]] attribute value of 'P' which is not writable and not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + value: 1001, + writable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + value: 1002 + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", 1001); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js new file mode 100644 index 0000000000..c275772feb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318-1.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-318-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'name' is own data property of 'O', + test TypeError is thrown when updating the [[Writable]] attribute + value of 'name' which is not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + writable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + writable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js new file mode 100644 index 0000000000..95284091f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-318.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-318 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is + generic own data property of 'O', test TypeError is thrown when + updating the [[Writable]] attribute value of 'name' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + writable: false, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + writable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } + +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js new file mode 100644 index 0000000000..6f184f8196 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319-1.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-319-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own data property of 'O', test + TypeError is thrown when updating the [[Enumerable]] attribute + value of 'P' which is not configurable (10.6 [[DefineOwnProperty]] + step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js new file mode 100644 index 0000000000..d4c4c20dc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-319.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-319 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is own + data property of 'O', test TypeError is thrown when updating the + [[Enumerable]] attribute value of 'P' which is not configurable + (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-32.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-32.js new file mode 100644 index 0000000000..b50308be75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-32.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. + +/*--- +es5id: 15.2.3.6-4-32 +description: > + Object.defineProperty - 'name' is an inherited accessor property + without a get function (8.12.9 step 1) +---*/ + +var proto = {}; +Object.defineProperty(proto, "foo", { + set: function() {}, + configurable: false +}); + +var ConstructFun = function() {}; +ConstructFun.prototype = proto; +var obj = new ConstructFun(); + +Object.defineProperty(obj, "foo", { + configurable: true +}); + +assert(obj.hasOwnProperty("foo"), 'obj.hasOwnProperty("foo") !== true'); +assert.sameValue(typeof obj.foo, "undefined", 'typeof obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js new file mode 100644 index 0000000000..794b689a98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320-1.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-320-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own data property of 'O', test + TypeError is thrown when updating the [[Configurable]] attribute + value of 'P' which is not configurable (10.6 [[DefineOwnProperty]] + step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + Object.defineProperty(arguments, "genericProperty", { + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js new file mode 100644 index 0000000000..2d16488d20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-320.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-320 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is own + data property of 'O', test TypeError is thrown when updating the + [[Configurable]] attribute value of 'P' which is not configurable + (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + Object.defineProperty(arguments, "genericProperty", { + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", undefined); + + verifyNotWritable(arguments, "genericProperty"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } + +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js new file mode 100644 index 0000000000..f0b19aff91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321-1.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-321-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own accessor property of 'O', + test TypeError is thrown when updating the [[Get]] attribute value + of 'P' which is not configurable (10.6 [[DefineOwnProperty]] step + 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function getFunc() { + return "genericPropertyString"; + } + + function setFunc(value) { + this.helpVerifyGet = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + get: function() { + return "overideGenericPropertyString"; + } + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (a !== 1) { + throw new Test262Error('Expected a === 1, actually ' + a); + } + + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "helpVerifyGet"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js new file mode 100644 index 0000000000..ce1ebc65ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-321.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-321 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Get]] attribute value of 'P' which is not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function getFunc() { + return "genericPropertyString"; + } + + function setFunc(value) { + this.helpVerifyGet = value; + } + Object.defineProperty(arguments, "genericProperty", { + get: getFunc, + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + get: function() { + return "overideGenericPropertyString"; + } + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyEqualTo(arguments, "genericProperty", getFunc()); + + verifyWritable(arguments, "genericProperty", "helpVerifyGet"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js new file mode 100644 index 0000000000..4261b4980b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322-1.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-322-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own accessor property of 'O', + test TypeError is thrown when updating the [[Set]] attribute value + of 'P' which is not configurable (10.6 [[DefineOwnProperty]] step + 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + set: function(value) { + this.genericPropertyString1 = value; + } + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js new file mode 100644 index 0000000000..9414c90d54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-322.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-322 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Set]] attribute value of 'P' which is not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + set: function(value) { + this.genericPropertyString1 = value; + } + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js new file mode 100644 index 0000000000..769c0a8634 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323-1.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-323-1 +description: > + Object.defineProperty - ''O' is an Arguments object of a function + that has formal parameters, 'P' is own accessor property of 'O', + test TypeError is thrown when updating the [[Enumerable]] + attribute value of 'P' which is not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + if (c !== 3) { + throw new Test262Error('Expected c === 3, actually ' + c); + } + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } + +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js new file mode 100644 index 0000000000..a6e17705ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-323.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-323 +description: > + Object.defineProperty - ''O' is an Arguments object, 'P' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Enumerable]] attribute value of 'P' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + enumerable: true, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + enumerable: false + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js new file mode 100644 index 0000000000..949102ee2f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324-1.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-324-1 +description: > + Object.defineProperty - 'O' is an Arguments object of a function + that has formal parameters, 'P' is own accessor property of 'O', + test TypeError is thrown when updating the [[Configurable]] + attribute value of 'P' which is not configurable (10.6 + [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function(a, b, c) { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js new file mode 100644 index 0000000000..bd7e47b2d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-324.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-324 +description: > + Object.defineProperty - 'O' is an Arguments object, 'P' is own + accessor property of 'O', test TypeError is thrown when updating + the [[Configurable]] attribute value of 'P' which is not + configurable (10.6 [[DefineOwnProperty]] step 4) +includes: [propertyHelper.js] +---*/ + +(function() { + function setFunc(value) { + this.genericPropertyString = value; + } + Object.defineProperty(arguments, "genericProperty", { + set: setFunc, + configurable: false + }); + try { + Object.defineProperty(arguments, "genericProperty", { + configurable: true + }); + throw new Test262Error("Expected an exception."); + } catch (e) { + verifyWritable(arguments, "genericProperty", "genericPropertyString"); + + verifyNotEnumerable(arguments, "genericProperty"); + + verifyNotConfigurable(arguments, "genericProperty"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + + } + false; +}(1, 2, 3)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325-1.js new file mode 100644 index 0000000000..7fd5606d8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-325-1 +description: > + Object.defineProperty - 'O' is an Arguments object which created + with function take formal parameters, 'name' is own property of + [[ParameterMap]] of 'O', test 'name' is deleted if 'name' is + configurable and 'desc' is accessor descriptor (10.6 + [[DefineOwnProperty]] step 5.a.i) +---*/ + +var argObj = (function(a, b, c) { + return arguments; +})(1, 2, 3); +var accessed = false; + +Object.defineProperty(argObj, 0, { + get: function() { + accessed = true; + return 12; + } +}); + +assert.sameValue(argObj[0], 12, 'argObj[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325.js new file mode 100644 index 0000000000..52fb06e715 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-325.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. + +/*--- +es5id: 15.2.3.6-4-325 +description: > + Object.defineProperty - 'O' is an Arguments object, 'name' is own + property of [[ParameterMap]] of 'O', test 'name' is deleted if + 'name' is configurable and 'desc' is accessor descriptor (10.6 + [[DefineOwnProperty]] step 5.a.i) +---*/ + +var argObj = (function() { + return arguments; +})(1, 2, 3); +var accessed = false; + +Object.defineProperty(argObj, 0, { + get: function() { + accessed = true; + return 12; + } +}); + +assert.sameValue(argObj[0], 12, 'argObj[0]'); +assert(accessed, 'accessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-326.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-326.js new file mode 100644 index 0000000000..7752bd6713 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-326.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. + +/*--- +es5id: 15.2.3.6-4-326 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is true) is writable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = (obj.prop === 2010); +obj.prop = 1001; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-327.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-327.js new file mode 100644 index 0000000000..25b2be0adb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-327.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-327 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is true) is enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var property in obj) { + if (property === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-328.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-328.js new file mode 100644 index 0000000000..cd0da76fa7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-328.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. + +/*--- +es5id: 15.2.3.6-4-328 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is true) is deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var beforeDelete = obj.hasOwnProperty("prop"); +delete obj.prop; +var afterDelete = obj.hasOwnProperty("prop"); + +assert(beforeDelete, 'beforeDelete !== true'); +assert.sameValue(afterDelete, false, 'afterDelete'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-329.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-329.js new file mode 100644 index 0000000000..2c4c1556b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-329.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-329 +description: > + ES5 Attributes - success to update [[Writable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, true, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-33.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-33.js new file mode 100644 index 0000000000..ec1e0bb134 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-33.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. + +/*--- +es5id: 15.2.3.6-4-33 +description: > + Object.defineProperty - 'O' is a Function object that uses + Object's [[GetOwnProperty]] method to access the 'name' property + (8.12.9 step 1) +---*/ + +var fun = function() {}; + +Object.defineProperty(fun, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(fun, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(fun.foo, 12, 'fun.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-330.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-330.js new file mode 100644 index 0000000000..9ec752dcd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-330.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-330 +description: > + ES5 Attributes - success to update [[enumerable]] attribute of + data property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-331.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-331.js new file mode 100644 index 0000000000..d486912194 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-331.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-331 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + data property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, true, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-332.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-332.js new file mode 100644 index 0000000000..87c3523276 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-332.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-332 +description: > + ES5 Attributes - success to update the data property ([[Writable]] + is true, [[Enumerable]] is true, [[Configurable]] is true) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js new file mode 100644 index 0000000000..b38f669f07 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-1.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-1 +description: > + Object.defineProperty will update [[Value]] attribute of named + property 'P' successfully when [[Configurable]] attribute is + false, [[Writable]] attribute is true and 'O' is an Object object + (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "property", { + value: 1002 +}); + +verifyEqualTo(obj, "property", 1002); + +verifyWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-10.js new file mode 100644 index 0000000000..5ef66b6e02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-10.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. + +/*--- +es5id: 15.2.3.6-4-333-10 +description: > + ES5 Attributes - indexed data property 'P' with attributes + [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false + is writable using simple assignment, 'O' is an Arguments object +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var verifyValue = (obj[0] === 2010); +obj[0] = 1001; + +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(obj[0], 1001, 'obj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-11.js new file mode 100644 index 0000000000..82b7979a03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-11.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. + +/*--- +es5id: 15.2.3.6-4-333-11 +description: > + ES5 Attributes - indexed property 'P' with attributes + [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false + is writable using simple assignment, 'O' is an Arguments object +---*/ + +var obj = (function(x) { + return arguments; +}(1001)); + +Object.defineProperty(obj, "0", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var verifyValue = (obj[0] === 2010); + +assert(verifyValue, 'verifyValue !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js new file mode 100644 index 0000000000..2c7ac9fd07 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-2.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-2 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property 'P' successfully when [[Configurable]] attribute is + false, [[Writable]] attribute is true and 'A' is an Array object + (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js new file mode 100644 index 0000000000..214436cb50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-3.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-3 +description: > + Object.defineProperty will update [[Value]] attribute of named + property 'P' successfully when [[Configurable]] attribute is + false, [[Writable]] attribute is true and 'O' is an Arguments + object (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "property", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "property", { + value: 1002 +}); + +verifyEqualTo(obj, "property", 1002); + +verifyWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-4.js new file mode 100644 index 0000000000..22cc6d3969 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-4.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. + +/*--- +es5id: 15.2.3.6-4-333-4 +description: > + Indexed property 'P' with attributes [[Writable]]: true, + [[Enumerable]]:true, [[Configurable]]:false is writable using + simple assignment, 'A' is an Array Object +---*/ + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var verifyValue = (obj[0] === 2010); +obj[0] = 1001; + +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(obj[0], 1001, 'obj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-5.js new file mode 100644 index 0000000000..59bfb0fdc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-5.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. + +/*--- +es5id: 15.2.3.6-4-333-5 +description: > + ES5 Attributes - named data property 'P' with attributes + [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false + is writable using simple assignment, 'O' is an Arguments object +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var verifyValue = (obj.prop === 2010); +obj.prop = 1001; + +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js new file mode 100644 index 0000000000..21265866ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-6.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-6 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property 'P' successfully when [[Configurable]] attribute is + false, [[Writable]] attribute is true and 'O' is an Object object + (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js new file mode 100644 index 0000000000..dea755a355 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-7 +description: > + Object.defineProperty will update [[Value]] attribute of named + property 'P' successfully when [[Configurable]] attribute is + false, [[Writable]] attribute is true and 'A' is an Array object + (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "prop", { + value: 1002 +}); + +verifyEqualTo(obj, "prop", 1002); + +verifyWritable(obj, "prop"); + +verifyNotEnumerable(obj, "prop"); + +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js new file mode 100644 index 0000000000..785d0adc99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-8.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-333-8 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property 'P'successfully when [[Configurable]] attribute is false, + [[Writable]] attribute is true and 'O' is an Arguments object + (8.12.9 - step 10) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + configurable: false +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-9.js new file mode 100644 index 0000000000..3e4826bc68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333-9.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. + +/*--- +es5id: 15.2.3.6-4-333-9 +description: > + Object.defineProperty - Named property 'P' with attributes + [[Writable]]: true, [[Enumerable]]:true, [[Configurable]]:false is + writable using simple assignment, 'A' is an Array Object +---*/ + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var verifyValue = (obj.prop === 2010); +obj.prop = 1001; + +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333.js new file mode 100644 index 0000000000..a058a96dfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-333.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. + +/*--- +es5id: 15.2.3.6-4-333 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is false) is writable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = (obj.prop === 2010); +obj.prop = 1001; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-334.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-334.js new file mode 100644 index 0000000000..9dd1913d57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-334.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-334 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is false) is enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.js new file mode 100644 index 0000000000..177a249f90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-335.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. + +/*--- +es5id: 15.2.3.6-4-335 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + true, [[Configurable]] is false) is undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); +assert.sameValue(obj.prop, 2010); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-336.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-336.js new file mode 100644 index 0000000000..1d36f87db1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-336.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-336 +description: > + ES5 Attributes - Success to update [[Writable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, true, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-337.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-337.js new file mode 100644 index 0000000000..6dbfc373e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-337.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-337 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-338.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-338.js new file mode 100644 index 0000000000..f5895fba7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-338.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-338 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + configurable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, false, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-1.js new file mode 100644 index 0000000000..bbb084c07d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-1.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-339-1 +description: > + Object.defineProperty - Updating indexed data property 'P' with + attributes [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false to an accessor property does not succeed, + 'A' is an Array object (8.12.9 - step 9.a) +---*/ + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("0"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "0", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj[0], 2010, 'obj[0]'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-2.js new file mode 100644 index 0000000000..b03613e1c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-2.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-339-2 +description: > + Object.defineProperty - Updating named data property 'P' with + attributes [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false to an accessor property does not succeed, + 'O' is an Arguments object (8.12.9 - step 9.a) +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-3.js new file mode 100644 index 0000000000..dd51c78891 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-3.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-339-3 +description: > + Object.defineProperty - Updating named data property 'P' with + attributes [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false to an accessor property does not succeed, + 'A' is an Array object (8.12.9 - step 9.a) +---*/ + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-4.js new file mode 100644 index 0000000000..9d0706c67e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339-4.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-339-4 +description: > + Object.defineProperty - Updating indexed data property 'P' with + attributes [[Writable]]: true, [[Enumerable]]: true, + [[Configurable]]: false to an accessor property does not succeed, + 'O' is an Arguments object (8.12.9 - step 9.a) +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("0"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "0", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj[0], 2010, 'obj[0]'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339.js new file mode 100644 index 0000000000..5dda522258 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-339.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-339 +description: > + ES5 Attributes - fail to update the data property ([[Writable]] is + true, [[Enumerable]] is true, [[Configurable]] is false) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-34.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-34.js new file mode 100644 index 0000000000..75abd1d192 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-34.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. + +/*--- +es5id: 15.2.3.6-4-34 +description: > + Object.defineProperty - 'O' is an Array object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var arrObj = []; + +Object.defineProperty(arrObj, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(arrObj, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(arrObj.foo, 12, 'arrObj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-340.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-340.js new file mode 100644 index 0000000000..1c409533d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-340.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. + +/*--- +es5id: 15.2.3.6-4-340 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is true) is writable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = (obj.prop === 2010); +obj.prop = 1001; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-341.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-341.js new file mode 100644 index 0000000000..5a69176101 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-341.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. + +/*--- +es5id: 15.2.3.6-4-341 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is true) is non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-342.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-342.js new file mode 100644 index 0000000000..f548201ebe --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-342.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. + +/*--- +es5id: 15.2.3.6-4-342 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is true) is deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var beforeDelete = obj.hasOwnProperty("prop"); +delete obj.prop; +var afterDelete = obj.hasOwnProperty("prop"); + +assert(beforeDelete, 'beforeDelete !== true'); +assert.sameValue(afterDelete, false, 'afterDelete'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-343.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-343.js new file mode 100644 index 0000000000..f277f07f73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-343.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-343 +description: > + ES5 Attributes - success to update [[Writable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, true, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-344.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-344.js new file mode 100644 index 0000000000..6e4242ade1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-344.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-344 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + data property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-345.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-345.js new file mode 100644 index 0000000000..00f26c332b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-345.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-345 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + data property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, true, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-346.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-346.js new file mode 100644 index 0000000000..39bae9dae3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-346.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-346 +description: > + ES5 Attributes - success to update the data property ([[Writable]] + is true, [[Enumerable]] is false, [[Configurable]] is true) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-347.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-347.js new file mode 100644 index 0000000000..2f1aef5c38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-347.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. + +/*--- +es5id: 15.2.3.6-4-347 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is false) is writable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = (obj.prop === 2010); +obj.prop = 1001; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-348.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-348.js new file mode 100644 index 0000000000..4aadfec3be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-348.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. + +/*--- +es5id: 15.2.3.6-4-348 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is false) is non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.js new file mode 100644 index 0000000000..143606c7a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-349.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. + +/*--- +es5id: 15.2.3.6-4-349 +description: > + ES5 Attributes - property ([[Writable]] is true, [[Enumerable]] is + false, [[Configurable]] is false) is undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); +assert.sameValue(obj.prop, 2010); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-35.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-35.js new file mode 100644 index 0000000000..3d3e33d8db --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-35.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. + +/*--- +es5id: 15.2.3.6-4-35 +description: > + Object.defineProperty - 'O' is a String object which implements + its own [[GetOwnProperty]] method to access the 'name' property + (8.12.9 step 1) +---*/ + +var str = new String("abc"); + +Object.defineProperty(str, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(str, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(str.foo, 12, 'str.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-350.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-350.js new file mode 100644 index 0000000000..aa7e7bbd32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-350.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-350 +description: > + ES5 Attributes - fail to update [[Writable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, true, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-351.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-351.js new file mode 100644 index 0000000000..7febca7766 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-351.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-351 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-352.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-352.js new file mode 100644 index 0000000000..83ef3294c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-352.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-352 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of data + property ([[Writable]] is true, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + configurable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, false, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-353.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-353.js new file mode 100644 index 0000000000..3a0ac2fc30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-353.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-353 +description: > + ES5 Attributes - fail to update the data property ([[Writable]] is + true, [[Enumerable]] is false, [[Configurable]] is false) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: true, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js new file mode 100644 index 0000000000..3e580abc51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-1.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-1 +description: > + Object.defineProperty will update [[Value]] attribute of named + property 'P' successfully when [[Configurable]] attribute is true + and [[Writable]] attribute is false, 'O' is an Object object + (8.12.9 step - Note) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "property", { + value: 1002 +}); + +verifyEqualTo(obj, "property", 1002); + +verifyNotWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js new file mode 100644 index 0000000000..4fa47d892d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-10.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-10 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property 'P' successfully when [[Configurable]] attribute is true + and [[Writable]] attribute is false, 'O' is an Object object + (8.12.9 step - Note) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyNotWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js new file mode 100644 index 0000000000..0f23373bff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-11.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-11 +description: > + Object.defineProperty will update [[Value]] attribute of named + property 'P' successfully when [[Configurable]] attribute is true + and [[Writable]] attribute is false, 'A' is an Array object + (8.12.9 step - Note) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "prop", { + value: 1002 +}); + +verifyEqualTo(obj, "prop", 1002); + +verifyNotWritable(obj, "prop"); + +verifyNotEnumerable(obj, "prop"); + +verifyConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js new file mode 100644 index 0000000000..c301667d62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-12.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-12 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property successfully when [[Configurable]] attribute is true and + [[Writable]] attribute is false, 'O' is an Arguments object + (8.12.9 - step Note) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyNotWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.js new file mode 100644 index 0000000000..42cf188ef5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-15.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. + +/*--- +es5id: 15.2.3.6-4-354-15 +description: > + Object.defineProperty - Named property 'P' with attributes + [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true + is non-writable using simple assignment, 'A' is an Array object +includes: [propertyHelper.js] +---*/ + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.js new file mode 100644 index 0000000000..b5947a8818 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-16.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. + +/*--- +es5id: 15.2.3.6-4-354-16 +description: > + ES5 Attributes - property 'P' is an indexed data property with + attributes [[Writable]]: false, [[Enumerable]]: true, + [[Configurable]] : true) is non-writable using simple assignment, + 'O' is an Arguments object +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); + +assert.sameValue(obj[0], 2010); +verifyNotWritable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js new file mode 100644 index 0000000000..60ef5a8187 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-2.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-2 +description: > + Object.defineProperty will update [[Value]] attribute of indexed + property 'P' successfully when [[Configurable]] attribute is true + and [[Writable]] attribute is false, 'A' is an Array object + (8.12.9 step - Note) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "0", { + value: 1002 +}); + +verifyEqualTo(obj, "0", 1002); + +verifyNotWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js new file mode 100644 index 0000000000..fecfdd55a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-3.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-354-3 +description: > + Object.defineProperty will update [[Value]] attribute successfully + when [[Configurable]] attribute is true and [[Writable]] attribute + is false, 'O' is an Arguments object (8.12.9 - step Note) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "property", { + value: 1001, + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "property", { + value: 1002 +}); + +verifyEqualTo(obj, "property", 1002); + +verifyNotWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.js new file mode 100644 index 0000000000..140bc5b7f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-6.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. + +/*--- +es5id: 15.2.3.6-4-354-6 +description: > + Object.defineProperty - Indexed property 'P' with attributes + [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true + is non-writable using simple assignment, 'A' is an Array object +includes: [propertyHelper.js] +---*/ + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); + +assert.sameValue(obj[0], 2010); +verifyNotWritable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.js new file mode 100644 index 0000000000..31fffa2ee2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354-7.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. + +/*--- +es5id: 15.2.3.6-4-354-7 +description: > + ES5 Attributes - property 'P' with attributes [[Writable]]: false, + [[Enumerable]]: true, [[Configurable]] : true) is non-writable + using simple assignment, 'O' is an Arguments object +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.js new file mode 100644 index 0000000000..dbf15887fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-354.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. + +/*--- +es5id: 15.2.3.6-4-354 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is true) is unwritable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-355.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-355.js new file mode 100644 index 0000000000..764432c18f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-355.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-355 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is true) is enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var property in obj) { + if (property === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-356.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-356.js new file mode 100644 index 0000000000..fd34047c0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-356.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. + +/*--- +es5id: 15.2.3.6-4-356 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is true) is deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var beforeDelete = obj.hasOwnProperty("prop"); +delete obj.prop; +var afterDelete = obj.hasOwnProperty("prop"); + +assert(beforeDelete, 'beforeDelete !== true'); +assert.sameValue(afterDelete, false, 'afterDelete'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-357.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-357.js new file mode 100644 index 0000000000..3d760926ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-357.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-357 +description: > + ES5 Attributes - success to update [[Writable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: true +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, false, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, true, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-358.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-358.js new file mode 100644 index 0000000000..c61f1fe0ac --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-358.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-358 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + data property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-359.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-359.js new file mode 100644 index 0000000000..d7d587f941 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-359.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-359 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + data property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, true, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-36.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-36.js new file mode 100644 index 0000000000..b9a846fa3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-36.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. + +/*--- +es5id: 15.2.3.6-4-36 +description: > + Object.defineProperty - 'O' is a Boolean object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var obj = new Boolean(true); + +Object.defineProperty(obj, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(obj.foo, 12, 'obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-1.js new file mode 100644 index 0000000000..0cc765ee6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-1.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-360-1 +description: > + ES5 Attributes - Updating indexed data property 'P' whose + attributes are [[Writable]]: false, [[Enumerable]]: true, + [[Configurable]]: true to an accessor property, 'A' is an Array + object (8.12.9 - step 9.b.i) +---*/ + +var obj = []; + +Object.defineProperty(obj, "0", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "0", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); +assert.sameValue(desc2.configurable, true, 'desc2.configurable'); +assert.sameValue(obj[0], 20, 'obj[0]'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-2.js new file mode 100644 index 0000000000..f7f96bdc52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-2.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-360-2 +description: > + ES5 Attributes - Updating data property 'P' whose attributes are + [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true + to an accessor property, 'O' is an Arguments object (8.12.9 - step + 9.b.i) +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); +assert.sameValue(desc2.configurable, true, 'desc2.configurable'); +assert.sameValue(obj.prop, 20, 'obj.prop'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-5.js new file mode 100644 index 0000000000..bcd2213f2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-5.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-360-5 +description: > + ES5 Attributes - Updating named data property 'P' whose attributes + are [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: + true to an accessor property, 'A' is an Array object (8.12.9 - + step 9.b.i) +---*/ + +var obj = []; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); +assert.sameValue(desc2.configurable, true, 'desc2.configurable'); +assert.sameValue(obj.prop, 20, 'obj.prop'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-6.js new file mode 100644 index 0000000000..96e5b4e3b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360-6.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-360-6 +description: > + ES5 Attributes - Updating indexed data property 'P' whose + attributes are [[Writable]]: false, [[Enumerable]]: true, + [[Configurable]]: true to an accessor property, 'O' is an + Arguments object (8.12.9 - step 9.b.i) +---*/ + +var obj = (function() { + return arguments; +}()); + +Object.defineProperty(obj, "0", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "0", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); +assert.sameValue(desc2.configurable, true, 'desc2.configurable'); +assert.sameValue(obj[0], 20, 'obj[0]'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360.js new file mode 100644 index 0000000000..b0975e43e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-360.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-360 +description: > + ES5 Attributes - success to update the data property ([[Writable]] + is false, [[Enumerable]] is true, [[Configurable]] is true) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert(desc2.hasOwnProperty("get"), 'desc2.hasOwnProperty("get") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.js new file mode 100644 index 0000000000..ddaf657cd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-361.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. + +/*--- +es5id: 15.2.3.6-4-361 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is false) is unwritable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-362.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-362.js new file mode 100644 index 0000000000..794aeb4686 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-362.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-362 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is false) is enumerable +---*/ + +var propertyFound = false; + +var obj = {}; +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var property in obj) { + if (property === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.js new file mode 100644 index 0000000000..5eb3404f36 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-363.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. + +/*--- +es5id: 15.2.3.6-4-363 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is true, [[Configurable]] is false) is undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-364.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-364.js new file mode 100644 index 0000000000..06b1ec0dfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-364.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-364 +description: > + ES5 Attributes - fail to update [[Writable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + writable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, false, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-365.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-365.js new file mode 100644 index 0000000000..d7fc88a3f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-365.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-365 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-366.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-366.js new file mode 100644 index 0000000000..606e968895 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-366.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-366 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is true, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + configurable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, false, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-367.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-367.js new file mode 100644 index 0000000000..446290d074 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-367.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-367 +description: > + ES5 Attributes - fail to update the data property ([[Writable]] is + false, [[Enumerable]] is true, [[Configurable]] is false) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: true, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.js new file mode 100644 index 0000000000..1faaa98d37 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-368.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. + +/*--- +es5id: 15.2.3.6-4-368 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is true) is unwritable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-369.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-369.js new file mode 100644 index 0000000000..60bfa0086a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-369.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. + +/*--- +es5id: 15.2.3.6-4-369 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is true) is non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-37.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-37.js new file mode 100644 index 0000000000..fe557c7dac --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-37.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. + +/*--- +es5id: 15.2.3.6-4-37 +description: > + Object.defineProperty - 'O' is a Number object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var obj = new Number(-2); + +Object.defineProperty(obj, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(obj.foo, 12, 'obj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-370.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-370.js new file mode 100644 index 0000000000..1b0ad6b0a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-370.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. + +/*--- +es5id: 15.2.3.6-4-370 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is true) is deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var beforeDelete = obj.hasOwnProperty("prop"); +delete obj.prop; +var afterDelete = obj.hasOwnProperty("prop"); + +assert(beforeDelete, 'beforeDelete !== true'); +assert.sameValue(afterDelete, false, 'afterDelete'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-371.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-371.js new file mode 100644 index 0000000000..12585ce6f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-371.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-371 +description: > + ES5 Attributes - success to update [[Writable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + writable: true +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, false, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, true, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-372.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-372.js new file mode 100644 index 0000000000..2fd3b8b4d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-372.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-372 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + data property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-373.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-373.js new file mode 100644 index 0000000000..9ff4a194e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-373.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-373 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + data property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is true) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, true, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-374.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-374.js new file mode 100644 index 0000000000..ea1bb48679 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-374.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-374 +description: > + ES5 Attributes - success to update the data property ([[Writable]] + is false, [[Enumerable]] is false, [[Configurable]] is true) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("value"), 'desc1.hasOwnProperty("value") !== true'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.js new file mode 100644 index 0000000000..b41c9513e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-375.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. + +/*--- +es5id: 15.2.3.6-4-375 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is false) is unwritable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); + +assert.sameValue(obj.prop, 2010); +verifyNotWritable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-376.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-376.js new file mode 100644 index 0000000000..fa2805314c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-376.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. + +/*--- +es5id: 15.2.3.6-4-376 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is false) is non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.js new file mode 100644 index 0000000000..efd2e54659 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-377.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. + +/*--- +es5id: 15.2.3.6-4-377 +description: > + ES5 Attributes - property ([[Writable]] is false, [[Enumerable]] + is false, [[Configurable]] is false) is undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-378.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-378.js new file mode 100644 index 0000000000..afde24d570 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-378.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-378 +description: > + ES5 Attributes - fail to update [[Writable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + writable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.writable, false, 'desc1.writable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.writable, false, 'desc2.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-379.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-379.js new file mode 100644 index 0000000000..cbb72d6f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-379.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-379 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js new file mode 100644 index 0000000000..f40b4f152a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-38.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-38 +description: > + Object.defineProperty - 'O' is the Math object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +includes: [propertyHelper.js] +---*/ + +try { + Object.defineProperty(Math, "foo", { + value: 12, + configurable: true + }); + + verifyEqualTo(Math, "foo", 12); + + verifyNotWritable(Math, "foo"); + + verifyNotEnumerable(Math, "foo"); + + verifyConfigurable(Math, "foo"); +} finally { + delete Math.foo; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-380.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-380.js new file mode 100644 index 0000000000..9dde066977 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-380.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-380 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of data + property ([[Writable]] is false, [[Enumerable]] is false, + [[Configurable]] is false) to different value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + configurable: true + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.configurable, false, 'desc1.configurable'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc2.configurable, false, 'desc2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-381.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-381.js new file mode 100644 index 0000000000..2efd739d82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-381.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-381 +description: > + ES5 Attributes - fail to update the data property ([[Writable]] is + false, [[Enumerable]] is false, [[Configurable]] is false) to an + accessor property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 2010, + writable: false, + enumerable: false, + configurable: false +}); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +function getFunc() { + return 20; +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc1.value, 2010, 'desc1.value'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-382.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-382.js new file mode 100644 index 0000000000..37efe23714 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-382.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: 15.2.3.6-4-382 +description: ES5 Attributes - [[Value]] attribute of data property is a number +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: 1001 +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, 1001, 'obj.prop'); +assert.sameValue(desc.value, 1001, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-383.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-383.js new file mode 100644 index 0000000000..05dc316613 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-383.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: 15.2.3.6-4-383 +description: ES5 Attributes - [[Value]] attribute of data property is a string +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: "ThisIsAString" +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, "ThisIsAString", 'obj.prop'); +assert.sameValue(desc.value, "ThisIsAString", 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-384.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-384.js new file mode 100644 index 0000000000..57719e51b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-384.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: 15.2.3.6-4-384 +description: ES5 Attributes - [[Value]] attribute of data property is a boolean +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: false +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, false, 'obj.prop'); +assert.sameValue(desc.value, false, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-385.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-385.js new file mode 100644 index 0000000000..dfffe80f88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-385.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. + +/*--- +es5id: 15.2.3.6-4-385 +description: > + ES5 Attributes - [[Value]] attribute of data property is a generic + object +---*/ + +var obj = {}; +var tempObj = { + testproperty: 100 +}; + +Object.defineProperty(obj, "prop", { + value: tempObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, tempObj, 'obj.prop'); +assert.sameValue(desc.value, tempObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-386.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-386.js new file mode 100644 index 0000000000..911752dcff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-386.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. + +/*--- +es5id: 15.2.3.6-4-386 +description: > + ES5 Attributes - [[Value]] attribute of data property is an Array + object +---*/ + +var obj = {}; +var arrObj = []; + +Object.defineProperty(obj, "prop", { + value: arrObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, arrObj, 'obj.prop'); +assert.sameValue(desc.value, arrObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-387.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-387.js new file mode 100644 index 0000000000..45ecb3f669 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-387.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. + +/*--- +es5id: 15.2.3.6-4-387 +description: > + ES5 Attributes - [[Value]] attribute of data property is a String + object +---*/ + +var obj = {}; +var strObj = new String(); + +Object.defineProperty(obj, "prop", { + value: strObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, strObj, 'obj.prop'); +assert.sameValue(desc.value, strObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-388.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-388.js new file mode 100644 index 0000000000..bf9546b71a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-388.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. + +/*--- +es5id: 15.2.3.6-4-388 +description: > + ES5 Attributes - [[Value]] attribute of data property is a Number + object +---*/ + +var obj = {}; +var numObj = new Number(); + +Object.defineProperty(obj, "prop", { + value: numObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, numObj, 'obj.prop'); +assert.sameValue(desc.value, numObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-389.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-389.js new file mode 100644 index 0000000000..7182ddfb85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-389.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. + +/*--- +es5id: 15.2.3.6-4-389 +description: > + ES5 Attributes - [[Value]] attribute of data property is a Boolean + Object +---*/ + +var obj = {}; +var boolObj = new Boolean(); + +Object.defineProperty(obj, "prop", { + value: boolObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, boolObj, 'obj.prop'); +assert.sameValue(desc.value, boolObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-39.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-39.js new file mode 100644 index 0000000000..4a8721990d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-39.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. + +/*--- +es5id: 15.2.3.6-4-39 +description: > + Object.defineProperty - 'O' is a Date object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var desc = new Date(); + +Object.defineProperty(desc, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(desc, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(desc.foo, 12, 'desc.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-390.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-390.js new file mode 100644 index 0000000000..c80f3724bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-390.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. + +/*--- +es5id: 15.2.3.6-4-390 +description: > + ES5 Attributes - [[Value]] attribute of data property is a + Function object +---*/ + +var obj = {}; +var funObj = function() {}; + +Object.defineProperty(obj, "prop", { + value: funObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, funObj, 'obj.prop'); +assert.sameValue(desc.value, funObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-391.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-391.js new file mode 100644 index 0000000000..584e8844af --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-391.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. + +/*--- +es5id: 15.2.3.6-4-391 +description: > + ES5 Attributes - [[Value]] attribute of data property is an Error + object +---*/ + +var obj = {}; +var errObj = new Error(); + +Object.defineProperty(obj, "prop", { + value: errObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, errObj, 'obj.prop'); +assert.sameValue(desc.value, errObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-392.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-392.js new file mode 100644 index 0000000000..268812cbc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-392.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. + +/*--- +es5id: 15.2.3.6-4-392 +description: > + ES5 Attributes - [[Value]] attribute of data property is a Date + object +---*/ + +var obj = {}; +var dateObj = new Date(); + +Object.defineProperty(obj, "prop", { + value: dateObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, dateObj, 'obj.prop'); +assert.sameValue(desc.value, dateObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-393.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-393.js new file mode 100644 index 0000000000..5eaa735152 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-393.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. + +/*--- +es5id: 15.2.3.6-4-393 +description: > + ES5 Attributes - [[Value]] attribute of data property is a RegExp + object +---*/ + +var obj = {}; +var regObj = new RegExp(); + +Object.defineProperty(obj, "prop", { + value: regObj +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, regObj, 'obj.prop'); +assert.sameValue(desc.value, regObj, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-394.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-394.js new file mode 100644 index 0000000000..16f70bb333 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-394.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. + +/*--- +es5id: 15.2.3.6-4-394 +description: ES5 Attributes - [[Value]] attribute of data property is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: undefined +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(typeof obj.prop, "undefined", 'typeof obj.prop'); +assert.sameValue(typeof desc.value, "undefined", 'typeof desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-395.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-395.js new file mode 100644 index 0000000000..4354960ae5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-395.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: 15.2.3.6-4-395 +description: ES5 Attributes - [[Value]] attribute of data property is null +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: null +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, null, 'obj.prop'); +assert.sameValue(desc.value, null, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-396.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-396.js new file mode 100644 index 0000000000..4ad3723e6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-396.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: 15.2.3.6-4-396 +description: ES5 Attributes - [[Value]] attribute of data property is NaN +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: NaN +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.prop !== obj.prop, 'obj.prop !== obj.prop !== true'); +assert(desc.value !== desc.value, 'desc.value !== desc.value !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-397.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-397.js new file mode 100644 index 0000000000..b6d89afb23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-397.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: 15.2.3.6-4-397 +description: ES5 Attributes - [[Value]] attribute of data property is Infinity +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: Infinity +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, Infinity, 'obj.prop'); +assert.sameValue(desc.value, Infinity, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-398.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-398.js new file mode 100644 index 0000000000..2665cf01b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-398.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: 15.2.3.6-4-398 +description: ES5 Attributes - [[Value]] attribute of data property is -Infinity +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: -Infinity +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, -Infinity, 'obj.prop'); +assert.sameValue(desc.value, -Infinity, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-399.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-399.js new file mode 100644 index 0000000000..97c6c7a46e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-399.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: 15.2.3.6-4-399 +description: > + ES5 Attributes - [[Value]] attribute of data property is the + global object +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + value: this +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(obj.prop, this, 'obj.prop'); +assert.sameValue(desc.value, this, 'desc.value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-4.js new file mode 100644 index 0000000000..80c9d3afd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-4.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: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. For newly defined properties, step 4.a.1 of + [[DefineOwnProperty]] creates a data property if handed a generic desc. +es5id: 15.2.3.6-4-4 +description: > + Object.defineProperty defines a data property if given a generic + desc(8.12.9 step 4.a.i) +---*/ + +var o = {}; + +var desc = {}; +Object.defineProperty(o, "foo", desc); + +var propDesc = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(propDesc.value, undefined, 'propDesc.value'); // undefined by default +assert.sameValue(propDesc.writable, false, 'propDesc.writable'); // false by default +assert.sameValue(propDesc.enumerable, false, 'propDesc.enumerable'); // false by default +assert.sameValue(propDesc.configurable, false, 'propDesc.configurable'); // false by default + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-40.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-40.js new file mode 100644 index 0000000000..7418b9cb59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-40.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. + +/*--- +es5id: 15.2.3.6-4-40 +description: > + Object.defineProperty - 'O' is a RegExp object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var desc = new RegExp(); + +Object.defineProperty(desc, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(desc, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(desc.foo, 12, 'desc.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-402.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-402.js new file mode 100644 index 0000000000..f4eac07a1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-402.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: 15.2.3.6-4-402 +description: > + ES5 Attributes - [[Value]] attribute of inherited property of + [[Prototype]] internal property is correct (String instance) +---*/ + +Object.defineProperty(String.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var strObj = new String(); + +assert.sameValue(strObj.hasOwnProperty("prop"), false, 'strObj.hasOwnProperty("prop")'); +assert.sameValue(strObj.prop, 1001, 'strObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-403.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-403.js new file mode 100644 index 0000000000..f2161ad8dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-403.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. + +/*--- +es5id: 15.2.3.6-4-403 +description: > + ES5 Attributes - Successfully add a property to an object when the + object's prototype has a property with same name and [[Writable]] + attribute is set to true (Array instance) +---*/ + +Object.defineProperty(Array.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var arrObj = []; +arrObj.prop = 1002; + +assert(arrObj.hasOwnProperty("prop"), 'arrObj.hasOwnProperty("prop") !== true'); +assert.sameValue(arrObj.prop, 1002, 'arrObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-404.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-404.js new file mode 100644 index 0000000000..9726c27754 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-404.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-404 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to true is enumerable (Boolean instance) +---*/ + +Object.defineProperty(Boolean.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var boolObj = new Boolean(); + +var verifyEnumerable = false; +for (var p in boolObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(boolObj.hasOwnProperty("prop"), false, 'boolObj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-405.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-405.js new file mode 100644 index 0000000000..d5b183c72c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-405.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. + +/*--- +es5id: 15.2.3.6-4-405 +description: > + ES5 Attributes - Failed to add a property to an object when the + object's object has a property with same name and [[Writable]] + attribute is set to false (Number instance) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(Number.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); + +var numObj = new Number(); + +assert(!numObj.hasOwnProperty("prop")); +verifyNotWritable(numObj, "prop", "noCheckOwnProp"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-406.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-406.js new file mode 100644 index 0000000000..78a9e6fef8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-406.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-406 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to false is non-enumerable (Function instance) +---*/ + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); +var funObj = function() {}; + +var verifyEnumerable = false; +for (var p in funObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(funObj.hasOwnProperty("prop"), false, 'funObj.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-407.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-407.js new file mode 100644 index 0000000000..d901d82656 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-407.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: 15.2.3.6-4-407 +description: > + ES5 Attributes - [[Value]] attribute of inherited property of + [[Prototype]] internal property is correct (Error Instance) +---*/ + +Object.defineProperty(Error.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var errObj = new Error(); + +assert.sameValue(errObj.hasOwnProperty("prop"), false, 'errObj.hasOwnProperty("prop")'); +assert.sameValue(errObj.prop, 1001, 'errObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-408.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-408.js new file mode 100644 index 0000000000..30f7518af8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-408.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. + +/*--- +es5id: 15.2.3.6-4-408 +description: > + ES5 Attributes - Successfully add a property to an object when the + object's prototype has a property with same name and [[Writable]] + attribute is set to true (Date instance) +---*/ + +Object.defineProperty(Date.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var dateObj = new Date(); +dateObj.prop = 1002; + +assert(dateObj.hasOwnProperty("prop"), 'dateObj.hasOwnProperty("prop") !== true'); +assert.sameValue(dateObj.prop, 1002, 'dateObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-409.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-409.js new file mode 100644 index 0000000000..16a04628f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-409.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-409 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to false is enumerable (RegExp instance) +---*/ + +Object.defineProperty(RegExp.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +var regObj = new RegExp(); + +var verifyEnumerable = false; +for (var p in regObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(regObj.hasOwnProperty("prop"), false, 'regObj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js new file mode 100644 index 0000000000..e69119a145 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-41.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-41 +description: > + Object.defineProperty - 'O' is the JSON object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +includes: [propertyHelper.js] +---*/ + + +Object.defineProperty(JSON, "foo", { + value: 12, + configurable: true +}); + +verifyEqualTo(JSON, "foo", 12); + +verifyNotWritable(JSON, "foo"); + +verifyNotEnumerable(JSON, "foo"); + +verifyConfigurable(JSON, "foo"); + +delete JSON.foo; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-410.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-410.js new file mode 100644 index 0000000000..7d7d0aa713 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-410.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. + +/*--- +es5id: 15.2.3.6-4-410 +description: > + ES5 Attributes - Failed to add a property to an object when the + object's prototype has a property with the same name and + [[Writable]] set to false (JSON) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(Object.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); + +assert(!JSON.hasOwnProperty("prop")); +verifyNotWritable(JSON, "prop", "noCheckOwnProp"); +assert.sameValue(JSON.prop, 1001); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-411.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-411.js new file mode 100644 index 0000000000..20e5a656c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-411.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. + +/*--- +es5id: 15.2.3.6-4-411 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to false is non-enumerable (Math) +---*/ + +Object.defineProperty(Object.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); + +var verifyEnumerable = false; +for (var p in Math) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(Math.hasOwnProperty("prop"), false, 'Math.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-412.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-412.js new file mode 100644 index 0000000000..337eb067c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-412.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-412 +description: > + ES5 Attributes - [[Value]] field of inherited property of + [[Prototype]] internal property is correct(Object.create) +---*/ + +var appointment = {}; + +Object.defineProperty(appointment, "startTime", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +Object.defineProperty(appointment, "name", { + value: "NAME", + writable: true, + enumerable: true, + configurable: true +}); + +var meeting = Object.create(appointment); +Object.defineProperty(meeting, "conferenceCall", { + value: "In-person meeting", + writable: true, + enumerable: true, + configurable: true +}); + +var teamMeeting = Object.create(meeting); + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(teamMeeting.name, "NAME", 'teamMeeting.name'); +assert.sameValue(teamMeeting.startTime, 1001, 'teamMeeting.startTime'); +assert.sameValue(teamMeeting.conferenceCall, "In-person meeting", 'teamMeeting.conferenceCall'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-413.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-413.js new file mode 100644 index 0000000000..f801ed76af --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-413.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-413 +description: > + ES5 Attributes - Successfully add a property to an object when the + object's prototype has a property with the same name and + [[Writable]] set to true (Object.create) +---*/ + +var appointment = {}; + +Object.defineProperty(appointment, "startTime", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +Object.defineProperty(appointment, "name", { + value: "NAME", + writable: true, + enumerable: true, + configurable: true +}); + +var meeting = Object.create(appointment); +Object.defineProperty(meeting, "conferenceCall", { + value: "In-person meeting", + writable: true, + enumerable: true, + configurable: true +}); + +var teamMeeting = Object.create(meeting); +teamMeeting.name = "Team Meeting"; +var dateObj = new Date("10/31/2010 08:00"); +teamMeeting.startTime = dateObj; +teamMeeting.conferenceCall = "4255551212"; + +var hasOwnProperty = teamMeeting.hasOwnProperty("name") && + teamMeeting.hasOwnProperty("startTime") && + teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(teamMeeting.name, "Team Meeting", 'teamMeeting.name'); +assert.sameValue(teamMeeting.startTime, dateObj, 'teamMeeting.startTime'); +assert.sameValue(teamMeeting.conferenceCall, "4255551212", 'teamMeeting.conferenceCall'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-414.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-414.js new file mode 100644 index 0000000000..945ecf7f1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-414.js @@ -0,0 +1,60 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-414 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to true is enumerable (Object.create) +---*/ + +var appointment = new Object(); + +Object.defineProperty(appointment, "startTime", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); +Object.defineProperty(appointment, "name", { + value: "NAME", + writable: true, + enumerable: true, + configurable: true +}); + +var meeting = Object.create(appointment); +Object.defineProperty(meeting, "conferenceCall", { + value: "In-person meeting", + writable: true, + enumerable: true, + configurable: true +}); + +var teamMeeting = Object.create(meeting); + +var verifyTimeProp = false; +var verifyNameProp = false; +var verifyCallProp = false; +for (var p in teamMeeting) { + if (p === "startTime") { + verifyTimeProp = true; + } + if (p === "name") { + verifyNameProp = true; + } + if (p === "conferenceCall") { + verifyCallProp = true; + } +} + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty("conferenceCall"); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert(verifyTimeProp, 'verifyTimeProp !== true'); +assert(verifyNameProp, 'verifyNameProp !== true'); +assert(verifyCallProp, 'verifyCallProp !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-415.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-415.js new file mode 100644 index 0000000000..00559f4a49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-415.js @@ -0,0 +1,56 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-415 +description: > + ES5 Attributes - Failed to add properties to an object when the + object's prototype has properties with the same name and + [[Writable]] set to false (Object.create) +includes: [propertyHelper.js] +---*/ + +var appointment = new Object(); + +Object.defineProperty(appointment, "startTime", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); +Object.defineProperty(appointment, "name", { + value: "NAME", + writable: false, + enumerable: false, + configurable: true +}); + +var meeting = Object.create(appointment); +Object.defineProperty(meeting, "conferenceCall", { + value: "In-person meeting", + writable: false, + enumerable: false, + configurable: true +}); + +var teamMeeting = Object.create(meeting); + +//teamMeeting.name = "Team Meeting"; +verifyNotWritable(teamMeeting, "name", "noCheckOwnProp"); + +var dateObj = new Date("10/31/2010 08:00"); +//teamMeeting.startTime = dateObj; +verifyNotWritable(teamMeeting, "startTime", "noCheckOwnProp"); + +//teamMeeting.conferenceCall = "4255551212"; +verifyNotWritable(teamMeeting, "conferenceCall", "noCheckOwnProp"); + +assert(!teamMeeting.hasOwnProperty("name")); +assert(!teamMeeting.hasOwnProperty("startTime")); +assert(!teamMeeting.hasOwnProperty('conferenceCall')); + +assert.sameValue(teamMeeting.name, "NAME"); +assert.sameValue(teamMeeting.startTime, 1001); +assert.sameValue(teamMeeting.conferenceCall, "In-person meeting"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-416.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-416.js new file mode 100644 index 0000000000..4f805ea994 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-416.js @@ -0,0 +1,60 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-416 +description: > + ES5 Attributes - Inherited properties whose [[Enumerable]] + attribute is set to false is non-enumerable (Object.create) +---*/ + +var appointment = {}; + +Object.defineProperty(appointment, "startTime", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); +Object.defineProperty(appointment, "name", { + value: "NAME", + writable: false, + enumerable: false, + configurable: true +}); + +var meeting = Object.create(appointment); +Object.defineProperty(meeting, "conferenceCall", { + value: "In-person meeting", + writable: false, + enumerable: false, + configurable: true +}); + +var teamMeeting = Object.create(meeting); + +var verifyTimeProp = false; +var verifyNameProp = false; +var verifyCallProp = false; +for (var p in teamMeeting) { + if (p === "startTime") { + verifyTimeProp = true; + } + if (p === "name") { + verifyNameProp = true; + } + if (p === "conferenceCall") { + verifyCallProp = true; + } +} + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty("conferenceCall"); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(verifyTimeProp, false, 'verifyTimeProp'); +assert.sameValue(verifyNameProp, false, 'verifyNameProp'); +assert.sameValue(verifyCallProp, false, 'verifyCallProp'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-417.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-417.js new file mode 100644 index 0000000000..d80d9e5536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-417.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. + +/*--- +es5id: 15.2.3.6-4-417 +description: > + ES5 Attributes - [[Value]] attribute of inherited property of + [[Prototype]] internal property is correct(Function.prototype.bind) +---*/ + +var foo = function() {}; + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-418.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-418.js new file mode 100644 index 0000000000..903bcd610c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-418.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. + +/*--- +es5id: 15.2.3.6-4-418 +description: > + ES5 Attributes - Successfully add a property to an object when the + object's prototype has a property with the same name and + [[Writable]] set to true (Function.prototype.bind) +---*/ + +var foo = function() {}; + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); +obj.prop = 1002; + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, 1002, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-419.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-419.js new file mode 100644 index 0000000000..f952af15d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-419.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-419 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to true is enumerable (Function.prototype.bind) +---*/ + +var foo = function() {}; + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); +var verifyEnumerable = false; +for (var p in obj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-42.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-42.js new file mode 100644 index 0000000000..194bc8cbeb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-42.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. + +/*--- +es5id: 15.2.3.6-4-42 +description: > + Object.defineProperty - 'O' is an Error object that uses Object's + [[GetOwnProperty]] method to access the 'name' property (8.12.9 + step 1) +---*/ + +var desc = new Error(); + +Object.defineProperty(desc, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(desc, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(desc.foo, 12, 'desc.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-420.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-420.js new file mode 100644 index 0000000000..0fe1d6bd55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-420.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. + +/*--- +es5id: 15.2.3.6-4-420 +description: > + ES5 Attributes - Failed to add a property to an object when the + object's prototype has a property with the same name and + [[Writable]] set to false(Function.prototype.bind) +includes: [propertyHelper.js] +---*/ + +var foo = function() {}; + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); + +var obj = foo.bind({}); +assert(!obj.hasOwnProperty("prop")); +verifyNotWritable(foo, "prop", "noCheckOwnProp"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-421.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-421.js new file mode 100644 index 0000000000..e6da6e0502 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-421.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-421 +description: > + ES5 Attributes - Inherited property whose [[Enumerable]] attribute + is set to false is non-enumerable (Function.prototype.bind) +---*/ + +var foo = function() {}; + +Object.defineProperty(Function.prototype, "prop", { + value: 1001, + writable: false, + enumerable: false, + configurable: true +}); + +var obj = foo.bind({}); +var verifyEnumerable = false; +for (var p in obj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-422.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-422.js new file mode 100644 index 0000000000..f03715acec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-422.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. + +/*--- +es5id: 15.2.3.6-4-422 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-423.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-423.js new file mode 100644 index 0000000000..93bb685cb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-423.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. + +/*--- +es5id: 15.2.3.6-4-423 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-424.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-424.js new file mode 100644 index 0000000000..6b6b262c6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-424.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-424 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is true) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-425.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-425.js new file mode 100644 index 0000000000..643211086a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-425.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-425 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-426.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-426.js new file mode 100644 index 0000000000..fa65a961d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-426.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-426 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-427.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-427.js new file mode 100644 index 0000000000..a5310d9f12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-427.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-427 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-428.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-428.js new file mode 100644 index 0000000000..98084ff284 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-428.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-428 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js new file mode 100644 index 0000000000..1484ccd385 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-429.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-429 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +verifyNotConfigurable(obj, "prop"); +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-43.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-43.js new file mode 100644 index 0000000000..2220be851e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-43.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. + +/*--- +es5id: 15.2.3.6-4-43 +description: > + Object.defineProperty - 'O' is an Arguments object which + implements its own [[GetOwnProperty]] method to access the 'name' + property (8.12.9 step 1) +---*/ + +var argObj = (function() { + return arguments; +})(); + +Object.defineProperty(argObj, "foo", { + value: 12, + configurable: false +}); +assert.throws(TypeError, function() { + Object.defineProperty(argObj, "foo", { + value: 11, + configurable: true + }); +}); +assert.sameValue(argObj.foo, 12, 'argObj.foo'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-430.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-430.js new file mode 100644 index 0000000000..d2260d4c56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-430.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-430 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-431.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-431.js new file mode 100644 index 0000000000..da5a96c214 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-431.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. + +/*--- +es5id: 15.2.3.6-4-431 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-432.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-432.js new file mode 100644 index 0000000000..fc0e43f328 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-432.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. + +/*--- +es5id: 15.2.3.6-4-432 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-433.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-433.js new file mode 100644 index 0000000000..57c7e9f6d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-433.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-433 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is false) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js new file mode 100644 index 0000000000..0c278f09b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-434.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-434 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-435.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-435.js new file mode 100644 index 0000000000..f3068b86f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-435.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-435 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-436.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-436.js new file mode 100644 index 0000000000..f7620105c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-436.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-436 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: setFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-437.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-437.js new file mode 100644 index 0000000000..f9336196bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-437.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-437 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js new file mode 100644 index 0000000000..ccf6b3d0aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-438.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-438 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-439.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-439.js new file mode 100644 index 0000000000..71cd1da584 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-439.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-439 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + undefined, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-440.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-440.js new file mode 100644 index 0000000000..97b98b0c39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-440.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. + +/*--- +es5id: 15.2.3.6-4-440 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-441.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-441.js new file mode 100644 index 0000000000..a4495cc980 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-441.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. + +/*--- +es5id: 15.2.3.6-4-441 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-442.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-442.js new file mode 100644 index 0000000000..c9eb02984f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-442.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-442 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is true) is + non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-443.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-443.js new file mode 100644 index 0000000000..28d39c1995 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-443.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-443 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-444.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-444.js new file mode 100644 index 0000000000..2c637ffcdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-444.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-444 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-445.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-445.js new file mode 100644 index 0000000000..e570581612 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-445.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-445 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +obj.prop = "overrideData"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-446.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-446.js new file mode 100644 index 0000000000..944fd5226f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-446.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-446 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js new file mode 100644 index 0000000000..e7580caeb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-447.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-447 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); + +verifyNotConfigurable(obj, "prop"); +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-448.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-448.js new file mode 100644 index 0000000000..b3e27acfc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-448.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-448 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-449.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-449.js new file mode 100644 index 0000000000..3949afee2b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-449.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. + +/*--- +es5id: 15.2.3.6-4-449 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.js new file mode 100644 index 0000000000..65701f6c78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-45.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. + +/*--- +es5id: 15.2.3.6-4-45 +description: > + Object.defineProperty - 'O' is the global object that uses + Object's [[GetOwnProperty]] method to access the 'name' property + (8.12.9 step 1) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(this, "foo", { + value: 12, + configurable: true +}); + +verifyEqualTo(this, "foo", 12); + +verifyNotWritable(this, "foo"); + +verifyNotEnumerable(this, "foo"); + +verifyConfigurable(this, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-450.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-450.js new file mode 100644 index 0000000000..3ccbac0cab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-450.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. + +/*--- +es5id: 15.2.3.6-4-450 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-451.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-451.js new file mode 100644 index 0000000000..ac6f1cada0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-451.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-451 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is false) is + non-enumerable +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js new file mode 100644 index 0000000000..d099d78495 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-452.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-452 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-453.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-453.js new file mode 100644 index 0000000000..27c637f5b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-453.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-453 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-454.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-454.js new file mode 100644 index 0000000000..5a0ef65a4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-454.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-454 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: setFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-455.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-455.js new file mode 100644 index 0000000000..9d66f0ac7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-455.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-455 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js new file mode 100644 index 0000000000..da9397f14d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-456.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-456 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-457.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-457.js new file mode 100644 index 0000000000..e731f2415e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-457.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-457 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + undefined, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: undefined, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-458.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-458.js new file mode 100644 index 0000000000..94f200aa09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-458.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. + +/*--- +es5id: 15.2.3.6-4-458 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-459.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-459.js new file mode 100644 index 0000000000..cb36fd924b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-459.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-459 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-46.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-46.js new file mode 100644 index 0000000000..118d1e3aa7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-46.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. + +/*--- +es5id: 15.2.3.6-4-46 +description: > + Object.defineProperty - 'name' is defined as data property if + 'name' property doesn't exist in 'O' and 'desc' is generic + descriptor (8.12.9 step 4.a) +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + enumerable: true +}); + +var isEnumerable = false; +for (var item in obj) { + if (obj.hasOwnProperty(item) && item === "property") { + isEnumerable = true; + } +} + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert(isEnumerable, 'isEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-460.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-460.js new file mode 100644 index 0000000000..d7245811e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-460.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-460 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is true) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-461.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-461.js new file mode 100644 index 0000000000..d7ef8ccb29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-461.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-461 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-462.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-462.js new file mode 100644 index 0000000000..fbca9ced97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-462.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-462 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-463.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-463.js new file mode 100644 index 0000000000..5dd3a15b54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-463.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-463 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: undefined +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-464.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-464.js new file mode 100644 index 0000000000..28c41b7b0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-464.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-464 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); + +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js new file mode 100644 index 0000000000..6ff40b2cc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-465.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-465 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); + +verifyNotConfigurable(obj, "prop"); +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-466.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-466.js new file mode 100644 index 0000000000..b8a679e7c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-466.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-466 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-467.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-467.js new file mode 100644 index 0000000000..28c68afe75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-467.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. + +/*--- +es5id: 15.2.3.6-4-467 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-468.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-468.js new file mode 100644 index 0000000000..0eb09dac55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-468.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-468 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-469.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-469.js new file mode 100644 index 0000000000..46f2175924 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-469.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-469 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is false) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js new file mode 100644 index 0000000000..4b8fd1bf7f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-47.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-47 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', + [[Value]] of 'name' property is set as undefined if it is absent + in data descriptor 'desc' (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + writable: true, + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "property", undefined); + +verifyWritable(obj, "property"); + +verifyEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js new file mode 100644 index 0000000000..39b025006b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-470.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-470 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +verifyNotWritable(obj, "prop"); +verifyNotConfigurable(obj, "prop"); + +assert.sameValue(desc.configurable, false); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-471.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-471.js new file mode 100644 index 0000000000..f3373dc3e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-471.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-471 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-472.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-472.js new file mode 100644 index 0000000000..53788647fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-472.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-472 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: undefined + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-473.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-473.js new file mode 100644 index 0000000000..0e1914d48d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-473.js @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-473 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); + +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js new file mode 100644 index 0000000000..ce3fa250dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-474.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-474 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-475.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-475.js new file mode 100644 index 0000000000..50e7f6a007 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-475.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-475 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + undefined, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-476.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-476.js new file mode 100644 index 0000000000..f30f03e397 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-476.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. + +/*--- +es5id: 15.2.3.6-4-476 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-477.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-477.js new file mode 100644 index 0000000000..d44370130c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-477.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-477 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-478.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-478.js new file mode 100644 index 0000000000..9677d58ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-478.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-478 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is true) is + non-enumerable +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-479.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-479.js new file mode 100644 index 0000000000..fddbd21f2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-479.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-479 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js new file mode 100644 index 0000000000..1dcf25ea46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-48.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-48 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Writable]] of 'name' property of 'Attributes' is set as false + value if absent in data descriptor 'desc' (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 1001, + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "property", 1001); + +verifyNotWritable(obj, "property"); + +verifyEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-480.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-480.js new file mode 100644 index 0000000000..c488ae9a2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-480.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-480 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-481.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-481.js new file mode 100644 index 0000000000..fe8c7eba0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-481.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-481 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: undefined +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-482.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-482.js new file mode 100644 index 0000000000..db87e9a238 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-482.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-482 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); + +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js new file mode 100644 index 0000000000..118a8aac10 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-483.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-483 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-484.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-484.js new file mode 100644 index 0000000000..54c080d470 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-484.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-484 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-485.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-485.js new file mode 100644 index 0000000000..ba7c8b29db --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-485.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. + +/*--- +es5id: 15.2.3.6-4-485 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.get, "undefined", 'typeof desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-486.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-486.js new file mode 100644 index 0000000000..6ea9594ad3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-486.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-486 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-487.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-487.js new file mode 100644 index 0000000000..a5b5b747fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-487.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-487 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is false) is + non-enumerable +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js new file mode 100644 index 0000000000..0785a3996e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-488.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-488 +description: > + ES5 Attributes - property ([[Get]] is undefined, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +verifyNotConfigurable(obj, "prop"); +assert.sameValue(desc.configurable, false); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-489.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-489.js new file mode 100644 index 0000000000..3218db8fa3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-489.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-489 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +var result1 = typeof obj.prop === "undefined"; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: getFunc + }); +}); +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(typeof desc1.get, "undefined", 'typeof desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.js new file mode 100644 index 0000000000..9e45eed271 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-49.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. + +/*--- +es5id: 15.2.3.6-4-49 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Enumerable]] of 'name' property of 'Attributes' is set as false + value if absent in data descriptor 'desc' (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 1001, + writable: true, + configurable: true +}); +verifyEqualTo(obj, "property", 1001); + +verifyWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-490.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-490.js new file mode 100644 index 0000000000..80ac582365 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-490.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-490 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: undefined + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-491.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-491.js new file mode 100644 index 0000000000..4af44ec230 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-491.js @@ -0,0 +1,52 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-491 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); + +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js new file mode 100644 index 0000000000..cc418c9e12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-492.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-492 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is undefined, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + verifyNotConfigurable(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-493.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-493.js new file mode 100644 index 0000000000..112765a427 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-493.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-493 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + undefined, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: undefined, + set: setFunc, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-494.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-494.js new file mode 100644 index 0000000000..360d5f2ebd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-494.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. + +/*--- +es5id: 15.2.3.6-4-494 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-495.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-495.js new file mode 100644 index 0000000000..918c7134e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-495.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-495 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-496.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-496.js new file mode 100644 index 0000000000..34c390b261 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-496.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-496 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is true) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-497.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-497.js new file mode 100644 index 0000000000..940c9f151d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-497.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-497 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-498.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-498.js new file mode 100644 index 0000000000..7e994758bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-498.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-498 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: undefined +}); + +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-499.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-499.js new file mode 100644 index 0000000000..d25a75aadf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-499.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-499 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +obj.prop = "overrideData"; + +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-5.js new file mode 100644 index 0000000000..e496ca8ccb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-5.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 6 of [[DefineOwnProperty]] returns if + every field of desc also occurs in current and every field in desc has + the same value as current. +es5id: 15.2.3.6-4-5 +description: > + Object.defineProperty is no-op if current and desc are the same + data desc +---*/ + +function sameDataDescriptorValues(d1, d2) { + return (d1.value === d2.value && + d1.enumerable === d2.enumerable && + d1.writable === d2.writable && + d1.configurable === d2.configurable); +} + +var o = {}; + +// create a data valued property with the following attributes: +// value: 101, enumerable: true, writable: true, configurable: true +o["foo"] = 101; + +// query for, and save, the desc. A subsequent call to defineProperty +// with the same desc should not disturb the property definition. +var d1 = Object.getOwnPropertyDescriptor(o, "foo"); + +// now, redefine the property with the same descriptor +// the property defintion should not get disturbed. +var desc = { + value: 101, + enumerable: true, + writable: true, + configurable: true +}; +Object.defineProperty(o, "foo", desc); + +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(sameDataDescriptorValues(d1, d2), true, 'sameDataDescriptorValues(d1, d2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.js new file mode 100644 index 0000000000..f49f61a6c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-50.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. + +/*--- +es5id: 15.2.3.6-4-50 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Configurable]] of 'name' property is set as false if it is + absent in data descriptor 'desc' (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + value: 1001, + writable: true, + enumerable: true +}); +verifyEqualTo(obj, "property", 1001); + +verifyWritable(obj, "property"); + +verifyEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-500.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-500.js new file mode 100644 index 0000000000..ba380b5576 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-500.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-500 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js new file mode 100644 index 0000000000..7de38b5055 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-501.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-501 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); + +verifyNotWritable(obj, "prop"); +verifyNotConfigurable(obj, "prop"); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-502.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-502.js new file mode 100644 index 0000000000..211bf9ad56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-502.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-502 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-503.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-503.js new file mode 100644 index 0000000000..cc69b7f31a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-503.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. + +/*--- +es5id: 15.2.3.6-4-503 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-504.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-504.js new file mode 100644 index 0000000000..e8eac02cab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-504.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-504 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-505.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-505.js new file mode 100644 index 0000000000..b1fe46024e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-505.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-505 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is false) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js new file mode 100644 index 0000000000..8ad6ca3b7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-506.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-506 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is true, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-507.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-507.js new file mode 100644 index 0000000000..d15be1da71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-507.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-507 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: undefined + }); +}); +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-508.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-508.js new file mode 100644 index 0000000000..70b835ea7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-508.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-508 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: setFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-509.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-509.js new file mode 100644 index 0000000000..f1fef2a928 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-509.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-509 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js new file mode 100644 index 0000000000..989d71d164 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-51.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-51 +description: > + Object.defineProperty - desc is data descriptor, test updating all + attribute values of 'name' (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = { + "property": 1 +}; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "property", { + value: 1001, + writable: false, + enumerable: false, + configurable: false +}); + +verifyEqualTo(obj, "property", 1001); + +verifyNotWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js new file mode 100644 index 0000000000..325f76e16c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-510.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-510 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-511.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-511.js new file mode 100644 index 0000000000..75032f7168 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-511.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-511 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + a Function, [[Set]] is undefined, [[Enumerable]] is true, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-512.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-512.js new file mode 100644 index 0000000000..5f624b3b7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-512.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. + +/*--- +es5id: 15.2.3.6-4-512 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-513.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-513.js new file mode 100644 index 0000000000..0645884c5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-513.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-513 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) is undefined +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-514.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-514.js new file mode 100644 index 0000000000..1c4ca0a01f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-514.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-514 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is true) is + non-enumerable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-515.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-515.js new file mode 100644 index 0000000000..7b40d7f6ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-515.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-515 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-516.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-516.js new file mode 100644 index 0000000000..626a28836d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-516.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-516 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: undefined +}); + +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-517.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-517.js new file mode 100644 index 0000000000..3181e0c083 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-517.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-517 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +var propertyDefineCorrect = obj.hasOwnProperty("prop"); + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +obj.prop = "overrideData"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-518.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-518.js new file mode 100644 index 0000000000..f616aa5e18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-518.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-518 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js new file mode 100644 index 0000000000..60baf731ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-519.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-519 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.js new file mode 100644 index 0000000000..0d2ca8420a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-52.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. + +/*--- +es5id: 15.2.3.6-4-52 +description: > + Object.defineProperty - 'desc' is generic descriptor without any + attribute, test 'name' is defined in 'obj' with all default + attribute values (8.12.9 step 4.a.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", {}); + +verifyEqualTo(obj, "property", undefined); + +verifyNotWritable(obj, "property"); + +verifyNotEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-520.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-520.js new file mode 100644 index 0000000000..94ae4a9ff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-520.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-520 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-521.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-521.js new file mode 100644 index 0000000000..5594c922b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-521.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. + +/*--- +es5id: 15.2.3.6-4-521 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-522.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-522.js new file mode 100644 index 0000000000..78a8f4ef45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-522.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-522 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) is undefined +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(typeof desc.set, "undefined", 'typeof desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-523.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-523.js new file mode 100644 index 0000000000..f7f9481f39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-523.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-523 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is false) is + non-enumerable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js new file mode 100644 index 0000000000..aa6fe43c25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-524.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-524 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is + undefined, [[Enumerable]] is false, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc.configurable, false); + +verifyNotConfigurable(obj, "prop"); + +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-525.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-525.js new file mode 100644 index 0000000000..8fd9cb53a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-525.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-525 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: undefined + }); +}); +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-526.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-526.js new file mode 100644 index 0000000000..0ae0120d5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-526.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-526 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: setFunc + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(typeof desc1.set, "undefined", 'typeof desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-527.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-527.js new file mode 100644 index 0000000000..609fe03607 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-527.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-527 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js new file mode 100644 index 0000000000..b666822536 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-528.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-528 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is undefined, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + assert.sameValue(desc1.configurable, false); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); + + assert(obj.hasOwnProperty("prop")); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-529.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-529.js new file mode 100644 index 0000000000..15ef13d55e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-529.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-529 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + a Function, [[Set]] is undefined, [[Enumerable]] is false, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: undefined, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js new file mode 100644 index 0000000000..b8dd34d5ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-53.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-53 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Get]] of 'name' property is set as undefined if it is absent in + accessor descriptor 'desc' (8.12.9 step 4.b) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var setFunc = function(value) { + obj.setVerifyHelpProp = value; +}; + +Object.defineProperty(obj, "property", { + set: setFunc, + enumerable: true, + configurable: true +}); + +verifyWritable(obj, "property", "setVerifyHelpProp"); + +verifyEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-530.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-530.js new file mode 100644 index 0000000000..308414e971 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-530.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-530 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js new file mode 100644 index 0000000000..167099fb52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-1.js @@ -0,0 +1,47 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-1 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of named accessor property 'P' successfully when [[Configurable]] + attribute is true, 'O' is an Object object (8.12.9 step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "property", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "property", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "property", getFunc()); + +verifyWritable(obj, "property", "verifySetFunction1"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js new file mode 100644 index 0000000000..50dbf751f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-10.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-10 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of indexed accessor property 'P' successfully when + [[Configurable]] attribute is true, 'O' is an Object object + (8.12.9 step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "0", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "0", getFunc()); + +verifyWritable(obj, "0", "verifySetFunction1"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js new file mode 100644 index 0000000000..d23dfcde09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-11.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-11 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of named accessor property 'P' successfully when [[Configurable]] + attribute is true, 'A' is an Array object (8.12.9 step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "prop", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "prop", getFunc()); + +verifyWritable(obj, "prop", "verifySetFunction1"); + +verifyNotEnumerable(obj, "prop"); + +verifyConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js new file mode 100644 index 0000000000..05a7954bab --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-12.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-12 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of indexed accessor property successfully when [[Configurable]] + attribute is true, 'O' is an Arguments object (8.12.9 step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "0", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "0", getFunc()); + +verifyWritable(obj, "0", "verifySetFunction1"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-15.js new file mode 100644 index 0000000000..938b50e4c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-15 +description: > + ES5 Attributes - Updating a named accessor property 'P' using + simple assignment is successful, 'A' is an Array object (8.12.5 + step 5.b) +---*/ + +var obj = []; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; +var getFunc = function() { + return verifySetFunc; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.prop, "overrideData", 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-16.js new file mode 100644 index 0000000000..d690167d9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-16.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-16 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' using + simple assignment, 'O' is an Arguments object (8.12.5 step 5.b) +---*/ + +var obj = (function() { + return arguments; +}()); + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; +var getFunc = function() { + return verifySetFunc; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +obj[0] = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("0"); +var desc = Object.getOwnPropertyDescriptor(obj, "0"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj[0], "overrideData", 'obj[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js new file mode 100644 index 0000000000..6c459d0db2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-2.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-2 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of indexed accessor property 'P' successfully when + [[Configurable]] attribute is true, 'A' is an Array object (8.12.9 + step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = []; + +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "0", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "0", getFunc()); + +verifyWritable(obj, "0", "verifySetFunction1"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js new file mode 100644 index 0000000000..0dc6f76257 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-3.js @@ -0,0 +1,50 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-3 +description: > + Object.defineProperty will update [[Get]] and [[Set]] attributes + of named accessor property successfully when [[Configurable]] + attribute is true, 'O' is an Arguments object (8.12.9 step 11) +includes: [propertyHelper.js] +---*/ + + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunction = "data"; +Object.defineProperty(obj, "property", { + get: function() { + return obj.verifySetFunction; + }, + set: function(value) { + obj.verifySetFunction = value; + }, + configurable: true +}); + +obj.verifySetFunction1 = "data1"; +var getFunc = function() { + return obj.verifySetFunction1; +}; +var setFunc = function(value) { + obj.verifySetFunction1 = value; +}; + +Object.defineProperty(obj, "property", { + get: getFunc, + set: setFunc +}); + +verifyEqualTo(obj, "property", getFunc()); + +verifyWritable(obj, "property", "verifySetFunction1"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-6.js new file mode 100644 index 0000000000..ffe9048f54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-6.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-6 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' without + [[Set]] using simple assignment is failed, 'A' is an Array object + (8.12.5 step 5.b) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +var verifySetFunc = "data"; +var getFunc = function() { + return verifySetFunc; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + enumerable: true, + configurable: true +}); + +verifyNotWritable(obj, "0"); + +assert(obj.hasOwnProperty("0")); +var desc = Object.getOwnPropertyDescriptor(obj, "0"); + +assert.sameValue(typeof desc.set, "undefined"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-7.js new file mode 100644 index 0000000000..4764a1c3f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531-7.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531-7 +description: > + ES5 Attributes - Updating a named accessor property 'P' without + [[Set]] using simple assignment is failed, 'O' is an Arguments + object (8.12.5 step 5.b) +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +var verifySetFunc = "data"; +var getFunc = function() { + return verifySetFunc; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + enumerable: true, + configurable: true +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotWritable(obj, "prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(typeof desc.set, "undefined"); +assert.sameValue(obj.prop, "data"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531.js new file mode 100644 index 0000000000..15691d7062 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-531.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-531 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-532.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-532.js new file mode 100644 index 0000000000..d49c562b8a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-532.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-532 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is true) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-533.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-533.js new file mode 100644 index 0000000000..f7bedbaf67 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-533.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-533 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-534.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-534.js new file mode 100644 index 0000000000..a7fa8e6466 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-534.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-534 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: undefined +}); + +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-535.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-535.js new file mode 100644 index 0000000000..453c4f2d78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-535.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-535 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: undefined +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-536.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-536.js new file mode 100644 index 0000000000..fc1a97a80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-536.js @@ -0,0 +1,54 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-536 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: false +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js new file mode 100644 index 0000000000..e05ce8fecf --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-537.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-537 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + configurable: false +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +verifyNotConfigurable(obj, "prop"); +assert.sameValue(desc1.configurable, true); +assert.sameValue(desc2.configurable, false); +assert(obj.hasOwnProperty("prop")); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js new file mode 100644 index 0000000000..06dd0aa4b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-1.js @@ -0,0 +1,61 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-538-1 +description: > + ES5 Attributes - Updating an indexed 'P' whose [[Configurable]] + attribute is true to a data property is successful, 'A' is an + Array object (8.12.9 - step 9.c.i) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +Object.defineProperty(obj, "0", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + +if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); +} + +if (!desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value")); +} + +if (typeof desc2.get !== "undefined") { + throw new Test262Error('Expected typeof desc2.get === "undefined", actually ' + typeof desc2.get); +} + +if (typeof desc2.set !== "undefined") { + throw new Test262Error('Expected typeof desc2.set === "undefined", actually ' + typeof desc2.set); +} + +verifyEqualTo(obj, "0", 1001); + +verifyNotWritable(obj, "0"); + +verifyEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js new file mode 100644 index 0000000000..c1a03d0ff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-2.js @@ -0,0 +1,63 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-538-2 +description: > + ES5 Attributes - Updating a named accessor property 'P' whose + [[Configurable]] attribute is true to a data property is + successful, 'O' is an Arguments object +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); +} + +if (!desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value")); +} + +if (typeof desc2.get !== "undefined") { + throw new Test262Error('Expected typeof desc2.get === "undefined" , actually ' + typeof desc2.get); +} + +if (typeof desc2.set !== "undefined") { + throw new Test262Error('Expected typeof desc2.set === "undefined" , actually ' + typeof desc2.set); +} + +verifyEqualTo(obj, "prop", 1001); + +verifyNotWritable(obj, "prop"); + +verifyEnumerable(obj, "prop"); + +verifyConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js new file mode 100644 index 0000000000..effdbc3676 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-5.js @@ -0,0 +1,62 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-538-5 +description: > + ES5 Attributes - Updating a named accessor property 'P' whose + [[Configurable]] attribute is true to a data property is + successful, 'A' is an Array object (8.12.9 - step 9.c.i) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); +} + +if (!desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value")); +} + +if (typeof desc2.get !== "undefined") { + throw new Test262Error('Expected typeof desc2.get === "undefined" , actually ' + typeof desc2.get); +} + +if (typeof desc2.set !== "undefined") { + throw new Test262Error('Expected typeof desc2.set === "undefined" , actually ' + typeof desc2.set); +} + + +verifyEqualTo(obj, "prop", 1001); + +verifyNotWritable(obj, "prop"); + +verifyEnumerable(obj, "prop"); + +verifyConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js new file mode 100644 index 0000000000..4bfe9d32ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538-6.js @@ -0,0 +1,63 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-538-6 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' whose + [[Configurable]] attribute is true to a data property is + successful, 'O' is an Arguments object +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +Object.defineProperty(obj, "0", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + +if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); +} + +if (!desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value")); +} + +if (typeof desc2.get !== "undefined") { + throw new Test262Error('Expected typeof desc2.get === "undefined" , actually ' + typeof desc2.get); +} + +if (typeof desc2.set !== "undefined") { + throw new Test262Error('Expected typeof desc2.set === "undefined" , actually ' + typeof desc2.set); +} + +verifyEqualTo(obj, "0", 1001); + +verifyNotWritable(obj, "0"); + +verifyEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js new file mode 100644 index 0000000000..8943f5cff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-538.js @@ -0,0 +1,58 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-538 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is true) to a data property +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: true +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); +} + +if (!desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected desc2.hasOwnProperty("value") to be true, actually ' + desc2.hasOwnProperty("value")); +} + +if (typeof desc2.get !== "undefined") { + throw new Test262Error('Expected typeof desc2.get === "undefined" , actually ' + typeof desc2.get); +} + + +verifyEqualTo(obj, "prop", 1001); + +verifyNotWritable(obj, "prop"); + +verifyEnumerable(obj, "prop"); + +verifyConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-539.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-539.js new file mode 100644 index 0000000000..e744cd0716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-539.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-539 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.js new file mode 100644 index 0000000000..34de6eff1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-54.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. + +/*--- +es5id: 15.2.3.6-4-54 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Set]] of 'name' property of 'Attributes' is set as undefined + value if absent in accessor descriptor 'desc' (8.12.9 step 4.b.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "property", { + get: function() { + return "property"; + }, + enumerable: false, + configurable: false +}); + + +assert.sameValue(obj.property, "property"); + +var desc = Object.getOwnPropertyDescriptor(obj, "property"); +assert.sameValue(typeof desc.set, "undefined"); + +verifyNotEnumerable(obj, "property"); +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js new file mode 100644 index 0000000000..ac2f8d5fb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-1.js @@ -0,0 +1,72 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-1 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of a named accessor property 'P' whose [[Configurable]] + attribute is false and throws TypeError exception, 'O' is an + Object object (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "property", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "property", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + verifyEqualTo(obj, "property", getFunc()); + + verifyWritable(obj, "property", "verifySetFunction"); + + verifyNotEnumerable(obj, "property"); + + verifyNotConfigurable(obj, "property"); +} + +try { + Object.defineProperty(obj, "property", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e) { + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + verifyEqualTo(obj, "property", getFunc()); + + verifyWritable(obj, "property", "verifySetFunction"); + + verifyNotEnumerable(obj, "property"); + + verifyNotConfigurable(obj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-10.js new file mode 100644 index 0000000000..5fd551084d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-10.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-10 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' using + simple assignment is successful, 'O' is an Arguments object + (8.12.5 step 5.b) +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj[0] = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("0"); +var desc = Object.getOwnPropertyDescriptor(obj, "0"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.verifySetFunc, "overrideData", 'obj.verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js new file mode 100644 index 0000000000..df61180433 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-2.js @@ -0,0 +1,72 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-2 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of an indexed property 'P' whose [[Configurable]] + attribute is false and throws TypeError exception, 'A' is an Array + object (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "0", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); +} + +try { + Object.defineProperty(obj, "0", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e) { + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js new file mode 100644 index 0000000000..f7018700c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-3.js @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-3 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of a named accessor property 'P' whose [[Configurable]] + attribute is false, 'O' is an Arguments object (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "property", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "property", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + verifyEqualTo(obj, "property", getFunc()); + + verifyWritable(obj, "property", "verifySetFunction"); + + verifyNotEnumerable(obj, "property"); + + verifyNotConfigurable(obj, "property"); +} + +try { + Object.defineProperty(obj, "property", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e) { + + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + verifyEqualTo(obj, "property", getFunc()); + + verifyWritable(obj, "property", "verifySetFunction"); + + verifyNotEnumerable(obj, "property"); + + verifyNotConfigurable(obj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-4.js new file mode 100644 index 0000000000..d37bd35ae6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-4.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-4 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' using + simple assignment is successful, 'A' is an Array object (8.12.5 + step 5.b) +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj[0] = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("0"); +var desc = Object.getOwnPropertyDescriptor(obj, "0"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.verifySetFunc, "overrideData", 'obj.verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-5.js new file mode 100644 index 0000000000..a311c705b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-5.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-5 +description: > + ES5 Attributes - Updating a named accessor property 'P' using + simple assignment is successful, 'O' is an Arguments object + (8.12.5 step 5.b) +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.verifySetFunc, "overrideData", 'obj.verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js new file mode 100644 index 0000000000..64cc3ff55f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-6.js @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-6 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of an indexed accessor property 'P' whose + [[Configurable]] attribute is false and throws TypeError + exception, 'O' is an Object object (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "0", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); +} + +try { + Object.defineProperty(obj, "0", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e) { + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js new file mode 100644 index 0000000000..bc90c7b983 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-7.js @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-7 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of a named property 'P' whose [[Configurable]] + attribute is false and throws TypeError exception, 'A' is an Array + object (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "prop", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + verifyEqualTo(obj, "prop", getFunc()); + + verifyWritable(obj, "prop", "verifySetFunction"); + + verifyNotEnumerable(obj, "prop"); + + verifyNotConfigurable(obj, "prop"); +} + +try { + Object.defineProperty(obj, "prop", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e1) { + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + + verifyEqualTo(obj, "prop", getFunc()); + + verifyWritable(obj, "prop", "verifySetFunction"); + + verifyNotEnumerable(obj, "prop"); + + verifyNotConfigurable(obj, "prop"); + + + if (!(e1 instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e1); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js new file mode 100644 index 0000000000..26be4c5177 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-8.js @@ -0,0 +1,74 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-8 +description: > + Object.defineProperty fails to update [[Get]] and [[Set]] + attributes of an indexed accessor property 'P' whose + [[Configurable]] attribute is false, 'O' is an Arguments object + (8.12.9 step 11.a) +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunction = "data"; +var getFunc = function() { + return obj.verifySetFunction; +}; +var setFunc = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + configurable: false +}); + +var result = false; +try { + Object.defineProperty(obj, "0", { + get: function() { + return 100; + } + }); +} catch (e) { + result = e instanceof TypeError; + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); +} + +try { + Object.defineProperty(obj, "0", { + set: function(value) { + obj.verifySetFunction1 = value; + } + }); +} catch (e) { + if (!result) { + throw new Test262Error('Expected result to be true, actually ' + result); + } + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunction"); + + verifyNotEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-9.js new file mode 100644 index 0000000000..7bde4483d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540-9.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540-9 +description: > + ES5 Attributes - Updating a named accessor property 'P' using + simple assignment is successful, 'A' is an Array object (8.12.5 + step 5.b) +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.verifySetFunc, "overrideData", 'obj.verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540.js new file mode 100644 index 0000000000..9f6ea0441e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-540.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-540 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-541.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-541.js new file mode 100644 index 0000000000..8eb0d4877d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-541.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-541 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is false) is + enumerable +---*/ + +var propertyFound = false; + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + if (p === "prop") { + propertyFound = true; + break; + } +} + +assert(propertyFound, 'Property not found'); +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js new file mode 100644 index 0000000000..0768fd3034 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-542.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-542 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is true, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-543.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-543.js new file mode 100644 index 0000000000..08b470da3c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-543.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-543 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: undefined + }); +}); +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-544.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-544.js new file mode 100644 index 0000000000..6a02e59d50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-544.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-544 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: undefined + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-545.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-545.js new file mode 100644 index 0000000000..0d9594d068 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-545.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-545 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: false + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, true, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js new file mode 100644 index 0000000000..bd266dbcb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-546.js @@ -0,0 +1,49 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-546 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is true, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + assert.sameValue(desc1.configurable, false); + + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + assert.sameValue(desc2.configurable, false); + + verifyNotConfigurable(obj, "prop"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js new file mode 100644 index 0000000000..ae003f7fdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-1.js @@ -0,0 +1,65 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-547-1 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' whose + [[Configurable]] attribute is false to a data property does not + succeed, 'A' is an Array object (8.12.9 step 9.a) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +try { + Object.defineProperty(obj, "0", { + value: 1001 + }); + + throw new Test262Error("Expected an exception."); +} catch (e) { + var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + + if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); + } + + if (desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected !desc2.hasOwnProperty("value") to be true, actually ' + !desc2.hasOwnProperty("value")); + } + + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunc"); + + verifyEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js new file mode 100644 index 0000000000..6b40da84ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-2.js @@ -0,0 +1,67 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-547-2 +description: > + ES5 Attributes - Updating a named accessor property 'P' whose + [[Configurable]] attribute is false to a data property does not + succeed, 'A' is an Arguments object (8.12.9 step 9.a) +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + value: 1001 + }); + + throw new Test262Error("Expected an exception."); +} catch (e) { + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); + } + + if (desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected !desc2.hasOwnProperty("value") to be true, actually ' + !desc2.hasOwnProperty("value")); + } + + + verifyEqualTo(obj, "prop", getFunc()); + + verifyWritable(obj, "prop", "verifySetFunc"); + + verifyEnumerable(obj, "prop"); + + verifyNotConfigurable(obj, "prop"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js new file mode 100644 index 0000000000..db6e0fdd62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-3.js @@ -0,0 +1,64 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-547-3 +description: > + ES5 Attributes - Updating a named accessor property 'P' whose + [[Configurable]] attribute is false to a data property does not + succeed, 'A' is an Array object (8.12.9 step 9.a) +includes: [propertyHelper.js] +---*/ + +var obj = []; + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + value: 1001 + }); + + throw new Test262Error("Expected an exception."); +} catch (e) { + var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + + if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); + } + + if (desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected !desc2.hasOwnProperty("value") to be true, actually ' + !desc2.hasOwnProperty("value")); + } + + + verifyEqualTo(obj, "prop", getFunc()); + + verifyWritable(obj, "prop", "verifySetFunc"); + + verifyEnumerable(obj, "prop"); + + verifyNotConfigurable(obj, "prop"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js new file mode 100644 index 0000000000..ffc954933e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547-4.js @@ -0,0 +1,65 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-547-4 +description: > + ES5 Attributes - Updating an indexed accessor property 'P' whose + [[Configurable]] attribute is false to a data property does not + succeed, 'A' is an Arguments object (8.12.9 step 9.a) +includes: [propertyHelper.js] +---*/ + +var obj = (function() { + return arguments; +}()); + +obj.verifySetFunc = "data"; +var getFunc = function() { + return obj.verifySetFunc; +}; + +var setFunc = function(value) { + obj.verifySetFunc = value; +}; + +Object.defineProperty(obj, "0", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "0"); + +try { + Object.defineProperty(obj, "0", { + value: 1001 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + var desc2 = Object.getOwnPropertyDescriptor(obj, "0"); + + if (!desc1.hasOwnProperty("get")) { + throw new Test262Error('Expected desc1.hasOwnProperty("get") to be true, actually ' + desc1.hasOwnProperty("get")); + } + + if (desc2.hasOwnProperty("value")) { + throw new Test262Error('Expected !desc2.hasOwnProperty("value") to be true, actually ' + !desc2.hasOwnProperty("value")); + } + + verifyEqualTo(obj, "0", getFunc()); + + verifyWritable(obj, "0", "verifySetFunc"); + + verifyEnumerable(obj, "0"); + + verifyNotConfigurable(obj, "0"); + + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547.js new file mode 100644 index 0000000000..dcb19f54a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-547.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-547 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + a Function, [[Set]] is a Function, [[Enumerable]] is true, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: true, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-548.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-548.js new file mode 100644 index 0000000000..11b2a79a51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-548.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-548 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-549.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-549.js new file mode 100644 index 0000000000..629e2c352c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-549.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-549 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js new file mode 100644 index 0000000000..ca020589dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-55.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-55 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Enumerable]] of 'name' property of 'Attributes' is set as false + value if absent in accessor descriptor 'desc' (8.12.9 step 4.b.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var setFunc = function(value) { + obj.setVerifyHelpProp = value; +}; +var getFunc = function() { + return 10; +}; + +Object.defineProperty(obj, "property", { + set: setFunc, + get: getFunc, + configurable: true +}); +verifyEqualTo(obj, "property", getFunc()); + +verifyWritable(obj, "property", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "property"); + +verifyConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-550.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-550.js new file mode 100644 index 0000000000..e85ee4d553 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-550.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-550 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is true) is + non-enumerable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-551.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-551.js new file mode 100644 index 0000000000..cec2e0d83f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-551.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-551 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is true) is + deletable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +delete obj.prop; + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-552.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-552.js new file mode 100644 index 0000000000..55303c7bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-552.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-552 +description: > + ES5 Attributes - success to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + get: undefined +}); + +var result2 = typeof obj.prop === "undefined"; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(typeof desc2.get, "undefined", 'typeof desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-553.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-553.js new file mode 100644 index 0000000000..726c412524 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-553.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-553 +description: > + ES5 Attributes - success to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + set: undefined +}); + +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(typeof desc2.set, "undefined", 'typeof desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-554.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-554.js new file mode 100644 index 0000000000..cfc4cf2d80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-554.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-554 +description: > + ES5 Attributes - success to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} + +Object.defineProperty(obj, "prop", { + enumerable: true +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, true, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js new file mode 100644 index 0000000000..96f0f78ea5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-555.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-555 +description: > + ES5 Attributes - success to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is true) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.sameValue(desc1.configurable, true); + +Object.defineProperty(obj, "prop", { + configurable: false +}); + +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-556.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-556.js new file mode 100644 index 0000000000..ecfdcf0cc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-556.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-556 +description: > + ES5 Attributes - success to update the accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is true) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: true +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +Object.defineProperty(obj, "prop", { + value: 1001 +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert(desc2.hasOwnProperty("value"), 'desc2.hasOwnProperty("value") !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-557.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-557.js new file mode 100644 index 0000000000..25d9fba3ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-557.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-557 +description: > + ES5 Attributes - [[Get]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 1001, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-558.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-558.js new file mode 100644 index 0000000000..d9626d1995 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-558.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-558 +description: > + ES5 Attributes - [[Set]] attribute of accessor property ([[Get]] + is a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) is the expected function +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +obj.prop = "overrideData"; +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, "overrideData", 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-559.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-559.js new file mode 100644 index 0000000000..aae9e8e40e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-559.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-559 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is false) is + non-enumerable +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +var propertyDefineCorrect = obj.hasOwnProperty("prop"); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +for (var p in obj) { + assert.notSameValue(p, "prop", 'p'); +} + +assert(propertyDefineCorrect, 'propertyDefineCorrect !== true'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js new file mode 100644 index 0000000000..c5ea0ffad5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-56.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-56 +description: > + Object.defineProperty - 'name' property doesn't exist in 'O', test + [[Configurable]] of 'name' property is set as false if it is + absent in accessor descriptor 'desc' (8.12.9 step 4.b.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var setFunc = function(value) { + obj.setVerifyHelpProp = value; +}; +var getFunc = function() { + return 10; +}; + +Object.defineProperty(obj, "property", { + set: setFunc, + get: getFunc, + enumerable: true +}); +verifyEqualTo(obj, "property", getFunc()); + +verifyWritable(obj, "property", "setVerifyHelpProp"); + +verifyEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js new file mode 100644 index 0000000000..127e3d4d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-560.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-560 +description: > + ES5 Attributes - property ([[Get]] is a Function, [[Set]] is a + Function, [[Enumerable]] is false, [[Configurable]] is false) is + undeletable +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +assert(obj.hasOwnProperty("prop")); +verifyNotConfigurable(obj, "prop"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-561.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-561.js new file mode 100644 index 0000000000..676338c4be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-561.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-561 +description: > + ES5 Attributes - fail to update [[Get]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +var result1 = obj.prop === 1001; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + get: undefined + }); +}); +var result2 = obj.prop === 1001; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert.sameValue(desc1.get, getFunc, 'desc1.get'); +assert.sameValue(desc2.get, getFunc, 'desc2.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-562.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-562.js new file mode 100644 index 0000000000..f68f4cda5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-562.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-562 +description: > + ES5 Attributes - fail to update [[Set]] attribute of accessor + property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); + +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + set: undefined + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert.sameValue(desc1.set, setFunc, 'desc1.set'); +assert.sameValue(desc2.set, setFunc, 'desc2.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-563.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-563.js new file mode 100644 index 0000000000..ac8907dba4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-563.js @@ -0,0 +1,55 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-563 +description: > + ES5 Attributes - fail to update [[Enumerable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); +var result1 = false; +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p1 in obj) { + if (p1 === "prop") { + result1 = true; + } +} +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + enumerable: true + }); +}); +var result2 = false; +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); +for (var p2 in obj) { + if (p2 === "prop") { + result2 = true; + } +} + +assert.sameValue(result1, false, 'result1'); +assert.sameValue(result2, false, 'result2'); +assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); +assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js new file mode 100644 index 0000000000..b4d0e29416 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-564.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-564 +description: > + ES5 Attributes - fail to update [[Configurable]] attribute of + accessor property ([[Get]] is a Function, [[Set]] is a Function, + [[Enumerable]] is false, [[Configurable]] is false) to different + value +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); + +try { + Object.defineProperty(obj, "prop", { + configurable: true + }); + + throw new Test262Error("Expected TypeError"); +} catch (e) { + assert(e instanceof TypeError); + assert.sameValue(desc1.configurable, false); + verifyNotConfigurable(obj, "prop"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-565.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-565.js new file mode 100644 index 0000000000..6b94355849 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-565.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-565 +description: > + ES5 Attributes - fail to update the accessor property ([[Get]] is + a Function, [[Set]] is a Function, [[Enumerable]] is false, + [[Configurable]] is false) to a data property +---*/ + +var obj = {}; + +var getFunc = function() { + return 1001; +}; + +var verifySetFunc = "data"; +var setFunc = function(value) { + verifySetFunc = value; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc, + set: setFunc, + enumerable: false, + configurable: false +}); +var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); +assert.throws(TypeError, function() { + Object.defineProperty(obj, "prop", { + value: 1001 + }); +}); +var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(desc1.hasOwnProperty("get"), 'desc1.hasOwnProperty("get") !== true'); +assert.sameValue(desc2.hasOwnProperty("value"), false, 'desc2.hasOwnProperty("value")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-566.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-566.js new file mode 100644 index 0000000000..05c97023f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-566.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. + +/*--- +es5id: 15.2.3.6-4-566 +description: > + ES5 Attributes - [[Get]] attribute is a function which has zero + argument +---*/ + +var obj = {}; +var getFunc = function() { + return 2010; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc.get, getFunc, 'desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-567.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-567.js new file mode 100644 index 0000000000..a93935c00e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-567.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. + +/*--- +es5id: 15.2.3.6-4-567 +description: > + ES5 Attributes - [[Get]] attribute is a function which has one + argument +---*/ + +var obj = {}; +var getFunc = function(arg1) { + return 2010; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc.get, getFunc, 'desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-568.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-568.js new file mode 100644 index 0000000000..0cf2eaefcb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-568.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. + +/*--- +es5id: 15.2.3.6-4-568 +description: > + ES5 Attributes - [[Get]] attribute is a function which has two + arguments +---*/ + +var obj = {}; +var getFunc = function(arg1, arg2) { + return 2010; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(desc.get, getFunc, 'desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-569.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-569.js new file mode 100644 index 0000000000..42c3a18254 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-569.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. + +/*--- +es5id: 15.2.3.6-4-569 +description: > + ES5 Attributes - [[Get]] attribute is a function which contains + global variable +---*/ + +var obj = {}; +var globalVariable = 20; +var getFunc = function() { + globalVariable = 2010; + return globalVariable; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(obj.prop, 2010, 'obj.prop'); +assert.sameValue(globalVariable, 2010, 'globalVariable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js new file mode 100644 index 0000000000..5ad316ca51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-57.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-57 +description: > + Object.defineProperty - 'desc' is accessor descriptor, test + updating all attribute values of 'name' (8.12.9 step 4.b.i) +includes: [propertyHelper.js] +---*/ + +var obj = {}; +var setFunc = function(value) { + obj.setVerifyHelpProp = value; +}; +var getFunc = function() { + return 14; +}; + +Object.defineProperty(obj, "property", { + get: function() { + return 11; + }, + set: function(value) {}, + configurable: true, + enumerable: true +}); + +Object.defineProperty(obj, "property", { + get: getFunc, + set: setFunc, + configurable: false, + enumerable: false +}); + +verifyEqualTo(obj, "property", getFunc()); + +verifyWritable(obj, "property", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "property"); + +verifyNotConfigurable(obj, "property"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-570.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-570.js new file mode 100644 index 0000000000..84cb1ae3e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-570.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. + +/*--- +es5id: 15.2.3.6-4-570 +description: > + ES5 Attributes - [[Get]] attribute is a function which doesn't + contains return statement +---*/ + +var obj = {}; +var verifyExecute = false; +var getFunc = function() { + verifyExecute = true; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.get, getFunc, 'desc.get'); +assert.sameValue(typeof obj.prop, "undefined", 'typeof obj.prop'); +assert(verifyExecute, 'verifyExecute !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-571.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-571.js new file mode 100644 index 0000000000..f16afa3929 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-571.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. + +/*--- +es5id: 15.2.3.6-4-571 +description: > + ES5 Attributes - [[Get]] attribute is a function which involves + 'this' object into statement(s) +---*/ + +var obj = { + len: 2010 +}; +var getFunc = function() { + return this; +}; + +Object.defineProperty(obj, "prop", { + get: getFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(obj.prop, obj, 'obj.prop'); +assert.sameValue(desc.get, getFunc, 'desc.get'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-572.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-572.js new file mode 100644 index 0000000000..a5edb3f1c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-572.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. + +/*--- +es5id: 15.2.3.6-4-572 +description: > + ES5 Attributes - [[Set]] attribute is a function which has zero + argument +---*/ + +var obj = {}; + +var setFunc = function() {}; + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-573.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-573.js new file mode 100644 index 0000000000..9815868d23 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-573.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. + +/*--- +es5id: 15.2.3.6-4-573 +description: > + ES5 Attributes - [[Set]] attribute is a function which has one + argument +---*/ + +var obj = {}; + +var verifySetFunc = 20; +var setFunc = function(value) { + verifySetFunc = value; +}; +Object.defineProperty(obj, "prop", { + set: setFunc +}); +obj.prop = 2010; +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(verifySetFunc, 2010, 'verifySetFunc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-574.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-574.js new file mode 100644 index 0000000000..7a402e76b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-574.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-574 +description: > + ES5 Attributes - [[Set]] attribute is a function which has two + arguments +---*/ + +var obj = {}; +var firstArg = 12; +var secondArg = 12; + +var setFunc = function(a, b) { + firstArg = a; + secondArg = b; +}; +Object.defineProperty(obj, "prop", { + set: setFunc +}); +obj.prop = 100; +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(firstArg, 100, 'firstArg'); +assert.sameValue(typeof secondArg, "undefined", 'typeof secondArg'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-575.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-575.js new file mode 100644 index 0000000000..b31aa4e181 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-575.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. + +/*--- +es5id: 15.2.3.6-4-575 +description: > + ES5 Attributes - [[Set]] attribute is a function which contains + global variable +---*/ + +var obj = {}; +var globalVariable = 20; +var setFunc = function() { + globalVariable = 2010; +}; + +Object.defineProperty(obj, "prop", { + set: setFunc +}); +obj.prop = 10; +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(globalVariable, 2010, 'globalVariable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-576.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-576.js new file mode 100644 index 0000000000..52bd9123d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-576.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. + +/*--- +es5id: 15.2.3.6-4-576 +description: > + ES5 Attributes - [[Set]] attribute is a function which contains + return statement +---*/ + +var obj = {}; + +var setFunc = function() { + return 2010; +}; + +Object.defineProperty(obj, "prop", { + set: setFunc +}); + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-577.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-577.js new file mode 100644 index 0000000000..a55c79eca3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-577.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. + +/*--- +es5id: 15.2.3.6-4-577 +description: > + ES5 Attributes - [[Set]] attribute is a function which involves + 'this' object into statement(s) +---*/ + +var obj = {}; + +var setFunc = function(value) { + this.len = value; +}; + +Object.defineProperty(obj, "prop", { + set: setFunc +}); +obj.prop = 2010; + +var desc = Object.getOwnPropertyDescriptor(obj, "prop"); + +assert(obj.hasOwnProperty("prop"), 'obj.hasOwnProperty("prop") !== true'); +assert.sameValue(desc.set, setFunc, 'desc.set'); +assert.sameValue(obj.len, 2010, 'obj.len'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-578.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-578.js new file mode 100644 index 0000000000..358bb82cf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-578.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. + +/*--- +es5id: 15.2.3.6-4-578 +description: > + ES5 Attributes - [[Get]] field of inherited property of + [[Prototype]] internal property is correct (String instance) +---*/ + +var data = "data"; + +Object.defineProperty(String.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var strObj = new String(); + +assert.sameValue(strObj.hasOwnProperty("prop"), false, 'strObj.hasOwnProperty("prop")'); +assert.sameValue(strObj.prop, "data", 'strObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-579.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-579.js new file mode 100644 index 0000000000..9ef0b9c4ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-579.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-579 +description: > + ES5 Attributes - Success to add property into object (Array + instance) +---*/ + +var data = "data"; + +Object.defineProperty(Array.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var arrObj = []; +arrObj.prop = "myOwnProperty"; + +assert.sameValue(arrObj.hasOwnProperty("prop"), false, 'arrObj.hasOwnProperty("prop")'); +assert.sameValue(arrObj.prop, "myOwnProperty", 'arrObj.prop'); +assert.sameValue(data, "myOwnProperty", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.js new file mode 100644 index 0000000000..d561f384f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-58.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. + +/*--- +es5id: 15.2.3.6-4-58 +description: > + Object.defineProperty - 'name' is data descriptor and every fields + in 'desc' is absent (8.12.9 step 5) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.foo = 101; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", {}); +verifyEqualTo(obj, "foo", 101); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-580.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-580.js new file mode 100644 index 0000000000..0086d54c9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-580.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-580 +description: > + ES5 Attributes - Inherited property is enumerable (Boolean + instance) +---*/ + +var data = "data"; + +Object.defineProperty(Boolean.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var boolObj = new Boolean(); +var verifyEnumerable = false; +for (var p in boolObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(boolObj.hasOwnProperty("prop"), false, 'boolObj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-581.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-581.js new file mode 100644 index 0000000000..fae2d10b5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-581.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. + +/*--- +es5id: 15.2.3.6-4-581 +description: ES5 Attributes - Fail to add property into object (Number instance) +includes: [propertyHelper.js] +---*/ + +var data = "data"; + +Object.defineProperty(Number.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); +var numObj = new Number(); + +verifyNotWritable(numObj, "prop", "nocheck"); + +assert(!numObj.hasOwnProperty("prop")); +assert.sameValue(numObj.prop, "data"); +assert.sameValue(data, "data"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-582.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-582.js new file mode 100644 index 0000000000..5981ca69d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-582.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-582 +description: > + ES5 Attributes - Inherited property is non-enumerable (Function + instance) +---*/ + +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); +var funObj = function() {}; +var verifyEnumerable = false; +for (var p in funObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(funObj.hasOwnProperty("prop"), false, 'funObj.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-583.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-583.js new file mode 100644 index 0000000000..699dd23cfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-583.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. + +/*--- +es5id: 15.2.3.6-4-583 +description: > + ES5 Attributes - [[Get]] field of inherited property of + [[Prototype]] internal property is correct (Error Instance) +---*/ + +var data = "data"; + +Object.defineProperty(Error.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var errObj = new Error(); + +assert.sameValue(errObj.hasOwnProperty("prop"), false, 'errObj.hasOwnProperty("prop")'); +assert.sameValue(errObj.prop, "data", 'errObj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-584.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-584.js new file mode 100644 index 0000000000..b9d9c07aa0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-584.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. + +/*--- +es5id: 15.2.3.6-4-584 +description: ES5 Attributes - Failed to add property into object (Date instance) +---*/ + +var data = "data"; + +Object.defineProperty(Date.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var dateObj = new Date(); +dateObj.prop = "myOwnProperty"; + +assert.sameValue(dateObj.hasOwnProperty("prop"), false, 'dateObj.hasOwnProperty("prop")'); +assert.sameValue(dateObj.prop, "myOwnProperty", 'dateObj.prop'); +assert.sameValue(data, "myOwnProperty", 'data'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-585.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-585.js new file mode 100644 index 0000000000..1149bdf239 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-585.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. + +/*--- +es5id: 15.2.3.6-4-585 +description: ES5 Attributes - Inherited property is enumerable (RegExp instance) +---*/ + +var data = "data"; + +Object.defineProperty(RegExp.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); +var regObj = new RegExp(); +var verifyEnumerable = false; +for (var p in regObj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(regObj.hasOwnProperty("prop"), false, 'regObj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-586.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-586.js new file mode 100644 index 0000000000..fb50b43e6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-586.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. + +/*--- +es5id: 15.2.3.6-4-586 +description: > + ES5 Attributes - Fail to update value of property into of + [[Proptotype]] internal property (JSON) +includes: [propertyHelper.js] +---*/ + +var data = "data"; + +Object.defineProperty(Object.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); +verifyNotWritable(JSON, "prop", "nocheck"); + +assert(!JSON.hasOwnProperty("prop")); +assert.sameValue(JSON.prop, "data"); +assert.sameValue(data, "data"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-587.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-587.js new file mode 100644 index 0000000000..a91e8f24e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-587.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. + +/*--- +es5id: 15.2.3.6-4-587 +description: ES5 Attributes - Inherited property is non-enumerable (Math) +---*/ + +var data = "data"; + +Object.defineProperty(Object.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); +var verifyEnumerable = false; +for (var p in Math) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(Math.hasOwnProperty("prop"), false, 'Math.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-588.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-588.js new file mode 100644 index 0000000000..d8b8f95674 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-588.js @@ -0,0 +1,54 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-588 +description: > + ES5 Attributes - [[Get]] field of inherited property of + [[Prototype]] internal property is correct (Object.create) +---*/ + +var appointment = {}; + +var data1 = 1001; +Object.defineProperty(appointment, "startTime", { + get: function() { + return data1; + }, + enumerable: true, + configurable: false +}); +var data2 = "NAME"; +Object.defineProperty(appointment, "name", { + get: function() { + return data2; + }, + set: function(value) { + data2 = value; + }, + enumerable: true, + configurable: true +}); + +var meeting = Object.create(appointment); +var data3 = "In-person meeting"; +Object.defineProperty(meeting, "conferenceCall", { + get: function() { + return data3; + }, + enumerable: true, + configurable: false +}); + +var teamMeeting = Object.create(meeting); + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(teamMeeting.name, "NAME", 'teamMeeting.name'); +assert.sameValue(teamMeeting.startTime, 1001, 'teamMeeting.startTime'); +assert.sameValue(teamMeeting.conferenceCall, "In-person meeting", 'teamMeeting.conferenceCall'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-589.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-589.js new file mode 100644 index 0000000000..e5a319257b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-589.js @@ -0,0 +1,64 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-589 +description: > + ES5 Attributes - Success to update value of property into of + [[Proptotype]] internal property (Object.create) +---*/ + +var appointment = {}; + +var data1 = 1001; +Object.defineProperty(appointment, "startTime", { + get: function() { + return data1; + }, + set: function(value) { + data1 = value; + }, + enumerable: true, + configurable: true +}); +var data2 = "NAME"; +Object.defineProperty(appointment, "name", { + get: function() { + return data2; + }, + set: function(value) { + data2 = value; + }, + enumerable: true, + configurable: false +}); + +var meeting = Object.create(appointment); +var data3 = "In-person meeting"; +Object.defineProperty(meeting, "conferenceCall", { + get: function() { + return data3; + }, + set: function(value) { + data3 = value; + }, + enumerable: true, + configurable: false +}); + +var teamMeeting = Object.create(meeting); +teamMeeting.name = "Team Meeting"; +var dateObj = new Date("10/31/2010 08:00"); +teamMeeting.startTime = dateObj; +teamMeeting.conferenceCall = "4255551212"; + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(teamMeeting.name, "Team Meeting", 'teamMeeting.name'); +assert.sameValue(teamMeeting.startTime, dateObj, 'teamMeeting.startTime'); +assert.sameValue(teamMeeting.conferenceCall, "4255551212", 'teamMeeting.conferenceCall'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js new file mode 100644 index 0000000000..903ac63326 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-59.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-59 +description: > + Object.defineProperty - 'name' is accessor descriptor and every + fields in 'desc' is absent (8.12.9 step 5) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 0; +} + +function setFunc(value) { + obj.helpVerifySet = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc +}); + +Object.defineProperty(obj, "foo", {}); +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "helpVerifySet"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-590.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-590.js new file mode 100644 index 0000000000..cb49b9f3ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-590.js @@ -0,0 +1,73 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-590 +description: ES5 Attributes - Inherited property is enumerable (Object.create) +---*/ + +var appointment = {}; + +var data1 = 1001; +Object.defineProperty(appointment, "startTime", { + get: function() { + return data1; + }, + set: function(value) { + data1 = value; + }, + enumerable: true, + configurable: true +}); +var data2 = "NAME"; +Object.defineProperty(appointment, "name", { + get: function() { + return data2; + }, + set: function(value) { + data2 = value; + }, + enumerable: true, + configurable: false +}); + +var meeting = Object.create(appointment); +var data3 = "In-person meeting"; +Object.defineProperty(meeting, "conferenceCall", { + get: function() { + return data3; + }, + set: function(value) { + data3 = value; + }, + enumerable: true, + configurable: false +}); + +var teamMeeting = Object.create(meeting); + +var verifyTimeProp = false; +var verifyNameProp = false; +var verifyCallProp = false; +for (var p in teamMeeting) { + if (p === "startTime") { + verifyTimeProp = true; + } + if (p === "name") { + verifyNameProp = true; + } + if (p === "conferenceCall") { + verifyCallProp = true; + } +} + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert(verifyTimeProp, 'verifyTimeProp !== true'); +assert(verifyNameProp, 'verifyNameProp !== true'); +assert(verifyCallProp, 'verifyCallProp !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-591.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-591.js new file mode 100644 index 0000000000..7fb8751e2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-591.js @@ -0,0 +1,75 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-591 +description: > + ES5 Attributes - Fail to update value of property of + [[Proptotype]] internal property (Object.create) +includes: [propertyHelper.js] +---*/ + +var appointment = {}; + +var data1 = 1001; +Object.defineProperty(appointment, "startTime", { + get: function() { + return data1; + }, + enumerable: false, + configurable: false +}); +var data2 = "NAME"; +Object.defineProperty(appointment, "name", { + get: function() { + return data2; + }, + enumerable: false, + configurable: true +}); + +var meeting = Object.create(appointment); +var data3 = "In-person meeting"; +Object.defineProperty(meeting, "conferenceCall", { + get: function() { + return data3; + }, + enumerable: false, + configurable: false +}); + +var teamMeeting = Object.create(meeting); + +verifyNotWritable(teamMeeting, "name", "nocheck"); +verifyNotWritable(teamMeeting, "startTime", "nocheck"); +verifyNotWritable(teamMeeting, "conferenceCall", "nocheck"); + +try { + teamMeeting.name = "IE Team Meeting"; +} catch (e) { + assert(e instanceof TypeError); +} + +try { + var dateObj = new Date("10/31/2010 08:00"); + teamMeeting.startTime = dateObj; +} catch (e) { + assert(e instanceof TypeError); +} + +try { + teamMeeting.conferenceCall = "4255551212"; +} catch (e) { + assert(e instanceof TypeError); +} + + +assert(!teamMeeting.hasOwnProperty("name")); +assert(!teamMeeting.hasOwnProperty("startTime")); +assert(!teamMeeting.hasOwnProperty('conferenceCall')); + +assert.sameValue(teamMeeting.name, "NAME"); +assert.sameValue(teamMeeting.startTime, 1001); +assert.sameValue(teamMeeting.conferenceCall, "In-person meeting"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-592.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-592.js new file mode 100644 index 0000000000..d5840aea14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-592.js @@ -0,0 +1,66 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-592 +description: > + ES5 Attributes - Inherited property is non-enumerable + (Object.create) +---*/ + +var appointment = {}; + +var data1 = 1001; +Object.defineProperty(appointment, "startTime", { + get: function() { + return data1; + }, + enumerable: false, + configurable: true +}); +var data2 = "NAME"; +Object.defineProperty(appointment, "name", { + get: function() { + return data2; + }, + enumerable: false, + configurable: false +}); + +var meeting = Object.create(appointment); +var data3 = "In-person meeting"; +Object.defineProperty(meeting, "conferenceCall", { + get: function() { + return data3; + }, + enumerable: false, + configurable: true +}); + +var teamMeeting = Object.create(meeting); + +var verifyTimeProp = false; +var verifyNameProp = false; +var verifyCallProp = false; +for (var p in teamMeeting) { + if (p === "startTime") { + verifyTimeProp = true; + } + if (p === "name") { + verifyNameProp = true; + } + if (p === "conferenceCall") { + verifyCallProp = true; + } +} + +var hasOwnProperty = !teamMeeting.hasOwnProperty("name") && + !teamMeeting.hasOwnProperty("startTime") && + !teamMeeting.hasOwnProperty('conferenceCall'); + +assert(hasOwnProperty, 'hasOwnProperty !== true'); +assert.sameValue(verifyTimeProp, false, 'verifyTimeProp'); +assert.sameValue(verifyNameProp, false, 'verifyNameProp'); +assert.sameValue(verifyCallProp, false, 'verifyCallProp'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-593.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-593.js new file mode 100644 index 0000000000..7c85bed474 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-593.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-593 +description: > + ES5 Attributes - [[Get]] field of inherited property of + [[Prototype]] internal property is correct + (Function.prototype.bind) +---*/ + +var foo = function() {}; +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert.sameValue(obj.prop, data, 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-594.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-594.js new file mode 100644 index 0000000000..57b81e70e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-594.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-594 +description: > + ES5 Attributes - Success to update value of property into of + [[Proptotype]] internal property (Function.prototype.bind) +---*/ + +var foo = function() {}; +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); +obj.prop = "overrideData"; + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert.sameValue(obj.prop, "overrideData", 'obj.prop'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-595.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-595.js new file mode 100644 index 0000000000..5df8b4da09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-595.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-595 +description: > + ES5 Attributes - Inherited property is enumerable + (Function.prototype.bind) +---*/ + +var foo = function() {}; +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + set: function(value) { + data = value; + }, + enumerable: true, + configurable: true +}); + +var obj = foo.bind({}); + +var verifyEnumerable = false; +for (var p in obj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-596.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-596.js new file mode 100644 index 0000000000..f875674657 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-596.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-596 +description: > + ES5 Attributes - Fail to update value of property into of + [[Proptotype]] internal property (Function.prototype.bind) +includes: [propertyHelper.js] +---*/ + +var foo = function() {}; +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); + +var obj = foo.bind({}); + +assert(!obj.hasOwnProperty("prop")); +verifyNotWritable(obj, "prop", "nocheck"); +assert.sameValue(obj.prop, "data");; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-597.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-597.js new file mode 100644 index 0000000000..135bcecf9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-597.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-597 +description: > + ES5 Attributes - Inherited property is non-enumerable + (Function.prototype.bind) +---*/ + +var foo = function() {}; +var data = "data"; + +Object.defineProperty(Function.prototype, "prop", { + get: function() { + return data; + }, + enumerable: false, + configurable: true +}); + +var obj = foo.bind({}); + +var verifyEnumerable = false; +for (var p in obj) { + if (p === "prop") { + verifyEnumerable = true; + } +} + +assert.sameValue(obj.hasOwnProperty("prop"), false, 'obj.hasOwnProperty("prop")'); +assert.sameValue(verifyEnumerable, false, 'verifyEnumerable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-598.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-598.js new file mode 100644 index 0000000000..bd8b55eae2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-598.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. + +/*--- +es5id: 15.2.3.6-4-598 +description: > + ES5 Attributes - all attributes in Object.getPrototypeOf are + correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "getPrototypeOf", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-599.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-599.js new file mode 100644 index 0000000000..1c388fe221 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-599.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. + +/*--- +es5id: 15.2.3.6-4-599 +description: > + ES5 Attributes - all attributes in Object.getOwnPropertyDescriptor + are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "getOwnPropertyDescriptor", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-6.js new file mode 100644 index 0000000000..ac7627a639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-6.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 6 of [[DefineOwnProperty]] returns if + every field of desc also occurs in current and every field in desc has + the same value as current. +es5id: 15.2.3.6-4-6 +description: > + Object.defineProperty is no-op if current and desc are the same + accessor desc +---*/ + +function sameAccessorDescriptorValues(d1, d2) { + return (d1.get == d2.get && + d1.enumerable == d2.enumerable && + d1.configurable == d2.configurable); +} + +var o = {}; + +// create an accessor property with the following attributes: +// enumerable: true, configurable: true +var desc = { + get: function() {}, + enumerable: true, + configurable: true +}; + +Object.defineProperty(o, "foo", desc); + +// query for, and save, the desc. A subsequent call to defineProperty +// with the same desc should not disturb the property definition. +var d1 = Object.getOwnPropertyDescriptor(o, "foo"); + +// now, redefine the property with the same descriptor +// the property defintion should not get disturbed. +Object.defineProperty(o, "foo", desc); + +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(sameAccessorDescriptorValues(d1, d2), true, 'sameAccessorDescriptorValues(d1, d2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.js new file mode 100644 index 0000000000..bb14e77bed --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-60.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. + +/*--- +es5id: 15.2.3.6-4-60 +description: > + Object.defineProperty - type of desc.value is different from type + of name.value (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.foo = 101; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: "abc" +}); +verifyEqualTo(obj, "foo", "abc"); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-600.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-600.js new file mode 100644 index 0000000000..fccdb4ed06 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-600.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. + +/*--- +es5id: 15.2.3.6-4-600 +description: > + ES5 Attributes - all attributes in Object.getOwnPropertyNames are + correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "getOwnPropertyNames", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-601.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-601.js new file mode 100644 index 0000000000..ebb199e657 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-601.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-601 +description: ES5 Attributes - all attributes in Object.create are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "getPrototypeOf", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-602.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-602.js new file mode 100644 index 0000000000..341be624a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-602.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. + +/*--- +es5id: 15.2.3.6-4-602 +description: > + ES5 Attributes - all attributes in Object.defineProperty are + correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "defineProperty", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-603.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-603.js new file mode 100644 index 0000000000..7a37c11746 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-603.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. + +/*--- +es5id: 15.2.3.6-4-603 +description: > + ES5 Attributes - all attributes in Object.defineProperties are + correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "defineProperties", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-604.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-604.js new file mode 100644 index 0000000000..c3b1567828 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-604.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-604 +description: ES5 Attributes - all attributes in Object.seal are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "seal", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-605.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-605.js new file mode 100644 index 0000000000..5ad929ddc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-605.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-605 +description: ES5 Attributes - all attributes in Object.freeze are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "freeze", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-606.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-606.js new file mode 100644 index 0000000000..984a13e886 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-606.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. + +/*--- +es5id: 15.2.3.6-4-606 +description: > + ES5 Attributes - all attributes in Object.preventExtensions are + correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "preventExtensions", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-607.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-607.js new file mode 100644 index 0000000000..6310643147 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-607.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-607 +description: ES5 Attributes - all attributes in Object.isSealed are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "isSealed", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-608.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-608.js new file mode 100644 index 0000000000..4abcbf78a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-608.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-608 +description: ES5 Attributes - all attributes in Object.isFrozen are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "isFrozen", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-609.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-609.js new file mode 100644 index 0000000000..9c35a503b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-609.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-609 +description: ES5 Attributes - all attributes in Object.isExtensible are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "isExtensible", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js new file mode 100644 index 0000000000..a59d8e6098 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-61.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-61 +description: > + Object.defineProperty - both desc.value and name.value are + undefined (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: undefined +}); + +Object.defineProperty(obj, "foo", { + value: undefined +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-610.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-610.js new file mode 100644 index 0000000000..6a2e387804 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-610.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-610 +description: ES5 Attributes - all attributes in Object.keys are correct +includes: [propertyHelper.js] +---*/ + +verifyProperty(Object, "keys", { + writable: true, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js new file mode 100644 index 0000000000..19c0ef715c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-611.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-611 +description: > + ES5 Attributes - all attributes in Function.prototype.bind are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Function.prototype, "bind"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Function.prototype.bind; + +Function.prototype.bind = "2010"; + +var isWritable = (Function.prototype.bind === "2010"); + +var isEnumerable = false; + +for (var prop in Function.prototype) { + if (prop === "bind") { + isEnumerable = true; + } +} + +delete Function.prototype.bind; + +var isConfigurable = !Function.prototype.hasOwnProperty("bind"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js new file mode 100644 index 0000000000..e33d81a9c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-612.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-612 +description: > + ES5 Attributes - all attributes in Array.prototype.indexOf are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "indexOf"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.indexOf; + +Array.prototype.indexOf = "2010"; + +var isWritable = (Array.prototype.indexOf === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "indexOf") { + isEnumerable = true; + } +} + +delete Array.prototype.indexOf; + +var isConfigurable = !Array.prototype.hasOwnProperty("indexOf"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js new file mode 100644 index 0000000000..162333109f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-613.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-613 +description: ES5 Attributes - all attributes in Object.lastIndexOf are correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "lastIndexOf"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.lastIndexOf; + +Array.prototype.lastIndexOf = "2010"; + +var isWritable = (Array.prototype.lastIndexOf === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "lastIndexOf") { + isEnumerable = true; + } +} + +delete Array.prototype.lastIndexOf; + +var isConfigurable = !Array.prototype.hasOwnProperty("lastIndexOf"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js new file mode 100644 index 0000000000..368a3b8977 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-614.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-614 +description: > + ES5 Attributes - all attributes in Array.prototype.every are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "every"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.every; + +Array.prototype.every = "2010"; + +var isWritable = (Array.prototype.every === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "every") { + isEnumerable = true; + } +} + +delete Array.prototype.every; + +var isConfigurable = !Array.prototype.hasOwnProperty("every"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js new file mode 100644 index 0000000000..c4deed0cd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-615.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-615 +description: ES5 Attributes - all attributes in Array.prototype.some are correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "some"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.some; + +Array.prototype.some = "2010"; + +var isWritable = (Array.prototype.some === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "some") { + isEnumerable = true; + } +} + +delete Array.prototype.some; + +var isConfigurable = !Array.prototype.hasOwnProperty("some"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js new file mode 100644 index 0000000000..d5547bda86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-616.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-616 +description: > + ES5 Attributes - all attributes in Array.prototype.forEach are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "forEach"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.forEach; + +Array.prototype.forEach = "2010"; + +var isWritable = (Array.prototype.forEach === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "forEach") { + isEnumerable = true; + } +} + +delete Array.prototype.forEach; + +var isConfigurable = !Array.prototype.hasOwnProperty("forEach"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js new file mode 100644 index 0000000000..0d18438ceb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-617.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-617 +description: ES5 Attributes - all attributes in Array.prototype.map are correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "map"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.map; + +Array.prototype.map = "2010"; + +var isWritable = (Array.prototype.map === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "map") { + isEnumerable = true; + } +} + +delete Array.prototype.map; + +var isConfigurable = !Array.prototype.hasOwnProperty("map"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js new file mode 100644 index 0000000000..3e21462908 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-618.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-618 +description: > + ES5 Attributes - all attributes in Array.prototype.filter are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "filter"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.filter; + +Array.prototype.filter = "2010"; + +var isWritable = (Array.prototype.filter === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "filter") { + isEnumerable = true; + } +} + +delete Array.prototype.filter; + +var isConfigurable = !Array.prototype.hasOwnProperty("filter"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js new file mode 100644 index 0000000000..746209ea13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-619.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-619 +description: > + ES5 Attributes - all attributes in Array.prototype.reduce are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "reduce"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.reduce; + +Array.prototype.reduce = "2010"; + +var isWritable = (Array.prototype.reduce === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "reduce") { + isEnumerable = true; + } +} + +delete Array.prototype.reduce; + +var isConfigurable = !Array.prototype.hasOwnProperty("reduce"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js new file mode 100644 index 0000000000..f16d18a98b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-62.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-62 +description: > + Object.defineProperty - both desc.value and name.value are null + (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: null +}); + +Object.defineProperty(obj, "foo", { + value: null +}); +verifyEqualTo(obj, "foo", null); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js new file mode 100644 index 0000000000..6ce2dbb7ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-620.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-620 +description: > + ES5 Attributes - all attributes in Array.prototype.reduceRight are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Array.prototype, "reduceRight"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Array.prototype.reduceRight; + +Array.prototype.reduceRight = "2010"; + +var isWritable = (Array.prototype.reduceRight === "2010"); + +var isEnumerable = false; + +for (var prop in Array.prototype) { + if (prop === "reduceRight") { + isEnumerable = true; + } +} + +delete Array.prototype.reduceRight; + +var isConfigurable = !Array.prototype.hasOwnProperty("reduceRight"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js new file mode 100644 index 0000000000..5e00e1db4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-621.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-621 +description: > + ES5 Attributes - all attributes in String.prototype.trim are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(String.prototype, "trim"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = String.prototype.trim; + +String.prototype.trim = "2010"; + +var isWritable = (String.prototype.trim === "2010"); + +var isEnumerable = false; + +for (var prop in String.prototype) { + if (prop === "trim") { + isEnumerable = true; + } +} + +delete String.prototype.trim; + +var isConfigurable = !String.prototype.hasOwnProperty("trim"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js new file mode 100644 index 0000000000..db59aba810 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-622.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-622 +description: ES5 Attributes - all attributes in Date.now are correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Date, "now"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Date.now; + +Date.now = "2010"; + +var isWritable = (Date.now === "2010"); + +var isEnumerable = false; + +for (var prop in Date) { + if (prop === "now") { + isEnumerable = true; + } +} + +delete Date.now; + +var isConfigurable = !Date.hasOwnProperty("now"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js new file mode 100644 index 0000000000..a5c94f29b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-623.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-623 +description: > + ES5 Attributes - all attributes in Date.prototype.toISOString are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Date.prototype, "toISOString"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Date.prototype.toISOString; + +Date.prototype.toISOString = "2010"; + +var isWritable = (Date.prototype.toISOString === "2010"); + +var isEnumerable = false; + +for (var prop in Date.prototype) { + if (prop === "toISOString") { + isEnumerable = true; + } +} + +delete Date.prototype.toISOString; + +var isConfigurable = !Date.prototype.hasOwnProperty("toISOString"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js new file mode 100644 index 0000000000..4774991788 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-624.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-624 +description: > + ES5 Attributes - all attributes in Date.prototype.toJSON are + correct +---*/ + +var desc = Object.getOwnPropertyDescriptor(Date.prototype, "toJSON"); + +var propertyAreCorrect = (desc.writable === true && desc.enumerable === false && desc.configurable === true); + +var temp = Date.prototype.toJSON; + +Date.prototype.toJSON = "2010"; + +var isWritable = (Date.prototype.toJSON === "2010"); + +var isEnumerable = false; + +for (var prop in Date.prototype) { + if (prop === "toJSON") { + isEnumerable = true; + } +} + +delete Date.prototype.toJSON; + +var isConfigurable = !Date.prototype.hasOwnProperty("toJSON"); + +assert(propertyAreCorrect, 'propertyAreCorrect !== true'); +assert(isWritable, 'isWritable !== true'); +assert.sameValue(isEnumerable, false, 'isEnumerable'); +assert(isConfigurable, 'isConfigurable !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-625gs.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-625gs.js new file mode 100644 index 0000000000..683458e946 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-625gs.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. + +/*--- +es5id: 15.2.3.6-4-625gs +description: > + Globally declared variable should take precedence over + Object.prototype property of the same name +---*/ + +Object.defineProperty(Object.prototype, + "prop", + { + value: 1001, + writable: false, + enumerable: false, + configurable: false + } +); +var prop = 1002; + +if (!(this.hasOwnProperty("prop") && prop === 1002)) { + throw "this.prop should take precedence over Object.prototype.prop"; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js new file mode 100644 index 0000000000..feaf556cef --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-63.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-63 +description: > + Object.defineProperty - both desc.value and name.value are NaN + (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: NaN +}); + +Object.defineProperty(obj, "foo", { + value: NaN +}); + +assert.sameValue(obj.foo, NaN); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js new file mode 100644 index 0000000000..d627e8a13f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-64.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-64 +description: > + Object.defineProperty - desc.value = +0 and name.value = -0 + (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: -0 +}); + +try { + Object.defineProperty(obj, "foo", { + value: +0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + + verifyEqualTo(obj, "foo", -0); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js new file mode 100644 index 0000000000..ed2ac2cc12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-65.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-65 +description: > + Object.defineProperty - desc.value = -0 and name.value = +0 + (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: +0 +}); + +try { + Object.defineProperty(obj, "foo", { + value: -0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", +0); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.js new file mode 100644 index 0000000000..87fe39bdbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-66.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. + +/*--- +es5id: 15.2.3.6-4-66 +description: > + Object.defineProperty - desc.value and name.value are two numbers + with different values (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.foo = 101; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: 102 +}); +verifyEqualTo(obj, "foo", 102); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js new file mode 100644 index 0000000000..6778b65e76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-67.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-67 +description: > + Object.defineProperty - both desc.value and name.value are two + strings which have same length and same characters in + corresponding positions (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: "abcd" +}); + +Object.defineProperty(obj, "foo", { + value: "abcd" +}); +verifyEqualTo(obj, "foo", "abcd"); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.js new file mode 100644 index 0000000000..f3f74ca0b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-68.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. + +/*--- +es5id: 15.2.3.6-4-68 +description: > + Object.defineProperty - desc.value and name.value are two strings + with different values (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.foo = "abcd"; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: "fghj" +}); +verifyEqualTo(obj, "foo", "fghj"); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js new file mode 100644 index 0000000000..39244aa40a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-69.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-69 +description: > + Object.defineProperty - both desc.value and name.value are boolean + values with the same value (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: true +}); + +Object.defineProperty(obj, "foo", { + value: true +}); +verifyEqualTo(obj, "foo", true); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-7.js new file mode 100644 index 0000000000..5bc108b476 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-7.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 7a of [[DefineOwnProperty]] rejects if + current.[[Configurable]] is false and desc.[[Configurable]] is true. +es5id: 15.2.3.6-4-7 +description: > + Object.defineProperty throws TypeError when changing + [[Configurable]] from false to true +---*/ + +var o = {}; + +// create a data valued property; all other attributes default to false. +var d1 = { + value: 101, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +var desc = { + value: 101, + configurable: true +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.js new file mode 100644 index 0000000000..24d4977637 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-70.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. + +/*--- +es5id: 15.2.3.6-4-70 +description: > + Object.defineProperty - desc.value and name.value are two boolean + values with different values (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +obj.foo = true; // default value of attributes: writable: true, configurable: true, enumerable: true + +Object.defineProperty(obj, "foo", { + value: false +}); +verifyEqualTo(obj, "foo", false); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js new file mode 100644 index 0000000000..c12aa123b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-71.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-71 +description: > + Object.defineProperty - both desc.value and name.value are Ojbects + which refer to the same Object (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +var obj1 = { + length: 10 +}; + +Object.defineProperty(obj, "foo", { + value: obj1 +}); + +Object.defineProperty(obj, "foo", { + value: obj1 +}); +verifyEqualTo(obj, "foo", obj1); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js new file mode 100644 index 0000000000..36c4fe3a34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-72.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-72 +description: > + Object.defineProperty - desc.value and name.value are two Ojbects + which refer to the different objects (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +var obj1 = { + length: 10 +}; +obj.foo = obj1; // default value of attributes: writable: true, configurable: true, enumerable: true + +var obj2 = { + length: 20 +}; + +Object.defineProperty(obj, "foo", { + value: obj2 +}); +verifyEqualTo(obj, "foo", obj2); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js new file mode 100644 index 0000000000..e003f7060f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-73.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-73 +description: > + Object.defineProperty - both desc.writable and name.writable are + boolean values with the same value (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + writable: false +}); + +Object.defineProperty(obj, "foo", { + writable: false +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js new file mode 100644 index 0000000000..735ff9e36d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-74.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-74 +description: > + Object.defineProperty - desc.writable and name.writable are two + boolean values with different values (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + writable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + writable: true +}); +verifyEqualTo(obj, "foo", undefined); + +verifyWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js new file mode 100644 index 0000000000..ffb8fa59fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-75.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-75 +description: > + Object.defineProperty - both desc.[[Get]] and name.[[Get]] are two + objects which refer to the same object (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +function setFunc(value) { + obj.helpVerifySet = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc +}); + +Object.defineProperty(obj, "foo", { + get: getFunc +}); +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "helpVerifySet"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js new file mode 100644 index 0000000000..91a011f019 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-76.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-76 +description: > + Object.defineProperty - desc.[[Get]] and name.[[Get]] are two + objects which refer to the different objects (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc1() { + return 10; +} + +function setFunc1(value) { + obj.helpVerifySet = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc1, + set: setFunc1, + configurable: true +}); + +function getFunc2() { + return 20; +} + +Object.defineProperty(obj, "foo", { + get: getFunc2 +}); +verifyEqualTo(obj, "foo", getFunc2()); + +verifyWritable(obj, "foo", "helpVerifySet"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.js new file mode 100644 index 0000000000..11813c0338 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-77.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. + +/*--- +es5id: 15.2.3.6-4-77 +description: > + Object.defineProperty - both desc.[[Set]] and name.[[Set]] are two + objects which refer to the same object (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc +}); + +Object.defineProperty(obj, "foo", { + set: setFunc +}); +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js new file mode 100644 index 0000000000..9ffdeb435b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-78.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-78 +description: > + Object.defineProperty - desc.[[Set]] and name.[[Set]] are two + objects which refer to the different objects (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc1() {} + +Object.defineProperty(obj, "foo", { + set: setFunc1, + configurable: true +}); + +function setFunc2(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc2 +}); +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js new file mode 100644 index 0000000000..0295f90eef --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-79.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-79 +description: > + Object.defineProperty - both desc.enumerable and name.enumerable + are boolean values with the same value (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + enumerable: false +}); + +Object.defineProperty(obj, "foo", { + enumerable: false +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-8.js new file mode 100644 index 0000000000..42f3d2045c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-8.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 7b of [[DefineOwnProperty]] rejects if + current.[[Enumerable]] and desc.[[Enumerable]] are the boolean negations + of each other. +es5id: 15.2.3.6-4-8 +description: > + Object.defineProperty throws TypeError when changing + [[Enumerable]] from false to true on non-configurable data + properties +---*/ + +var o = {}; + +// create a data valued property; all other attributes default to false. +var d1 = { + value: 101, + enumerable: false, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// now, setting enumerable to true should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + value: 101, + enumerable: true +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.enumerable, false, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js new file mode 100644 index 0000000000..06c6f05859 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-80.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-80 +description: > + Object.defineProperty - desc.enumerable and name.enumerable are + boolean negation of each other (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js new file mode 100644 index 0000000000..bb04cb882d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-81.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-81 +description: > + Object.defineProperty - both desc.configurable and + name.configurable are booleans with the same value (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + configurable: false +}); + +Object.defineProperty(obj, "foo", { + configurable: false +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js new file mode 100644 index 0000000000..b2a9b4b8ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-1.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-1 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains [[Enumerable]] + attribute as false, 'name' property is a data property (8.12.9 + step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js new file mode 100644 index 0000000000..4c2395e14d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-10.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-10 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as true and [[Configurable]] attribute is false, 'name' + property is an accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js new file mode 100644 index 0000000000..0fefd5de68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-11.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-11 +description: > + Object.defineProperty - Update [[Enumerable]] and [[Configurable]] + attributes of 'name' property to false successfully when + [[Enumerable]] and [[Configurable]] attributes of 'name' property + are true, the 'desc' is a generic descriptor which contains + [[Enumerable]] and [[Configurable]] attributes as false, 'name' + property is an accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: false +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js new file mode 100644 index 0000000000..ba8dd041b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-12.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-12 +description: > + Object.defineProperty - Update [[Enumerable]] attributes of 'name' + property to true successfully when [[Enumerable]] attribute of + 'name' is false and [[Configurable]] attribute of 'name' is true, + the 'desc' is a generic descriptor which only contains + [[Enumerable]] attribute as true, 'name' property is an accessor + property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js new file mode 100644 index 0000000000..4e954f0939 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-13.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-13 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains [[Enumerable]] + attribute as false, 'name' property is an index data property + (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js new file mode 100644 index 0000000000..b91f538d57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-14.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-14 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as false and [[Configurable]] attribute as true, 'name' + property is an index data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false, + configurable: true +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js new file mode 100644 index 0000000000..5a88b4781c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-15.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-15 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Configurable]] + attribute of 'name' property is true, the 'desc' is a generic + descriptor which contains [[Configurable]] attribute as false, + 'name' property is an index data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + configurable: false +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js new file mode 100644 index 0000000000..fe07c56e74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-16.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-16 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as true and [[Configurable]] attribute as false, 'name' + property is an index data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js new file mode 100644 index 0000000000..de43ae8048 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-17.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-17 +description: > + Object.defineProperty - Update [[Enumerable]] and [[Configurable]] + attributes of 'name' property to false successfully when + [[Enumerable]] and [[Configurable]] attributes of 'name' property + are true, the 'desc' is a generic descriptor which contains + [[Enumerable]] and [[Configurable]] attributes as false, 'name' + property is an index data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false, + configurable: false +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyNotEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js new file mode 100644 index 0000000000..30b44c922c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-18.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-18 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to true successfully when [[Enumerable]] attribute of + 'name' is false and [[Configurable]] attribute of 'name' is true, + the 'desc' is a generic descriptor which only contains + [[Enumerable]] attribute as true, 'name' property is an index data + property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "0", { + value: 1001, + writable: true, + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: true +}); + +verifyEqualTo(obj, "0", 1001); + +verifyWritable(obj, "0"); + +verifyEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js new file mode 100644 index 0000000000..b8776f7da0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-19.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-19 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains [Enumerable]] + attribute as false and 'name' property is an index accessor + property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js new file mode 100644 index 0000000000..e5093aeec7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-2.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-2 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as false and [[Configurable]] attribute as true, 'name' + property is a data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: true +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js new file mode 100644 index 0000000000..4b4ee70a99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-20.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-20 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [Enumerable]] + attribute as false and [[Configurable]] property is true, 'name' + property is an index accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false, + configurable: true +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyNotEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js new file mode 100644 index 0000000000..f4d984ef54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-21.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-21 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains + [[Configurable]] attribute as false, 'name' property is an index + accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + configurable: false +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js new file mode 100644 index 0000000000..4df84cf130 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-22.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-22 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as true and [[Configurable]] attribute is false, 'name' + property is an index accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js new file mode 100644 index 0000000000..a313d8ed02 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-23.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-23 +description: > + Object.defineProperty - Update [[Enumerable]] and [[Configurable]] + attributes of 'name' property to false successfully when + [[Enumerable]] and [[Configurable]] attributes of 'name' property + are true, the 'desc' is a generic descriptor which contains + [[Enumerable]] and [[Configurable]] attributes as false, 'name' + property is an index accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: false, + configurable: false +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyNotEnumerable(obj, "0"); + +verifyNotConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js new file mode 100644 index 0000000000..fd2e6d537b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-24.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-24 +description: > + Object.defineProperty - Update [[Enumerable]] attributes of 'name' + property to true successfully when [[Enumerable]] attribute of + 'name' is false and [[Configurable]] attribute of 'name' is true, + the 'desc' is a generic descriptor which only contains + [[Enumerable]] attribute as true, 'name' property is an index + accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "0", { + get: get_func, + set: set_func, + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "0", { + enumerable: true +}); + +verifyEqualTo(obj, "0", get_func()); + +verifyWritable(obj, "0", "verifySetFunction"); + +verifyEnumerable(obj, "0"); + +verifyConfigurable(obj, "0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js new file mode 100644 index 0000000000..f031e54a38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-3.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-3 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Configurable]] + attribute of 'name' property is true, the 'desc' is a generic + descriptor which contains [[Configurable]] attribute as false, + 'name' property is a data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + configurable: false +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js new file mode 100644 index 0000000000..9e6bd3600a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-4.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-4 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [[Enumerable]] + attribute as true and [[Configurable]] attribute as false, 'name' + property is a data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true, + configurable: false +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js new file mode 100644 index 0000000000..d0dae554c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-5.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-5 +description: > + Object.defineProperty - Update [[Enumerable]] and [[Configurable]] + attributes of 'name' property to false successfully when + [[Enumerable]] and [[Configurable]] attributes of 'name' property + are true, the 'desc' is a generic descriptor which contains + [[Enumerable]] and [[Configurable]] attributes as false, 'name' + property is a data property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: false +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js new file mode 100644 index 0000000000..265df4a1bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-6.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-6 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to true successfully when [[Enumerable]] attribute of + 'name' is false and [[Configurable]] attribute of 'name' is true, + the 'desc' is a generic descriptor which only contains + [[Enumerable]] attribute as true, 'name' property is a data + property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 1001, + writable: true, + enumerable: false, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: true +}); + +verifyEqualTo(obj, "foo", 1001); + +verifyWritable(obj, "foo"); + +verifyEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js new file mode 100644 index 0000000000..72e6355d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-7.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-7 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains [Enumerable]] + attribute as false and 'name' property is an accessor property + (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js new file mode 100644 index 0000000000..1238652846 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-8.js @@ -0,0 +1,45 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-8 +description: > + Object.defineProperty - Update [[Enumerable]] attribute of 'name' + property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which contains [Enumerable]] + attribute as false and [[Configurable]] property is true, 'name' + property is an accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + enumerable: false, + configurable: true +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyNotEnumerable(obj, "foo"); + +verifyConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js new file mode 100644 index 0000000000..7f7b8b7a1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82-9.js @@ -0,0 +1,44 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82-9 +description: > + Object.defineProperty - Update [[Configurable]] attribute of + 'name' property to false successfully when [[Enumerable]] and + [[Configurable]] attributes of 'name' property are true, the + 'desc' is a generic descriptor which only contains + [[Configurable]] attribute as false, 'name' property is an + accessor property (8.12.9 step 8) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; +obj.verifySetFunction = "data"; +var get_func = function() { + return obj.verifySetFunction; +}; +var set_func = function(value) { + obj.verifySetFunction = value; +}; +Object.defineProperty(obj, "foo", { + get: get_func, + set: set_func, + enumerable: true, + configurable: true +}); + +Object.defineProperty(obj, "foo", { + configurable: false +}); + +verifyEqualTo(obj, "foo", get_func()); + +verifyWritable(obj, "foo", "verifySetFunction"); + +verifyEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js new file mode 100644 index 0000000000..f80c1afff1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-82.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-82 +description: > + Object.defineProperty - desc.configurable and name.configurable + are boolean negation of each other (8.12.9 step 6) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + configurable: true +}); + +Object.defineProperty(obj, "foo", { + configurable: false +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js new file mode 100644 index 0000000000..c9fb22b3d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-83.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-83 +description: > + Object.defineProperty will not throw TypeError if + name.configurable = false, name.writable = false, name.value = + undefined and desc.value = undefined (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: undefined, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: undefined, + writable: false, + configurable: false +}); +verifyEqualTo(obj, "foo", undefined); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js new file mode 100644 index 0000000000..fdb49395ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-84.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-84 +description: > + Object.defineProperty will not throw TypeError if + name.configurable = false, name.writable = false, name.value = + null and desc.value = null (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: null, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: null, + writable: false, + configurable: false +}); +verifyEqualTo(obj, "foo", null); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js new file mode 100644 index 0000000000..882a018143 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-85.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-85 +description: > + Object.defineProperty will not throw TypeError if + name.configurable = false, name.writable = false, name.value = NaN + and desc.value = NaN (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: NaN, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: NaN, + writable: false, + configurable: false +}); + +assert.sameValue(obj.foo, NaN); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js new file mode 100644 index 0000000000..1bf35f3460 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-86.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-86 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value = +0 and name.value = + -0 (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: -0, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(obj, "foo", { + value: +0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", -0); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js new file mode 100644 index 0000000000..cbf3421f4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-87.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-87 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value = -0 and name.value = + +0 (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: +0, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(obj, "foo", { + value: -0 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", +0); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js new file mode 100644 index 0000000000..27b56ee337 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-88.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-88 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, name.writable = false, desc.value and + name.value are two numbers with the same value (8.12.9 step + 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 100, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: 100 +}); +verifyEqualTo(obj, "foo", 100); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js new file mode 100644 index 0000000000..a8b3ba707f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-89.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-89 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value and name.value are two + numbers with different values (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: 10, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(obj, "foo", { + value: 20 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", 10); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-9.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-9.js new file mode 100644 index 0000000000..82bc4ff57c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-9.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method + of O to define the property. Step 7b of [[DefineOwnProperty]] rejects if + current.[[Enumerable]] and desc.[[Enumerable]] are the boolean negations + of each other. +es5id: 15.2.3.6-4-9 +description: > + Object.defineProperty throws TypeError when changing + [[Enumerable]] from true to false on non-configurable data + properties +---*/ + +var o = {}; + +// create a data valued property with [[Enumerable]] explicitly set to true; +// all other attributes default to false. +var d1 = { + value: 101, + enumerable: true, + configurable: false +}; +Object.defineProperty(o, "foo", d1); + +// now, setting enumerable to false should fail, since [[Configurable]] +// on the original property will be false. +var desc = { + value: 101, + enumerable: false +}; +assert.throws(TypeError, function() { + Object.defineProperty(o, "foo", desc); +}); +// the property should remain unchanged. +var d2 = Object.getOwnPropertyDescriptor(o, "foo"); +assert.sameValue(d2.value, 101, 'd2.value'); +assert.sameValue(d2.enumerable, true, 'd2.enumerable'); +assert.sameValue(d2.configurable, false, 'd2.configurable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js new file mode 100644 index 0000000000..07438a7406 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-90.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-90 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, name.writable = false, desc.value and + name.value are two strings with the same value (8.12.9 step + 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: "abcd", + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: "abcd" +}); +verifyEqualTo(obj, "foo", "abcd"); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js new file mode 100644 index 0000000000..665ae48b79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-91.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-91 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value and name.value are two + strings with different values (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: "abcd", + writable: false, + configurable: false +}); + +try { + Object.defineProperty(obj, "foo", { + value: "fghj" + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", "abcd"); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js new file mode 100644 index 0000000000..780ad68e54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-92.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-92 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, name.writable = false, desc.value and + name.value are two booleans with the same value (8.12.9 step + 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: false, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: false +}); +verifyEqualTo(obj, "foo", false); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js new file mode 100644 index 0000000000..27113a056f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-93.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-93 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value and name.value are two + booleans with different values (8.12.9 step 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +Object.defineProperty(obj, "foo", { + value: false, + writable: false, + configurable: false +}); + +try { + Object.defineProperty(obj, "foo", { + value: true + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", false); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js new file mode 100644 index 0000000000..6a3a90950d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-94.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-94 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, name.writable = false, desc.value and + name.value are two Objects refer to the same object (8.12.9 step + 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +var obj1 = { + length: 10 +}; + +Object.defineProperty(obj, "foo", { + value: obj1, + writable: false, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + value: obj1 +}); +verifyEqualTo(obj, "foo", obj1); + +verifyNotWritable(obj, "foo"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js new file mode 100644 index 0000000000..9590be199b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.js @@ -0,0 +1,51 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-95 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.writable = false, desc.value and name.value are two + objects which refer to the different objects (8.12.9 step + 10.a.ii.1) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +var obj1 = { + length: 10 +}; + +Object.defineProperty(obj, "foo", { + value: obj1, + writable: false, + configurable: false +}); + +var obj2 = { + length: 20 +}; + +try { + Object.defineProperty(obj, "foo", { + value: obj2 + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "foo", obj1); + + verifyNotWritable(obj, "foo"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js new file mode 100644 index 0000000000..6cc17c467e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-96.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-96 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, both desc.[[Set]] and name.[[Set]] are + two objects which refer to the same object (8.12.9 step 11.a.i) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + set: setFunc +}); +verifyWritable(obj, "foo", "setVerifyHelpProp"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js new file mode 100644 index 0000000000..6e3d07a24b --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-97.js @@ -0,0 +1,46 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-97 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.[[Set]] is undefined, desc.[[Set]] refers to an + object (8.12.9 step 11.a.i) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return "property"; +} + +Object.defineProperty(obj, "property", { + get: getFunc, + configurable: false +}); + +try { + Object.defineProperty(obj, "property", { + get: getFunc, + set: function() {}, + configurable: false + }); + + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyEqualTo(obj, "property", getFunc()); + + verifyNotEnumerable(obj, "property"); + + verifyNotConfigurable(obj, "property"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js new file mode 100644 index 0000000000..0b54b241d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-98.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-98 +description: > + Object.defineProperty will not throw TypeError when + name.configurable = false, both desc.[[Get]] and name.[[Get]] are + two objects which refer to the same object (8.12.9 step 11.a.ii) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function getFunc() { + return 10; +} + +function setFunc(value) { + obj.verifyGetHelpMethod = value; +} + +Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc, + configurable: false +}); + +Object.defineProperty(obj, "foo", { + get: getFunc +}); + +verifyEqualTo(obj, "foo", getFunc()); + +verifyWritable(obj, "foo", "verifyGetHelpMethod"); + +verifyNotEnumerable(obj, "foo"); + +verifyNotConfigurable(obj, "foo"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js new file mode 100644 index 0000000000..bc8efa7208 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-99.js @@ -0,0 +1,48 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6-4-99 +description: > + Object.defineProperty will throw TypeError when name.configurable + = false, name.[[Get]] is undefined, desc.[[Get]] refers to an + object (8.12.9 step 11.a.ii) +includes: [propertyHelper.js] +---*/ + + +var obj = {}; + +function setFunc(value) { + obj.setVerifyHelpProp = value; +} + +Object.defineProperty(obj, "foo", { + set: setFunc, + configurable: false +}); + +function getFunc() { + return 10; +} + +try { + Object.defineProperty(obj, "foo", { + get: getFunc, + set: setFunc + }); + throw new Test262Error("Expected an exception."); +} catch (e) { + verifyWritable(obj, "foo", "setVerifyHelpProp"); + + verifyNotEnumerable(obj, "foo"); + + verifyNotConfigurable(obj, "foo"); + + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_1.js b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_1.js new file mode 100644 index 0000000000..83670f1a5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_1.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.12.9-9-b-i_1 +description: > + Redefine a configurable data property to be an accessor property + on a newly non-extensible object +---*/ + +var o = {}; +Object.defineProperty(o, "foo", +{ + value: "hello", + configurable: true +}); +Object.preventExtensions(o); +Object.defineProperty(o, "foo", { + get: function() { + return 5; + } +}); + +var fooDescrip = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(o.foo, 5, 'o.foo'); +assert(fooDescrip.get !== undefined, 'fooDescrip.get!==undefined !== true'); +assert.sameValue(fooDescrip.set, undefined, 'fooDescrip.set'); +assert.sameValue(fooDescrip.value, undefined, 'fooDescrip.value'); +assert.sameValue(fooDescrip.configurable, true, 'fooDescrip.configurable'); +assert.sameValue(fooDescrip.enumerable, false, 'fooDescrip.enumerable'); +assert.sameValue(fooDescrip.writable, undefined, 'fooDescrip.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_2.js b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_2.js new file mode 100644 index 0000000000..143c79bf64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-b-i_2.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.12.9-9-b-i_2 +description: > + Redefine a configurable data property to be an accessor property + on a newly non-extensible object +---*/ + +var o = {}; +Object.defineProperty(o, "foo", +{ + value: "hello", + configurable: true, + enumerable: true, + writable: true +}); +Object.preventExtensions(o); +Object.defineProperty(o, "foo", { + get: function() { + return 5; + } +}); + +var fooDescrip = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(o.foo, 5, 'o.foo'); +assert(fooDescrip.get !== undefined, 'fooDescrip.get!==undefined !== true'); +assert.sameValue(fooDescrip.set, undefined, 'fooDescrip.set'); +assert.sameValue(fooDescrip.value, undefined, 'fooDescrip.value'); +assert.sameValue(fooDescrip.configurable, true, 'fooDescrip.configurable'); +assert.sameValue(fooDescrip.enumerable, true, 'fooDescrip.enumerable'); +assert.sameValue(fooDescrip.writable, undefined, 'fooDescrip.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_1.js b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_1.js new file mode 100644 index 0000000000..bae31d5774 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_1.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.12.9-9-c-i_1 +description: > + Redefine a configurable accessor property to be a data property on + a non-extensible object +---*/ + +var o = {}; +Object.defineProperty(o, "foo", +{ + get: function() { + return 5; + }, + configurable: true +}); +Object.preventExtensions(o); +Object.defineProperty(o, "foo", { + value: "hello" +}); + +var fooDescrip = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(o.foo, "hello", 'o.foo'); +assert.sameValue(fooDescrip.get, undefined, 'fooDescrip.get'); +assert.sameValue(fooDescrip.set, undefined, 'fooDescrip.set'); +assert.sameValue(fooDescrip.value, "hello", 'fooDescrip.value'); +assert.sameValue(fooDescrip.configurable, true, 'fooDescrip.configurable'); +assert.sameValue(fooDescrip.enumerable, false, 'fooDescrip.enumerable'); +assert.sameValue(fooDescrip.writable, false, 'fooDescrip.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_2.js b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_2.js new file mode 100644 index 0000000000..76eb3119b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/8.12.9-9-c-i_2.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 8.12.9-9-c-i_2 +description: > + Redefine a configurable accessor property to be a data property on + a non-extensible object +---*/ + +var o = {}; +Object.defineProperty(o, "foo", +{ + get: function() { + return 5; + }, + configurable: true +}); +Object.preventExtensions(o); +Object.defineProperty(o, "foo", +{ + value: "hello", + writable: true +}); + +var fooDescrip = Object.getOwnPropertyDescriptor(o, "foo"); + +assert.sameValue(o.foo, "hello", 'o.foo'); +assert.sameValue(fooDescrip.get, undefined, 'fooDescrip.get'); +assert.sameValue(fooDescrip.set, undefined, 'fooDescrip.set'); +assert.sameValue(fooDescrip.value, "hello", 'fooDescrip.value'); +assert.sameValue(fooDescrip.configurable, true, 'fooDescrip.configurable'); +assert.sameValue(fooDescrip.enumerable, false, 'fooDescrip.enumerable'); +assert.sameValue(fooDescrip.writable, true, 'fooDescrip.writable'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A1.js b/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A1.js new file mode 100644 index 0000000000..e57b9345ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A1.js @@ -0,0 +1,38 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If a particular API exists (document.createElement, as happens to + exist in a browser environment), check if the form objects it makes + obey the constraints that even host objects must obey. In this + case, that if defineProperty seems to have successfully installed a + non-configurable getter, that it is still there. +es5id: 15.2.3.6_A1 +description: Do getters on HTMLFormElements disappear? +---*/ + +function getter() { + return 'gotten'; +} + +if (typeof document !== 'undefined' && + typeof document.createElement === 'function') { + var f = document.createElement("form"); + var refused = false; + try { + Object.defineProperty(f, 'foo', { + get: getter, + set: void 0 + }); + } catch (err) { + // A host object may refuse to install the getter + refused = true; + } + if (!refused) { + var desc = Object.getOwnPropertyDescriptor(f, 'foo'); + assert.sameValue(desc.get, getter, 'The value of desc.get is expected to equal the value of getter'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A2.js b/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A2.js new file mode 100644 index 0000000000..ea75252e6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A2.js @@ -0,0 +1,26 @@ +// Copyright 2011 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.2.3.6_A2 +description: > + Checks if an inherited accessor property appears to be an own + property. +---*/ + +var base = {}; +var derived = Object.create(base); + +function getter() { + return 'gotten'; +} +Object.defineProperty(base, 'foo', { + get: getter +}); + +assert( + !derived.hasOwnProperty('foo'), + 'The value of !derived.hasOwnProperty("foo") is expected to be true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/browser.js b/js/src/tests/test262/built-ins/Object/defineProperty/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/browser.js diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/name.js b/js/src/tests/test262/built-ins/Object/defineProperty/name.js new file mode 100644 index 0000000000..93e3066236 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.1.2.4 +description: > + Object.defineProperty.name is "defineProperty". +info: | + Object.defineProperty ( O, P, Attributes ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Object.defineProperty.name, "defineProperty"); + +verifyNotEnumerable(Object.defineProperty, "name"); +verifyNotWritable(Object.defineProperty, "name"); +verifyConfigurable(Object.defineProperty, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js b/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js new file mode 100644 index 0000000000..8c49a7085c --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Object.defineProperty does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Object.defineProperty), + false, + 'isConstructor(Object.defineProperty) must return false' +); + +assert.throws(TypeError, () => { + new Object.defineProperty({}, '', {}); +}, '`new Object.defineProperty({}, \'\', {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js new file mode 100644 index 0000000000..d9b55b268f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-bigint.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (bigint) +info: | + Object.defineProperty ( O, P, Attributes ) + + ... + Let desc be ? ToPropertyDescriptor(Attributes). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [BigInt] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', 0n); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js new file mode 100644 index 0000000000..801a934006 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-false.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (false) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js new file mode 100644 index 0000000000..21daf0d268 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-null.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (null) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js new file mode 100644 index 0000000000..f9339187d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-number.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (number) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js new file mode 100644 index 0000000000..953c60f41f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-string.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (string) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js new file mode 100644 index 0000000000..b1c491dd56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-symbol.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (symbol) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js new file mode 100644 index 0000000000..7c96153db7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-true.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (true) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', true); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js new file mode 100644 index 0000000000..8dc081ebd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/property-description-must-be-an-object-not-undefined.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-object.defineproperty +description: > + Property description must be an object (undefined) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperty({}, 'a', undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/redefine-length-with-various-values-and-configurable-true.js b/js/src/tests/test262/built-ins/Object/defineProperty/redefine-length-with-various-values-and-configurable-true.js new file mode 100644 index 0000000000..efb7dcf9be --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/redefine-length-with-various-values-and-configurable-true.js @@ -0,0 +1,40 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +description: > + Redefining "length" to `configurable: true` throws a TypeError exception +info: | + ArraySetLength ( A, Desc ) + + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) +---*/ + +let a = [1]; + +assert.throws(TypeError, () => { + Object.defineProperty(a, "length", { + configurable: true + }); +}); +assert.throws(TypeError, () => { + Object.defineProperty(a, "length", { + value: 1, + configurable: true + }); +}); +assert.throws(TypeError, () => { + Object.defineProperty(a, "length", { + value: 2, + configurable: true + }); +}); +assert.throws(TypeError, () => { + Object.defineProperty(a, "length", { + value: 3, + configurable: true + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/shell.js b/js/src/tests/test262/built-ins/Object/defineProperty/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/shell.js diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-configurable.js b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-configurable.js new file mode 100644 index 0000000000..b0b381fb8f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-configurable.js @@ -0,0 +1,41 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.2.4 +description: > + Symbol used as property for configurable data property definition +features: [Symbol] +includes: [propertyHelper.js] +---*/ +var sym = Symbol(); +var obj = {}; + + +Object.defineProperty(obj, sym, { + value: 1, + configurable: true +}); + +assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`"); +verifyProperty(obj, sym, { + value: 1, + configurable: true, + writable: false, + enumerable: false, +}); + +assert.sameValue( + Object.prototype.propertyIsEnumerable.call(obj, sym), + false, + "`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`" +); + +assert.sameValue(delete obj[sym], true, "The result of `delete obj[sym]` is `true`"); + +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, sym), + undefined, + "`Object.getOwnPropertyDescriptor(obj, sym)` returns `undefined`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js new file mode 100644 index 0000000000..ce9d9cc91f --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-non-strict.js @@ -0,0 +1,45 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.2.4 +description: > + Symbol used as property for property definition +flags: [noStrict] +features: [Symbol] +includes: [propertyHelper.js] +---*/ +var sym = Symbol(); +var obj = {}; + + +Object.defineProperty(obj, sym, { + value: 1, +}); + +assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`"); +verifyProperty(obj, sym, { + value: 1, + configurable: false, + writable: false, + enumerable: false, +}); + +assert.sameValue( + Object.prototype.propertyIsEnumerable.call(obj, sym), + false, + "`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`" +); + +assert.sameValue(delete obj[sym], false, "The result of `delete obj[sym]` is `false`"); + +assert.notSameValue( + Object.getOwnPropertyDescriptor(obj, sym), + undefined, + "`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`" +); + +obj[sym] = 2; + +assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-strict-strict.js b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-strict-strict.js new file mode 100644 index 0000000000..9e6e7a4b81 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-default-strict-strict.js @@ -0,0 +1,50 @@ +'use strict'; +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.2.4 +description: > + Symbol used as property for default data property definition +flags: [onlyStrict] +features: [Symbol] +includes: [propertyHelper.js] +---*/ +var sym = Symbol(); +var obj = {}; + + +Object.defineProperty(obj, sym, { + value: 1, +}); + +assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`"); +verifyProperty(obj, sym, { + value: 1, + configurable: false, + writable: false, + enumerable: false, +}); + +assert.sameValue( + Object.prototype.propertyIsEnumerable.call(obj, sym), + false, + "`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`" +); + +assert.throws(TypeError, function() { + delete obj[sym]; +}); + +assert.notSameValue( + Object.getOwnPropertyDescriptor(obj, sym), + undefined, + "`Object.getOwnPropertyDescriptor(obj, sym)` does not return `undefined`" +); + +assert.throws(TypeError, function() { + obj[sym] = 2; +}); + +assert.sameValue(obj[sym], 1, "The value of `obj[sym]` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-writable.js b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-writable.js new file mode 100644 index 0000000000..1d8436bf15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/defineProperty/symbol-data-property-writable.js @@ -0,0 +1,37 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.1.2.4 +description: > + Symbol used as property for writable data property definition +features: [Symbol] +includes: [propertyHelper.js] +---*/ +var sym = Symbol(); +var obj = {}; + + +Object.defineProperty(obj, sym, { + value: 1, + writable: true +}); + +assert.sameValue(sym in obj, true, "The result of `sym in obj` is `true`"); +verifyProperty(obj, sym, { + value: 1, + configurable: false, + writable: true, + enumerable: false, +}); + +assert.sameValue( + Object.prototype.propertyIsEnumerable.call(obj, sym), + false, + "`Object.prototype.propertyIsEnumerable.call(obj, sym)` returns `false`" +); + +obj[sym] = 2; + +assert.sameValue(obj[sym], 2, "The value of `obj[sym]` is `2`"); + +reportCompare(0, 0); |