diff --git a/test/language/subclassing/NativeError/EvalError-message.js b/test/language/subclassing/NativeError/EvalError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..475b236b8fbaf69a13860eae3e21884bf837133b --- /dev/null +++ b/test/language/subclassing/NativeError/EvalError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends EvalError {} + +Err.prototype.message = 'custom-eval-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-eval-error'); diff --git a/test/language/subclassing/NativeError/EvalError-name.js b/test/language/subclassing/NativeError/EvalError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..cfd96de075b334b735e5e67f94d3ebdbd4b313ab --- /dev/null +++ b/test/language/subclassing/NativeError/EvalError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends EvalError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'EvalError'); diff --git a/test/language/subclassing/NativeError/EvalError-super.js b/test/language/subclassing/NativeError/EvalError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..c55cbf0b16379c7d92f97443bb927f4034bb1096 --- /dev/null +++ b/test/language/subclassing/NativeError/EvalError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends EvalError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); diff --git a/test/language/subclassing/NativeError/RangeError-message.js b/test/language/subclassing/NativeError/RangeError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..f3f4150fcf93a31255be0185983c4d2ab7031111 --- /dev/null +++ b/test/language/subclassing/NativeError/RangeError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends RangeError {} + +Err.prototype.message = 'custom-range-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-range-error'); diff --git a/test/language/subclassing/NativeError/RangeError-name.js b/test/language/subclassing/NativeError/RangeError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..c676057e2bb22e6623dbccd7e6430867337bc5af --- /dev/null +++ b/test/language/subclassing/NativeError/RangeError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends RangeError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'RangeError'); diff --git a/test/language/subclassing/NativeError/RangeError-super.js b/test/language/subclassing/NativeError/RangeError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..c02eec530d55a07336734d5ad7ddc0bb67fe8e57 --- /dev/null +++ b/test/language/subclassing/NativeError/RangeError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends RangeError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); diff --git a/test/language/subclassing/NativeError/ReferenceError-message.js b/test/language/subclassing/NativeError/ReferenceError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..d8ba34f1001f78324e5327e1731c2226e92903f1 --- /dev/null +++ b/test/language/subclassing/NativeError/ReferenceError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends ReferenceError {} + +Err.prototype.message = 'custom-reference-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-reference-error'); diff --git a/test/language/subclassing/NativeError/ReferenceError-name.js b/test/language/subclassing/NativeError/ReferenceError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..ca746745ad2f982048a3aef7d17ec7c2fef1a8bb --- /dev/null +++ b/test/language/subclassing/NativeError/ReferenceError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends ReferenceError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'ReferenceError'); diff --git a/test/language/subclassing/NativeError/ReferenceError-super.js b/test/language/subclassing/NativeError/ReferenceError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..7ea1b66d188185eee846aac9866511801454a658 --- /dev/null +++ b/test/language/subclassing/NativeError/ReferenceError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends ReferenceError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); diff --git a/test/language/subclassing/NativeError/SyntaxError-message.js b/test/language/subclassing/NativeError/SyntaxError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..4a31b877396ef5afb3056b4de6d4c4113d482ca0 --- /dev/null +++ b/test/language/subclassing/NativeError/SyntaxError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends SyntaxError {} + +Err.prototype.message = 'custom-syntax-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-syntax-error'); diff --git a/test/language/subclassing/NativeError/SyntaxError-name.js b/test/language/subclassing/NativeError/SyntaxError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..658d59e5470b194048232834f6b18772ff7d607c --- /dev/null +++ b/test/language/subclassing/NativeError/SyntaxError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends SyntaxError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'SyntaxError'); diff --git a/test/language/subclassing/NativeError/SyntaxError-super.js b/test/language/subclassing/NativeError/SyntaxError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..903f5337bf0e931b8bd37975b94dd7f1fb655d14 --- /dev/null +++ b/test/language/subclassing/NativeError/SyntaxError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends SyntaxError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); diff --git a/test/language/subclassing/NativeError/TypeError-message.js b/test/language/subclassing/NativeError/TypeError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..a8bdbb3c0a8261d89584bacb2fd34ea70de3fb42 --- /dev/null +++ b/test/language/subclassing/NativeError/TypeError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends TypeError {} + +Err.prototype.message = 'custom-type-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-type-error'); diff --git a/test/language/subclassing/NativeError/TypeError-name.js b/test/language/subclassing/NativeError/TypeError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..d84b419c982588b2883b297622f135c0df8606c7 --- /dev/null +++ b/test/language/subclassing/NativeError/TypeError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends TypeError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'TypeError'); diff --git a/test/language/subclassing/NativeError/TypeError-super.js b/test/language/subclassing/NativeError/TypeError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..ee764f80d0da10b9de0f371e5142111954486109 --- /dev/null +++ b/test/language/subclassing/NativeError/TypeError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends TypeError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +}); diff --git a/test/language/subclassing/NativeError/URIError-message.js b/test/language/subclassing/NativeError/URIError-message.js new file mode 100644 index 0000000000000000000000000000000000000000..214e73d3871b41798d06dcb64f1b5645735ca127 --- /dev/null +++ b/test/language/subclassing/NativeError/URIError-message.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + A new instance has the message property if created with a parameter +info: > + 19.5.6.1.1 NativeError ( message ) + + ... + 4. If message is not undefined, then + a. Let msg be ToString(message). + b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true}. + c. Let status be DefinePropertyOrThrow(O, "message", msgDesc). + ... +includes: [propertyHelper.js] + +---*/ + +class Err extends URIError {} + +Err.prototype.message = 'custom-uri-error'; + +var err1 = new Err('foo 42'); +assert.sameValue(err1.message, 'foo 42'); +assert(err1.hasOwnProperty('message')); + +verifyWritable(err1, 'message'); +verifyNotEnumerable(err1, 'message'); +verifyConfigurable(err1, 'message'); + +var err2 = new Err(); +assert.sameValue(err2.hasOwnProperty('message'), false); +assert.sameValue(err2.message, 'custom-uri-error'); diff --git a/test/language/subclassing/NativeError/URIError-name.js b/test/language/subclassing/NativeError/URIError-name.js new file mode 100644 index 0000000000000000000000000000000000000000..78791e36d7240deb93709243041ad40f57efd0c8 --- /dev/null +++ b/test/language/subclassing/NativeError/URIError-name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1.1 +description: > + The name property on a new instance +info: > + 19.5.6.3.3 NativeError.prototype.name + + The initial value of the name property of the prototype for a given + NativeError constructor is a string consisting of the name of the constructor + (the name used instead of NativeError). +---*/ + +class Err extends URIError {} + +var err1 = new Err(); +assert.sameValue(err1.name, 'URIError'); diff --git a/test/language/subclassing/NativeError/URIError-super.js b/test/language/subclassing/NativeError/URIError-super.js new file mode 100644 index 0000000000000000000000000000000000000000..ab21a7170af081b8323a63ddd037af593b1a89b6 --- /dev/null +++ b/test/language/subclassing/NativeError/URIError-super.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.5.6.1 +description: Super need to be called to initialize internals +info: > + 19.5.6.1 NativeError Constructors + + ... + Each NativeError constructor is designed to be subclassable. It may be used as + the value of an extends clause of a class definition. Subclass constructors + that intend to inherit the specified NativeError behaviour must include a + super call to the NativeError constructor to create and initialize subclass + instances with a [[ErrorData]] internal slot. +---*/ + +class CustomError extends URIError { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new CustomError(); +});