Add tests for test harness

This commit is contained in:
Mike Pennisi 2015-04-21 15:22:35 -04:00
parent 6d945e2a1e
commit 3211e33199
53 changed files with 1267 additions and 0 deletions

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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', '');

View File

@ -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({}, {});

View File

@ -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);

View File

@ -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.');
}

View File

@ -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);

View File

@ -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.');
}

View File

@ -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);

View File

@ -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.');
}

View File

@ -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();
});

View File

@ -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.');
}

View File

@ -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();
});

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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);

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

29
test/harness/error.js Normal file
View File

@ -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.');
}

View File

@ -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');

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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');

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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');

View File

@ -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');

View File

@ -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.');
}

View File

@ -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');

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}