diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/NativeErrors/SyntaxError')
19 files changed, 373 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js new file mode 100644 index 0000000000..79b5fb8708 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/constructor.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + SyntaxError is a constructor function. +---*/ + +assert.sameValue(typeof SyntaxError, 'function', 'typeof SyntaxError is "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js new file mode 100644 index 0000000000..792fb96005 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/instance-proto.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + The prototype of SyntaxError instances is SyntaxError.prototype. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.getPrototypeOf(new SyntaxError), SyntaxError.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-a-constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-a-constructor.js new file mode 100644 index 0000000000..ad74f340ca --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The SyntaxError constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(SyntaxError), true, 'isConstructor(SyntaxError) must return true'); +new SyntaxError(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js new file mode 100644 index 0000000000..8ea07870fa --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/is-error-object.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.4 +description: > + SyntaxError instances have an [[ErrorData]] internal slot. +info: | + NativeError instances are ordinary objects that inherit properties + from their NativeError prototype object and have an [[ErrorData]] + internal slot whose value is undefined +---*/ + +assert.sameValue(Object.prototype.toString.call(new SyntaxError), "[object Error]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js new file mode 100644 index 0000000000..555a5c1529 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + SyntaxError.length is 1. +info: | + NativeError ( message ) + + 19.5.6.2 Properties of the NativeError Constructors + Besides the length property (whose value is 1) [...]. + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.length, 1); + +verifyNotEnumerable(SyntaxError, "length"); +verifyNotWritable(SyntaxError, "length"); +verifyConfigurable(SyntaxError, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js new file mode 100644 index 0000000000..f70899d0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.1 +description: > + SyntaxError.name is "SyntaxError". +info: | + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.name, "SyntaxError"); + +verifyNotEnumerable(SyntaxError, "name"); +verifyNotWritable(SyntaxError, "name"); +verifyConfigurable(SyntaxError, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js new file mode 100644 index 0000000000..09fad3baa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-syntaxerror +description: Property descriptor for SyntaxError +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "SyntaxError"); +verifyWritable(this, "SyntaxError"); +verifyConfigurable(this, "SyntaxError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js new file mode 100644 index 0000000000..7bb0aef336 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto-from-ctor-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-nativeerror +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + NativeError ( message ) + + 1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeErrorPrototype%", « [[ErrorData]] »). + ... + 4. Return O. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + ... + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, 'prototype'). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var err; + +newTarget.prototype = undefined; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is undefined'); + +newTarget.prototype = null; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is null'); + +newTarget.prototype = true; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Boolean'); + +newTarget.prototype = ''; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a String'); + +newTarget.prototype = Symbol(); +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Symbol'); + +newTarget.prototype = Infinity; +err = Reflect.construct(SyntaxError, [], newTarget); +assert.sameValue(Object.getPrototypeOf(err), other.SyntaxError.prototype, 'newTarget.prototype is a Number'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js new file mode 100644 index 0000000000..119a24e25b --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/proto.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2 +description: > + The prototype of SyntaxError is Error. +info: | + The value of the [[Prototype]] internal slot of a NativeError constructor is the intrinsic object %Error% (19.5.1). +---*/ + +assert.sameValue(Object.getPrototypeOf(SyntaxError), Error); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js new file mode 100644 index 0000000000..2afe909c57 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.2.1 +description: > + The initial value of SyntaxError.prototype is the SyntaxError prototype object. +info: | + The initial value of NativeError.prototype is a NativeError prototype object (19.5.6.3). + Each NativeError constructor has a distinct prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.prototype, Object.getPrototypeOf(new SyntaxError)); + +verifyNotEnumerable(SyntaxError, "prototype"); +verifyNotWritable(SyntaxError, "prototype"); +verifyNotConfigurable(SyntaxError, "prototype"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js new file mode 100644 index 0000000000..a5aaf689d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.1 +description: > + The initial value of SyntaxError.prototype.constructor is the SyntaxError object. +info: | + The initial value of the constructor property of the prototype for a given NativeError + constructor is the corresponding intrinsic object %NativeError% (19.5.6.1). + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.prototype.constructor, SyntaxError); + +verifyNotEnumerable(SyntaxError.prototype, "constructor"); +verifyWritable(SyntaxError.prototype, "constructor"); +verifyConfigurable(SyntaxError.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js new file mode 100644 index 0000000000..43c0f97bad --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/message.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.2 +description: > + The initial value of SyntaxError.prototype.message is the empty string. +info: | + The initial value of the message property of the prototype for a given NativeError + constructor is the empty String. + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.prototype.message, ""); + +verifyNotEnumerable(SyntaxError.prototype, "message"); +verifyWritable(SyntaxError.prototype, "message"); +verifyConfigurable(SyntaxError.prototype, "message"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js new file mode 100644 index 0000000000..8f80d797ba --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/name.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3.3 +description: > + The initial value of SyntaxError.prototype.name is "SyntaxError". +info: | + 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). + + 17 ECMAScript Standard Built-in Objects: + Every other data property described in clauses 18 through 26 and in Annex B.2 has + the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } + unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SyntaxError.prototype.name, "SyntaxError"); + +verifyNotEnumerable(SyntaxError.prototype, "name"); +verifyWritable(SyntaxError.prototype, "name"); +verifyConfigurable(SyntaxError.prototype, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js new file mode 100644 index 0000000000..4d863890e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/not-error-object.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + SyntaxError.prototype is not an error object instance. +info: | + Each NativeError prototype object is an ordinary object. It is not an + Error instance and does not have an [[ErrorData]] internal slot. +---*/ + +assert.sameValue(Object.prototype.toString.call(SyntaxError.prototype), "[object Object]"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js new file mode 100644 index 0000000000..4130132fc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/proto.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 19.5.6.3 +description: > + The prototype of SyntaxError.prototype is Error.prototype. +info: | + The value of the [[Prototype]] internal slot of each NativeError prototype + object is the intrinsic object %ErrorPrototype% (19.5.3). +---*/ + +assert.sameValue(Object.getPrototypeOf(SyntaxError.prototype), Error.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/NativeErrors/SyntaxError/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |