From 3211e331993460150f736a1f8adb4351b0a03ef0 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 21 Apr 2015 15:22:35 -0400 Subject: [PATCH] Add tests for test harness --- test/harness/assert-false.js | 25 +++++++++++++ test/harness/assert-notsamevalue-nan.js | 25 +++++++++++++ test/harness/assert-notsamevalue-notsame.js | 14 +++++++ test/harness/assert-notsamevalue-objects.js | 9 +++++ test/harness/assert-notsamevalue-zeros.js | 9 +++++ test/harness/assert-obj.js | 25 +++++++++++++ test/harness/assert-samevalue-nan.js | 9 +++++ test/harness/assert-samevalue-objects.js | 25 +++++++++++++ test/harness/assert-samevalue-same.js | 18 +++++++++ test/harness/assert-samevalue-zeros.js | 25 +++++++++++++ test/harness/assert-throws-custom.js | 14 +++++++ test/harness/assert-throws-incorrect-ctor.js | 28 ++++++++++++++ test/harness/assert-throws-native.js | 36 ++++++++++++++++++ test/harness/assert-throws-no-arg.js | 25 +++++++++++++ test/harness/assert-throws-no-error.js | 25 +++++++++++++ test/harness/assert-throws-null.js | 27 ++++++++++++++ test/harness/assert-throws-primitive.js | 27 ++++++++++++++ test/harness/assert-throws-single-arg.js | 25 +++++++++++++ test/harness/assert-true.js | 9 +++++ .../compare-array-different-elements.js | 15 ++++++++ .../harness/compare-array-different-length.js | 16 ++++++++ test/harness/compare-array-empty.js | 12 ++++++ ...are-array-same-elements-different-order.js | 16 ++++++++ .../compare-array-same-elements-same-order.js | 16 ++++++++ test/harness/compare-array-sparse.js | 28 ++++++++++++++ test/harness/error.js | 29 +++++++++++++++ ...yhelper-verifyconfigurable-configurable.js | 15 ++++++++ ...onfigurable-not-configurable-not-strict.js | 32 ++++++++++++++++ ...ifyconfigurable-not-configurable-strict.js | 32 ++++++++++++++++ ...pertyhelper-verifyenumerable-enumerable.js | 15 ++++++++ ...yhelper-verifyenumerable-not-enumerable.js | 31 ++++++++++++++++ ...lper-verifynotconfigurable-configurable.js | 31 ++++++++++++++++ ...onfigurable-not-configurable-not-strict.js | 17 +++++++++ ...notconfigurable-not-configurable-strict.js | 17 +++++++++ ...tyhelper-verifynotenumerable-enumerable.js | 31 ++++++++++++++++ ...lper-verifynotenumerable-not-enumerable.js | 15 ++++++++ ...rifynotwritable-not-writable-not-strict.js | 23 ++++++++++++ ...r-verifynotwritable-not-writable-strict.js | 23 ++++++++++++ ...opertyhelper-verifynotwritable-writable.js | 31 ++++++++++++++++ ...-verifywritable-not-writable-not-strict.js | 32 ++++++++++++++++ ...lper-verifywritable-not-writable-strict.js | 32 ++++++++++++++++ .../propertyhelper-verifywritable-writable.js | 21 +++++++++++ .../testbuiltinobject-function-badstring.js | 27 ++++++++++++++ ...tbuiltinobject-function-expected-length.js | 27 ++++++++++++++ ...bject-function-not-constructor-no-error.js | 27 ++++++++++++++ ...t-function-not-constructor-no-typeerror.js | 30 +++++++++++++++ .../testbuiltinobject-non-extensible.js | 28 ++++++++++++++ ...estbuiltinobject-not-function-badstring.js | 27 ++++++++++++++ .../testbuiltinobject-prop-enumerable.js | 37 +++++++++++++++++++ .../harness/testbuiltinobject-prop-missing.js | 34 +++++++++++++++++ ...testbuiltinobject-prop-not-configurable.js | 37 +++++++++++++++++++ .../testbuiltinobject-prop-not-writable.js | 37 +++++++++++++++++++ test/harness/testbuiltinobject-undefined.js | 26 +++++++++++++ 53 files changed, 1267 insertions(+) create mode 100644 test/harness/assert-false.js create mode 100644 test/harness/assert-notsamevalue-nan.js create mode 100644 test/harness/assert-notsamevalue-notsame.js create mode 100644 test/harness/assert-notsamevalue-objects.js create mode 100644 test/harness/assert-notsamevalue-zeros.js create mode 100644 test/harness/assert-obj.js create mode 100644 test/harness/assert-samevalue-nan.js create mode 100644 test/harness/assert-samevalue-objects.js create mode 100644 test/harness/assert-samevalue-same.js create mode 100644 test/harness/assert-samevalue-zeros.js create mode 100644 test/harness/assert-throws-custom.js create mode 100644 test/harness/assert-throws-incorrect-ctor.js create mode 100644 test/harness/assert-throws-native.js create mode 100644 test/harness/assert-throws-no-arg.js create mode 100644 test/harness/assert-throws-no-error.js create mode 100644 test/harness/assert-throws-null.js create mode 100644 test/harness/assert-throws-primitive.js create mode 100644 test/harness/assert-throws-single-arg.js create mode 100644 test/harness/assert-true.js create mode 100644 test/harness/compare-array-different-elements.js create mode 100644 test/harness/compare-array-different-length.js create mode 100644 test/harness/compare-array-empty.js create mode 100644 test/harness/compare-array-same-elements-different-order.js create mode 100644 test/harness/compare-array-same-elements-same-order.js create mode 100644 test/harness/compare-array-sparse.js create mode 100644 test/harness/error.js create mode 100644 test/harness/propertyhelper-verifyconfigurable-configurable.js create mode 100644 test/harness/propertyhelper-verifyconfigurable-not-configurable-not-strict.js create mode 100644 test/harness/propertyhelper-verifyconfigurable-not-configurable-strict.js create mode 100644 test/harness/propertyhelper-verifyenumerable-enumerable.js create mode 100644 test/harness/propertyhelper-verifyenumerable-not-enumerable.js create mode 100644 test/harness/propertyhelper-verifynotconfigurable-configurable.js create mode 100644 test/harness/propertyhelper-verifynotconfigurable-not-configurable-not-strict.js create mode 100644 test/harness/propertyhelper-verifynotconfigurable-not-configurable-strict.js create mode 100644 test/harness/propertyhelper-verifynotenumerable-enumerable.js create mode 100644 test/harness/propertyhelper-verifynotenumerable-not-enumerable.js create mode 100644 test/harness/propertyhelper-verifynotwritable-not-writable-not-strict.js create mode 100644 test/harness/propertyhelper-verifynotwritable-not-writable-strict.js create mode 100644 test/harness/propertyhelper-verifynotwritable-writable.js create mode 100644 test/harness/propertyhelper-verifywritable-not-writable-not-strict.js create mode 100644 test/harness/propertyhelper-verifywritable-not-writable-strict.js create mode 100644 test/harness/propertyhelper-verifywritable-writable.js create mode 100644 test/harness/testbuiltinobject-function-badstring.js create mode 100644 test/harness/testbuiltinobject-function-expected-length.js create mode 100644 test/harness/testbuiltinobject-function-not-constructor-no-error.js create mode 100644 test/harness/testbuiltinobject-function-not-constructor-no-typeerror.js create mode 100644 test/harness/testbuiltinobject-non-extensible.js create mode 100644 test/harness/testbuiltinobject-not-function-badstring.js create mode 100644 test/harness/testbuiltinobject-prop-enumerable.js create mode 100644 test/harness/testbuiltinobject-prop-missing.js create mode 100644 test/harness/testbuiltinobject-prop-not-configurable.js create mode 100644 test/harness/testbuiltinobject-prop-not-writable.js create mode 100644 test/harness/testbuiltinobject-undefined.js diff --git a/test/harness/assert-false.js b/test/harness/assert-false.js new file mode 100644 index 0000000000..93b8205813 --- /dev/null +++ b/test/harness/assert-false.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `false` does not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert(false); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-notsamevalue-nan.js b/test/harness/assert-notsamevalue-nan.js new file mode 100644 index 0000000000..856cc482c7 --- /dev/null +++ b/test/harness/assert-notsamevalue-nan.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Two references to NaN do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.notSameValue(NaN, NaN); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-notsamevalue-notsame.js b/test/harness/assert-notsamevalue-notsame.js new file mode 100644 index 0000000000..ae222b15d6 --- /dev/null +++ b/test/harness/assert-notsamevalue-notsame.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Values that are not strictly equal satisfy the assertion. +---*/ + +assert.notSameValue(undefined, null); +assert.notSameValue(null, undefined); +assert.notSameValue(0, 1); +assert.notSameValue(1, 0); +assert.notSameValue('', 's'); +assert.notSameValue('s', ''); diff --git a/test/harness/assert-notsamevalue-objects.js b/test/harness/assert-notsamevalue-objects.js new file mode 100644 index 0000000000..1e4fb54a99 --- /dev/null +++ b/test/harness/assert-notsamevalue-objects.js @@ -0,0 +1,9 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Distinct objects satisfy the assertion. +---*/ + +assert.notSameValue({}, {}); diff --git a/test/harness/assert-notsamevalue-zeros.js b/test/harness/assert-notsamevalue-zeros.js new file mode 100644 index 0000000000..9a2d105429 --- /dev/null +++ b/test/harness/assert-notsamevalue-zeros.js @@ -0,0 +1,9 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Positive and negative zero satisfy the assertion. +---*/ + +assert.notSameValue(0, -0); diff --git a/test/harness/assert-obj.js b/test/harness/assert-obj.js new file mode 100644 index 0000000000..edaf82fc69 --- /dev/null +++ b/test/harness/assert-obj.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + An object literal does not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert({}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-samevalue-nan.js b/test/harness/assert-samevalue-nan.js new file mode 100644 index 0000000000..8ca9e56e6e --- /dev/null +++ b/test/harness/assert-samevalue-nan.js @@ -0,0 +1,9 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Two references to NaN satisfy the assertion. +---*/ + +assert.sameValue(NaN, NaN); diff --git a/test/harness/assert-samevalue-objects.js b/test/harness/assert-samevalue-objects.js new file mode 100644 index 0000000000..833f864b4d --- /dev/null +++ b/test/harness/assert-samevalue-objects.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Distinct objects do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.sameValue({}, {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-samevalue-same.js b/test/harness/assert-samevalue-same.js new file mode 100644 index 0000000000..0e38a9cef7 --- /dev/null +++ b/test/harness/assert-samevalue-same.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Values that are strictly equal satisfy the assertion. +---*/ +var obj; + +assert.sameValue(undefined, undefined); +assert.sameValue(null, null); +assert.sameValue(0, 0); +assert.sameValue(1, 1); +assert.sameValue('', ''); +assert.sameValue('s', 's'); + +obj = {}; +assert.sameValue(obj, obj); diff --git a/test/harness/assert-samevalue-zeros.js b/test/harness/assert-samevalue-zeros.js new file mode 100644 index 0000000000..a4a44a031d --- /dev/null +++ b/test/harness/assert-samevalue-zeros.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Positive and negative zero do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.sameValue(0, -0); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-custom.js b/test/harness/assert-throws-custom.js new file mode 100644 index 0000000000..4d42b130c3 --- /dev/null +++ b/test/harness/assert-throws-custom.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that throw instances of the specified constructor function + satisfy the assertion. +---*/ + +function MyError() {} + +assert.throws(MyError, function() { + throw new MyError(); +}); diff --git a/test/harness/assert-throws-incorrect-ctor.js b/test/harness/assert-throws-incorrect-ctor.js new file mode 100644 index 0000000000..47f4f0ba76 --- /dev/null +++ b/test/harness/assert-throws-incorrect-ctor.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that throw values whose constructor does not match the specified + constructor do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() { + throw new TypeError(); + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-native.js b/test/harness/assert-throws-native.js new file mode 100644 index 0000000000..7650acb19e --- /dev/null +++ b/test/harness/assert-throws-native.js @@ -0,0 +1,36 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that throw instances of the specified native Error constructor + satisfy the assertion. +---*/ + +assert.throws(Error, function() { + throw new Error(); +}); + +assert.throws(EvalError, function() { + throw new EvalError(); +}); + +assert.throws(RangeError, function() { + throw new RangeError(); +}); + +assert.throws(ReferenceError, function() { + throw new ReferenceError(); +}); + +assert.throws(SyntaxError, function() { + throw new SyntaxError(); +}); + +assert.throws(TypeError, function() { + throw new TypeError(); +}); + +assert.throws(URIError, function() { + throw new URIError(); +}); diff --git a/test/harness/assert-throws-no-arg.js b/test/harness/assert-throws-no-arg.js new file mode 100644 index 0000000000..c8a9f3510b --- /dev/null +++ b/test/harness/assert-throws-no-arg.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + The assertion fails when invoked without arguments. +---*/ + +var threw = false; + +try { + assert.throws(); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-no-error.js b/test/harness/assert-throws-no-error.js new file mode 100644 index 0000000000..d40b06b44c --- /dev/null +++ b/test/harness/assert-throws-no-error.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that do not throw errors do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-null.js b/test/harness/assert-throws-null.js new file mode 100644 index 0000000000..7b10f61247 --- /dev/null +++ b/test/harness/assert-throws-null.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that throw the `null` value do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() { + throw null; + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-primitive.js b/test/harness/assert-throws-primitive.js new file mode 100644 index 0000000000..f1f86e18e0 --- /dev/null +++ b/test/harness/assert-throws-primitive.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions that throw primitive values do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() { + throw 3; + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-throws-single-arg.js b/test/harness/assert-throws-single-arg.js new file mode 100644 index 0000000000..3606a1608d --- /dev/null +++ b/test/harness/assert-throws-single-arg.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + The assertion fails when invoked with a single argument. +---*/ + +var threw = false; + +try { + assert.throws(function() {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/assert-true.js b/test/harness/assert-true.js new file mode 100644 index 0000000000..7050005a9c --- /dev/null +++ b/test/harness/assert-true.js @@ -0,0 +1,9 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `true` satisfies the assertion. +---*/ + +assert(true); diff --git a/test/harness/compare-array-different-elements.js b/test/harness/compare-array-different-elements.js new file mode 100644 index 0000000000..32ed51c819 --- /dev/null +++ b/test/harness/compare-array-different-elements.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Arrays containing different elements are not equivalent. +includes: [compareArray.js] +---*/ + +var first = [0, 'a', undefined]; +var second = [0, 'b', undefined]; + +if (compareArray(first, second) !== false) { + $ERROR('Arrays containing different elements are not equivalent.'); +} diff --git a/test/harness/compare-array-different-length.js b/test/harness/compare-array-different-length.js new file mode 100644 index 0000000000..df48a86638 --- /dev/null +++ b/test/harness/compare-array-different-length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Arrays of differing lengths are not equivalent. +includes: [compareArray.js] +---*/ + +if (compareArray([], [undefined]) !== false) { + $ERROR('Arrays of differing lengths are not equivalent.'); +} + +if (compareArray([undefined], []) !== false) { + $ERROR('Arrays of differing lengths are not equivalent.'); +} diff --git a/test/harness/compare-array-empty.js b/test/harness/compare-array-empty.js new file mode 100644 index 0000000000..f3196db4c4 --- /dev/null +++ b/test/harness/compare-array-empty.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Empty arrays of are equivalent. +includes: [compareArray.js] +---*/ + +if (compareArray([], []) !== true) { + $ERROR('Empty arrays are equivalent.'); +} diff --git a/test/harness/compare-array-same-elements-different-order.js b/test/harness/compare-array-same-elements-different-order.js new file mode 100644 index 0000000000..243d670bae --- /dev/null +++ b/test/harness/compare-array-same-elements-different-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Arrays containg the same elements in different order are not equivalent. +includes: [compareArray.js] +---*/ + +var obj = {}; +var first = [0, 1, '', 's', null, undefined, obj]; +var second = [0, 1, '', 's', undefined, null, obj]; + +if (compareArray(first, second) !== false) { + $ERROR('Arrays containing the same elements in different order are not equivalent.'); +} diff --git a/test/harness/compare-array-same-elements-same-order.js b/test/harness/compare-array-same-elements-same-order.js new file mode 100644 index 0000000000..ac09fed284 --- /dev/null +++ b/test/harness/compare-array-same-elements-same-order.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Arrays containg the same elements in the same order are equivalent. +includes: [compareArray.js] +---*/ + +var obj = {}; +var first = [0, 1, '', 's', undefined, null, obj]; +var second = [0, 1, '', 's', undefined, null, obj]; + +if (compareArray(first, second) !== true) { + $ERROR('Arrays containing the same elements in the same order are equivalent.'); +} diff --git a/test/harness/compare-array-sparse.js b/test/harness/compare-array-sparse.js new file mode 100644 index 0000000000..316039a06f --- /dev/null +++ b/test/harness/compare-array-sparse.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Spares arrays are only equivalent if they have the same length. +includes: [compareArray.js] +---*/ + +if (compareArray([,], [,]) !== true) { + $ERROR('Sparse arrays of the same length are equivalent.'); +} + +if (compareArray([,], [,,]) !== false) { + $ERROR('Sparse arrays of differing lengths are not equivalent.'); +} + +if (compareArray([,,], [,]) !== false) { + $ERROR('Sparse arrays of differing lengths are not equivalent.'); +} + +if (compareArray([,], []) !== false) { + $ERROR('Sparse arrays are not equivalent to empty arrays.'); +} + +if (compareArray([], [,]) !== false) { + $ERROR('Sparse arrays are not equivalent to empty arrays.'); +} diff --git a/test/harness/error.js b/test/harness/error.js new file mode 100644 index 0000000000..e6cee574f6 --- /dev/null +++ b/test/harness/error.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + The global `$ERROR` function throws an instance of the global `Test262` + function with the specified message. +---*/ + +var threw = false; + +try { + $ERROR('This is a test message'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + if (err.message !== 'This is a test message') { + throw new Error('The error thrown did not define the specified message.'); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifyconfigurable-configurable.js b/test/harness/propertyhelper-verifyconfigurable-configurable.js new file mode 100644 index 0000000000..997c9f9390 --- /dev/null +++ b/test/harness/propertyhelper-verifyconfigurable-configurable.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: true +}); + +verifyConfigurable(obj, 'a'); diff --git a/test/harness/propertyhelper-verifyconfigurable-not-configurable-not-strict.js b/test/harness/propertyhelper-verifyconfigurable-not-configurable-not-strict.js new file mode 100644 index 0000000000..e8216b2329 --- /dev/null +++ b/test/harness/propertyhelper-verifyconfigurable-not-configurable-not-strict.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not configurable do not satisfy the + assertion outside of strict mode. +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +try { + verifyConfigurable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifyconfigurable-not-configurable-strict.js b/test/harness/propertyhelper-verifyconfigurable-not-configurable-strict.js new file mode 100644 index 0000000000..ce438f50fa --- /dev/null +++ b/test/harness/propertyhelper-verifyconfigurable-not-configurable-strict.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not configurable do not satisfy the + assertion in strict mode. +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +try { + verifyConfigurable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifyenumerable-enumerable.js b/test/harness/propertyhelper-verifyenumerable-enumerable.js new file mode 100644 index 0000000000..7540999802 --- /dev/null +++ b/test/harness/propertyhelper-verifyenumerable-enumerable.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is enumerable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: true +}); + +verifyEnumerable(obj, 'a'); diff --git a/test/harness/propertyhelper-verifyenumerable-not-enumerable.js b/test/harness/propertyhelper-verifyenumerable-not-enumerable.js new file mode 100644 index 0000000000..569ac0904a --- /dev/null +++ b/test/harness/propertyhelper-verifyenumerable-not-enumerable.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: false +}); + +try { + verifyEnumerable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifynotconfigurable-configurable.js b/test/harness/propertyhelper-verifynotconfigurable-configurable.js new file mode 100644 index 0000000000..4b66a9b12a --- /dev/null +++ b/test/harness/propertyhelper-verifynotconfigurable-configurable.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is configurable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: true +}); + +try { + verifyNotConfigurable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifynotconfigurable-not-configurable-not-strict.js b/test/harness/propertyhelper-verifynotconfigurable-not-configurable-not-strict.js new file mode 100644 index 0000000000..e8b882427a --- /dev/null +++ b/test/harness/propertyhelper-verifynotconfigurable-not-configurable-not-strict.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not configurable satisfy the assertion + outside of strict mode. +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +verifyNotConfigurable(obj, 'a'); diff --git a/test/harness/propertyhelper-verifynotconfigurable-not-configurable-strict.js b/test/harness/propertyhelper-verifynotconfigurable-not-configurable-strict.js new file mode 100644 index 0000000000..b551076365 --- /dev/null +++ b/test/harness/propertyhelper-verifynotconfigurable-not-configurable-strict.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not configurable satisfy the assertion + in strict mode. +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +verifyNotConfigurable(obj, 'a'); diff --git a/test/harness/propertyhelper-verifynotenumerable-enumerable.js b/test/harness/propertyhelper-verifynotenumerable-enumerable.js new file mode 100644 index 0000000000..1d838d4f6c --- /dev/null +++ b/test/harness/propertyhelper-verifynotenumerable-enumerable.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: true +}); + +try { + verifyNotEnumerable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js b/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js new file mode 100644 index 0000000000..6e04b69309 --- /dev/null +++ b/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not enumerable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: false +}); + +verifyNotEnumerable(obj, 'a'); diff --git a/test/harness/propertyhelper-verifynotwritable-not-writable-not-strict.js b/test/harness/propertyhelper-verifynotwritable-not-writable-not-strict.js new file mode 100644 index 0000000000..7b2963ceb2 --- /dev/null +++ b/test/harness/propertyhelper-verifynotwritable-not-writable-not-strict.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not writable satisfy the assertion + outside of strict mode. +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +var obj = {}; + +Object.defineProperty(obj, 'a', { + writable: false, + value: 123 +}); + +verifyNotWritable(obj, 'a'); + +if (obj.a !== 123) { + $ERROR('`verifyNotWritable` should be non-destructive.'); +} diff --git a/test/harness/propertyhelper-verifynotwritable-not-writable-strict.js b/test/harness/propertyhelper-verifynotwritable-not-writable-strict.js new file mode 100644 index 0000000000..f30533116f --- /dev/null +++ b/test/harness/propertyhelper-verifynotwritable-not-writable-strict.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not writable satisfy the assertion in + strict mode. +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +var obj = {}; + +Object.defineProperty(obj, 'a', { + writable: false, + value: 123 +}); + +verifyNotWritable(obj, 'a'); + +if (obj.a !== 123) { + $ERROR('`verifyNotWritable` should be non-destructive.'); +} diff --git a/test/harness/propertyhelper-verifynotwritable-writable.js b/test/harness/propertyhelper-verifynotwritable-writable.js new file mode 100644 index 0000000000..8eb1b75fb7 --- /dev/null +++ b/test/harness/propertyhelper-verifynotwritable-writable.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is writable do not satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, + value: 1 +}); + +try { + verifyNotWritable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifywritable-not-writable-not-strict.js b/test/harness/propertyhelper-verifywritable-not-writable-not-strict.js new file mode 100644 index 0000000000..bae8fec16d --- /dev/null +++ b/test/harness/propertyhelper-verifywritable-not-writable-not-strict.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not writable do not satisfy the + assertion outside of strict mode. +includes: [propertyHelper.js] +flags: [noStrict] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: false +}); + +try { + verifyWritable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifywritable-not-writable-strict.js b/test/harness/propertyhelper-verifywritable-not-writable-strict.js new file mode 100644 index 0000000000..1ee497f782 --- /dev/null +++ b/test/harness/propertyhelper-verifywritable-not-writable-strict.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is not writable do not satisfy the + assertion in strict mode. +includes: [propertyHelper.js] +flags: [onlyStrict] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: false +}); + +try { + verifyWritable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/propertyhelper-verifywritable-writable.js b/test/harness/propertyhelper-verifywritable-writable.js new file mode 100644 index 0000000000..5dc13e8c04 --- /dev/null +++ b/test/harness/propertyhelper-verifywritable-writable.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified property is writable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, 'a', { + writable: true, + value: 123 +}); + +verifyWritable(obj, 'a'); + +if (obj.a !== 123) { + $ERROR('`verifyWritable` should be non-destructive.'); +} diff --git a/test/harness/testbuiltinobject-function-badstring.js b/test/harness/testbuiltinobject-function-badstring.js new file mode 100644 index 0000000000..5b7a4cba6c --- /dev/null +++ b/test/harness/testbuiltinobject-function-badstring.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that are expected to be functions but do not define the correct + [[Class]] internal property do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; + +try { + testBuiltInObject(null, true); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-function-expected-length.js b/test/harness/testbuiltinobject-function-expected-length.js new file mode 100644 index 0000000000..cc69d94ddf --- /dev/null +++ b/test/harness/testbuiltinobject-function-expected-length.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions whose `length` property does not match the expected value do not + satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; + +try { + testBuiltInObject(function(a, b) {}, true, false, [], 3); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-function-not-constructor-no-error.js b/test/harness/testbuiltinobject-function-not-constructor-no-error.js new file mode 100644 index 0000000000..e3b9f73e34 --- /dev/null +++ b/test/harness/testbuiltinobject-function-not-constructor-no-error.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Non-constructor functions that do not throw an when invoked via `new` do + not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; + +try { + testBuiltInObject(function() {}, true, false, [], 0); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-function-not-constructor-no-typeerror.js b/test/harness/testbuiltinobject-function-not-constructor-no-typeerror.js new file mode 100644 index 0000000000..4a72bf34f2 --- /dev/null +++ b/test/harness/testbuiltinobject-function-not-constructor-no-typeerror.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Non-constructor functions that do not throw a TypeError when invoked via + `new` do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var fn = function() { + throw new Error(); +}; + +try { + testBuiltInObject(fn, true, false, [], 0); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-non-extensible.js b/test/harness/testbuiltinobject-non-extensible.js new file mode 100644 index 0000000000..5d43f711d6 --- /dev/null +++ b/test/harness/testbuiltinobject-non-extensible.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that are not extensible do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var obj = {}; +Object.preventExtensions(obj); + +try { + testBuiltInObject(obj); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-not-function-badstring.js b/test/harness/testbuiltinobject-not-function-badstring.js new file mode 100644 index 0000000000..9d0e69c95e --- /dev/null +++ b/test/harness/testbuiltinobject-not-function-badstring.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that are not expected to be functions but do not define the correct + [[Class]] internal property do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; + +try { + testBuiltInObject(function() {}, false); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-prop-enumerable.js b/test/harness/testbuiltinobject-prop-enumerable.js new file mode 100644 index 0000000000..fda5a1abd1 --- /dev/null +++ b/test/harness/testbuiltinobject-prop-enumerable.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that do not define all of the specified "own" properties as + non-enumerable do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, enumerable: false, configurable: true +}); +Object.defineProperty(obj, 'b', { + writable: true, enumerable: true, configurable: true +}); +Object.defineProperty(obj, 'c', { + writable: true, enumerable: false, configurable: true +}); + +try { + testBuiltInObject(obj, false, false, ['a', 'b', 'c']); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-prop-missing.js b/test/harness/testbuiltinobject-prop-missing.js new file mode 100644 index 0000000000..bfad8336e5 --- /dev/null +++ b/test/harness/testbuiltinobject-prop-missing.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that do not define all of the specified "own" properties do not + satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, enumerable: false, configurable: true +}); +Object.defineProperty(obj, 'c', { + writable: true, enumerable: false, configurable: true +}); + +try { + testBuiltInObject(obj, false, false, ['a', 'b', 'c']); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-prop-not-configurable.js b/test/harness/testbuiltinobject-prop-not-configurable.js new file mode 100644 index 0000000000..661e344675 --- /dev/null +++ b/test/harness/testbuiltinobject-prop-not-configurable.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that do not define all of the specified "own" properties as + configurable do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, enumerable: false, configurable: true +}); +Object.defineProperty(obj, 'b', { + writable: true, enumerable: false, configurable: false +}); +Object.defineProperty(obj, 'c', { + writable: true, enumerable: false, configurable: true +}); + +try { + testBuiltInObject(obj, false, false, ['a', 'b', 'c']); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-prop-not-writable.js b/test/harness/testbuiltinobject-prop-not-writable.js new file mode 100644 index 0000000000..7f2ba95daa --- /dev/null +++ b/test/harness/testbuiltinobject-prop-not-writable.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects that do not define all of the specified "own" properties as + writable do not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, enumerable: false, configurable: true +}); +Object.defineProperty(obj, 'b', { + writable: false, enumerable: false, configurable: true +}); +Object.defineProperty(obj, 'c', { + writable: true, enumerable: false, configurable: true +}); + +try { + testBuiltInObject(obj, false, false, ['a', 'b', 'c']); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/harness/testbuiltinobject-undefined.js b/test/harness/testbuiltinobject-undefined.js new file mode 100644 index 0000000000..ffab8c7ed1 --- /dev/null +++ b/test/harness/testbuiltinobject-undefined.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `undefined` does not satisfy the assertion. +includes: [testBuiltInObject.js] +---*/ + +var threw = false; + +try { + testBuiltInObject(undefined); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + $ERROR( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + $ERROR('Expected a Test262Error, but no error was thrown.'); +}