Add tests for AggregateError (#2406)

This covers part of the Promise.any proposal
This commit is contained in:
Leo Balter 2019-11-07 11:01:21 -05:00 committed by GitHub
parent 91861e2330
commit 1bc193528b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 2124 additions and 0 deletions

View File

@ -153,6 +153,11 @@ coalesce-expression
# https://github.com/tc39-transfer/proposal-intl-displaynames
Intl.DisplayNames
# Promise.any
# https://github.com/tc39/proposal-promise-any
Promise.any
AggregateError
## Standard language features
#
# Language features that have been included in a published version of the

View File

@ -0,0 +1,183 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Return abrupt completion from IterableToList(errors)
info: |
AggregateError ( errors, message )
...
3. Let errorsList be ? IterableToList(errors).
4. Set O.[[AggregateErrors]] to errorsList.
...
6. Return O.
Runtime Semantics: IterableToList ( items [ , method ] )
1. If method is present, then
...
2. Else,
b. Let iteratorRecord be ? GetIterator(items, sync).
3. Let values be a new empty List.
4. Let next be true.
5. Repeat, while next is not false
a. Set next to ? IteratorStep(iteratorRecord).
b. If next is not false, then
i. Let nextValue be ? IteratorValue(next).
ii. Append nextValue to the end of the List values.
6. Return values.
GetIterator ( obj [ , hint [ , method ] ] )
...
3. If method is not present, then
a. If hint is async, then
...
b. Otherwise, set method to ? GetMethod(obj, @@iterator).
4. Let iterator be ? Call(method, obj).
5. If Type(iterator) is not Object, throw a TypeError exception.
6. Let nextMethod be ? GetV(iterator, "next").
...
8. Return iteratorRecord.
features: [AggregateError, Symbol.iterator]
---*/
var case1 = {
get [Symbol.iterator]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
var obj = new AggregateError(case1);
}, 'get Symbol.iterator');
var case2 = {
get [Symbol.iterator]() {
return {};
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case2);
}, 'GetMethod(obj, @@iterator) abrupts from non callable');
var case3 = {
[Symbol.iterator]() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
var obj = new AggregateError(case3);
}, 'Abrupt from @@iterator call');
var case4 = {
[Symbol.iterator]() {
return 'a string';
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case4);
}, '@@iterator call returns a string');
var case5 = {
[Symbol.iterator]() {
return undefined;
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case5);
}, '@@iterator call returns undefined');
var case6 = {
[Symbol.iterator]() {
return {
get next() {
throw new Test262Error();
}
}
}
};
assert.throws(Test262Error, () => {
var obj = new AggregateError(case6);
}, 'GetV(iterator, next) returns abrupt');
var case7 = {
[Symbol.iterator]() {
return {
get next() {
return {};
}
}
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case7);
}, 'GetV(iterator, next) returns a non callable');
var case8 = {
[Symbol.iterator]() {
return {
next() {
throw new Test262Error();
}
}
}
};
assert.throws(Test262Error, () => {
var obj = new AggregateError(case8);
}, 'abrupt from iterator.next()');
var case9 = {
[Symbol.iterator]() {
return {
next() {
return undefined;
}
}
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case9);
}, 'iterator.next() returns undefined');
var case10 = {
[Symbol.iterator]() {
return {
next() {
return 'a string';
}
}
}
};
assert.throws(TypeError, () => {
var obj = new AggregateError(case10);
}, 'iterator.next() returns a string');
var case11 = {
[Symbol.iterator]() {
return {
next() {
return {
get done() {
throw new Test262Error();
}
};
}
}
}
};
assert.throws(Test262Error, () => {
var obj = new AggregateError(case11);
}, 'IteratorCompete abrupts getting the done property');

View File

@ -0,0 +1,69 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Iteration of errors
info: |
AggregateError ( errors, message )
...
3. Let errorsList be ? IterableToList(errors).
4. Set O.[[AggregateErrors]] to errorsList.
...
6. Return O.
Runtime Semantics: IterableToList ( items [ , method ] )
1. If method is present, then
...
2. Else,
b. Let iteratorRecord be ? GetIterator(items, sync).
3. Let values be a new empty List.
4. Let next be true.
5. Repeat, while next is not false
a. Set next to ? IteratorStep(iteratorRecord).
b. If next is not false, then
i. Let nextValue be ? IteratorValue(next).
ii. Append nextValue to the end of the List values.
6. Return values.
GetIterator ( obj [ , hint [ , method ] ] )
...
3. If method is not present, then
a. If hint is async, then
...
b. Otherwise, set method to ? GetMethod(obj, @@iterator).
4. Let iterator be ? Call(method, obj).
5. If Type(iterator) is not Object, throw a TypeError exception.
6. Let nextMethod be ? GetV(iterator, "next").
...
8. Return iteratorRecord.
features: [AggregateError, Symbol.iterator]
includes: [compareArray.js]
---*/
var count = 0;
var values = [];
var case1 = {
[Symbol.iterator]() {
return {
next() {
count += 1;
return {
done: count === 3,
get value() {
values.push(count)
}
};
}
};
}
};
new AggregateError(case1);
assert.sameValue(count, 3);
assert.compareArray(values, [1, 2]);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: AggregateError.length property descriptor
info: |
AggregateError ( errors, message )
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. Optional parameters
(which are indicated with brackets: [ ]) or rest parameters (which
are 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]
features: [AggregateError]
---*/
verifyProperty(AggregateError, 'length', {
value: 2,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,69 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Cast ToString values of message in the created method property
info: |
AggregateError ( errors, message )
...
5. If message is not undefined, then
a. Let msg be ? ToString(message).
b. Perform ! CreateMethodProperty(O, "message", msg).
6. Return O.
CreateMethodProperty ( O, P, V )
...
3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
4. Return ? O.[[DefineOwnProperty]](P, newDesc).
features: [AggregateError]
includes: [propertyHelper.js]
---*/
var case1 = new AggregateError([], 42);
verifyProperty(case1, 'message', {
value: '42',
writable: true,
enumerable: false,
configurable: true,
});
var case2 = new AggregateError([], false);
verifyProperty(case2, 'message', {
value: 'false',
writable: true,
enumerable: false,
configurable: true,
});
var case3 = new AggregateError([], true);
verifyProperty(case3, 'message', {
value: 'true',
writable: true,
enumerable: false,
configurable: true,
});
var case4 = new AggregateError([], { toString() { return 'string'; }});
verifyProperty(case4, 'message', {
value: 'string',
writable: true,
enumerable: false,
configurable: true,
});
var case5 = new AggregateError([], null);
verifyProperty(case5, 'message', {
value: 'null',
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Creates a method property for message
info: |
AggregateError ( errors, message )
...
5. If message is not undefined, then
a. Let msg be ? ToString(message).
b. Perform ! CreateMethodProperty(O, "message", msg).
6. Return O.
CreateMethodProperty ( O, P, V )
...
3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
4. Return ? O.[[DefineOwnProperty]](P, newDesc).
features: [AggregateError]
includes: [propertyHelper.js]
---*/
var obj = new AggregateError([], '42');
verifyProperty(obj, 'message', {
value: '42',
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,39 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Abrupt completions of ToString(Symbol message)
info: |
AggregateError ( errors, message )
...
5. If message is not undefined, then
a. Let msg be ? ToString(message).
b. Perform ! CreateMethodProperty(O, "message", msg).
6. Return O.
features: [AggregateError, Symbol, Symbol.toPrimitive]
---*/
var case1 = Symbol();
assert.throws(TypeError, () => {
new AggregateError([], case1);
}, 'toPrimitive');
var case2 = {
[Symbol.toPrimitive]() {
return Symbol();
},
toString() {
throw new Test262Error();
},
valueOf() {
throw new Test262Error();
}
};
assert.throws(TypeError, () => {
new AggregateError([], case2);
}, 'from ToPrimitive');

View File

@ -0,0 +1,59 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Abrupt completions of ToString(message)
info: |
AggregateError ( errors, message )
...
5. If message is not undefined, then
a. Let msg be ? ToString(message).
b. Perform ! CreateMethodProperty(O, "message", msg).
6. Return O.
features: [AggregateError, Symbol.toPrimitive]
---*/
var case1 = {
[Symbol.toPrimitive]() {
throw new Test262Error();
},
toString() {
throw 'toString called';
},
valueOf() {
throw 'valueOf called';
}
};
assert.throws(Test262Error, () => {
new AggregateError([], case1);
}, 'toPrimitive');
var case2 = {
[Symbol.toPrimitive]: undefined,
toString() {
throw new Test262Error();
},
valueOf() {
throw 'valueOf called';
}
};
assert.throws(Test262Error, () => {
new AggregateError([], case2);
}, 'toString');
var case3 = {
[Symbol.toPrimitive]: undefined,
toString: undefined,
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
new AggregateError([], case3);
}, 'valueOf');

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
If message is undefined, no property will be set to the new instance
info: |
AggregateError ( errors, message )
...
5. If message is not undefined, then
a. Let msg be ? ToString(message).
b. Perform ! CreateMethodProperty(O, "message", msg).
6. Return O.
features: [AggregateError]
---*/
var case1 = new AggregateError([], undefined);
assert.sameValue(
Object.prototype.hasOwnProperty.call(case1, 'message'),
false,
'explicit'
);
var case2 = new AggregateError([]);
assert.sameValue(
Object.prototype.hasOwnProperty.call(case2, 'message'),
false,
'implicit'
);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: AggregateError.name property descriptor
info: |
Properties of the AggregateError Constructor
- has a name property whose value is the String value "AggregateError".
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, this value is the name that
is given to the function in this specification. For functions that
are specified as properties of objects, the name value is the
property name string used to access the function. [...]
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]
features: [AggregateError]
---*/
verifyProperty(AggregateError, 'name', {
value: 'AggregateError',
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,47 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Use a custom NewTarget prototype
info: |
AggregateError ( errors, message )
1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
...
6. 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.
Return proto.
features: [AggregateError]
---*/
var custom = { x: 42 };
var newt = new Proxy(function() {}, {
get(t, p) {
if (p === 'prototype') {
return custom;
}
return t[p];
}
});
var obj = Reflect.construct(AggregateError, [], newt);
assert.sameValue(Object.getPrototypeOf(obj), custom);
assert.sameValue(obj.x, 42);

View File

@ -0,0 +1,62 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Fallback to the NewTarget's [[Prototype]] if the prototype property is not an object
info: |
AggregateError ( errors, message )
1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
...
6. 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.
Return proto.
features: [AggregateError, Symbol]
---*/
var custom = { x: 42 };
var ctor = function() {};
Object.setPrototypeOf(ctor, custom);
var values = [
undefined,
null,
42,
false,
true,
Symbol(),
'string'
];
for (const value of values) {
const newt = new Proxy(ctor, {
get(t, p) {
if (p === 'prototype') {
return value;
}
return t[p];
}
});
const obj = Reflect.construct(AggregateError, [], newt);
assert.sameValue(Object.getPrototypeOf(obj), custom);
assert.sameValue(obj.x, 42);
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Default prototype is the %AggregateError.prototype%"
info: |
AggregateError ( errors, message )
1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget.
2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
...
6. 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.
Return proto.
features: [AggregateError]
---*/
var obj = new AggregateError([]);
assert.sameValue(Object.getPrototypeOf(obj), AggregateError.prototype);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error
description: >
Property descriptor of AggregateError
info: |
The AggregateError Object
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]
features: [AggregateError]
---*/
assert.sameValue(typeof AggregateError, 'function');
verifyProperty(this, 'AggregateError', {
enumerable: false,
writable: true,
configurable: true
});

View File

@ -0,0 +1,16 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: The prototype of AggregateError constructor is Error
esid: sec-aggregate-error
info: |
Properties of the AggregateError Constructor
- has a [[Prototype]] internal slot whose value is the intrinsic object %Error%.
features: [AggregateError]
---*/
var proto = Object.getPrototypeOf(AggregateError);
assert.sameValue(proto, Error);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.constructor
description: >
The `AggregateError.prototype.constructor` property descriptor.
info: |
The initial value of AggregateError.prototype.constructor is the intrinsic
object %AggregateError%.
17 ECMAScript Standard Built-in Objects:
Every other data property described (...) has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
verifyProperty(AggregateError.prototype, 'constructor', {
value: AggregateError,
enumerable: false,
writable: true,
configurable: true
});

View File

@ -0,0 +1,21 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Requires this value to have a [[AggregateErrorData]] internal slot
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
2. If Type(E) is not Object, throw a TypeError exception.
3. If E does not have an [[ErrorData]] internal slot, throw a TypeError exception.
4. If E does not have an [[AggregateErrors]] internal slot, throw a TypeError exception.
5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
features: [AggregateError]
---*/
assert.throws(TypeError, function() {
AggregateError.prototype.errors;
});

View File

@ -0,0 +1,25 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Throws a TypeError exception when invoked as a function
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
2. If Type(E) is not Object, throw a TypeError exception.
3. If E does not have an [[ErrorData]] internal slot, throw a TypeError exception.
4. If E does not have an [[AggregateErrors]] internal slot, throw a TypeError exception.
5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
features: [AggregateError]
---*/
var getter = Object.getOwnPropertyDescriptor(
AggregateError.prototype, 'errors'
).get;
assert.throws(TypeError, function() {
getter();
});

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Property descriptor of (get AggregateError.prototype.errors).length
info: |
get AggregateError.prototype.errors
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]
features: [AggregateError]
---*/
var desc = Object.getOwnPropertyDescriptor(AggregateError.prototype, 'errors');
verifyProperty(desc.get, 'length', {
value: 0,
enumerable: false,
writable: false,
configurable: true
});

View File

@ -0,0 +1,28 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Property descriptor of (get AggregateError.prototype.errors).name
info: |
get AggregateError.prototype.errors
17 ECMAScript Standard Built-in Objects
Functions that are specified as get or set accessor functions of built-in
properties have "get " or "set " prepended to the property name string.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
var desc = Object.getOwnPropertyDescriptor(
AggregateError.prototype, 'errors'
);
verifyProperty(desc.get, 'name', {
value: 'get errors',
enumerable: false,
writable: false,
configurable: true
});

View File

@ -0,0 +1,25 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
"errors" property of AggregateError.prototype
info: |
AggregateError.prototype.errors is an accessor property whose set accessor
function is undefined.
Section 17: Every accessor property described in clauses 18 through 26 and in
Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
includes: [propertyHelper.js]
features: [AggregateError]
---*/
var desc = Object.getOwnPropertyDescriptor(AggregateError.prototype, 'errors');
assert.sameValue(desc.set, undefined);
assert.sameValue(typeof desc.get, 'function');
verifyProperty(AggregateError.prototype, 'errors', {
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,51 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Return a new array from the [[AggregateErrors]] list, after an iterable errors arg.
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
...
5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
includes: [compareArray.js]
features: [AggregateError, Symbol.iterator]
---*/
var count = 0;
var errors = {
[Symbol.iterator]() {
return {
next() {
count += 1;
return {
done: count === 3,
get value() {
return count * 3;
}
};
}
};
}
};
var case1 = new AggregateError(errors);
assert.sameValue(count, 3);
var get1 = case1.errors;
var get2 = case1.errors;
assert.sameValue(Array.isArray(get1), true);
assert.sameValue(Array.isArray(get2), true);
assert.notSameValue(get1, errors, 'creates a new array #1');
assert.notSameValue(get2, errors, 'creates a new array #2');
assert.notSameValue(get1, get2, 'creates a new array everytime it gets the values');
assert.compareArray(get1, [3, 6], 'get accessor does not trigger a new iteration #1');
assert.compareArray(get2, [3, 6], 'get accessor does not trigger a new iteration #2');
assert.sameValue(count, 3, 'count is preserved');

View File

@ -0,0 +1,76 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Return a new array from the [[AggregateErrors]] list.
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
...
5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
includes: [compareArray.js]
features: [AggregateError, Symbol]
---*/
var errors = [];
var case1 = new AggregateError(errors);
var case1get1 = case1.errors;
var case1get2 = case1.errors;
assert.sameValue(Array.isArray(case1get1), true);
assert.sameValue(Array.isArray(case1get2), true);
assert.notSameValue(case1get1, errors, 'case1 - creates a new array #1');
assert.notSameValue(case1get2, errors, 'case1 - creates a new array #2');
assert.notSameValue(case1get1, case1get2, 'creates a new array everytime it gets the values');
assert.compareArray(case1get1, errors);
assert.compareArray(case1get2, errors);
/////
errors = [undefined, null, 1, 0, '', {}, Symbol()];
var case2 = new AggregateError(errors);
var case2get1 = case2.errors;
var case2get2 = case2.errors;
assert.sameValue(Array.isArray(case2get1), true);
assert.sameValue(Array.isArray(case2get2), true);
assert.notSameValue(case2get1, errors, 'case2 - creates a new array #1');
assert.notSameValue(case2get2, errors, 'case2 - creates a new array #2');
assert.notSameValue(case2get1, case2get2, 'creates a new array everytime it gets the values');
assert.compareArray(case2get1, errors);
assert.compareArray(case2get2, errors);
/////
errors = [undefined,,,,undefined];
var case3 = new AggregateError(errors);
var case3get1 = case3.errors;
var case3get2 = case3.errors;
assert.sameValue(Array.isArray(case3get1), true);
assert.sameValue(Array.isArray(case3get2), true);
assert.notSameValue(case3get1, errors, 'case3 - creates a new array #1');
assert.notSameValue(case3get2, errors, 'case3 - creates a new array #2');
assert.notSameValue(case3get1, case3get2, 'creates a new array everytime it gets the values');
assert.compareArray(case3get1, errors);
assert.compareArray(case3get2, errors);
assert(Object.prototype.hasOwnProperty.call(case3get1, 0), 'filled array from a sparse origin - case3get1, 0');
assert(Object.prototype.hasOwnProperty.call(case3get1, 1), 'filled array from a sparse origin - case3get1, 1');
assert(Object.prototype.hasOwnProperty.call(case3get1, 2), 'filled array from a sparse origin - case3get1, 2');
assert(Object.prototype.hasOwnProperty.call(case3get1, 3), 'filled array from a sparse origin - case3get1, 3');
assert(Object.prototype.hasOwnProperty.call(case3get1, 4), 'filled array from a sparse origin - case3get1, 4');
assert(Object.prototype.hasOwnProperty.call(case3get2, 0), 'filled array from a sparse origin - case3get2, 0');
assert(Object.prototype.hasOwnProperty.call(case3get2, 1), 'filled array from a sparse origin - case3get2, 1');
assert(Object.prototype.hasOwnProperty.call(case3get2, 2), 'filled array from a sparse origin - case3get2, 2');
assert(Object.prototype.hasOwnProperty.call(case3get2, 3), 'filled array from a sparse origin - case3get2, 3');
assert(Object.prototype.hasOwnProperty.call(case3get2, 4), 'filled array from a sparse origin - case3get2, 4');

View File

@ -0,0 +1,29 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: >
Throws a TypeError exception when `this` does not have a [[AggregateErrorData]]
internal slot
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
2. If Type(E) is not Object, throw a TypeError exception.
3. If E does not have an [[ErrorData]] internal slot, throw a TypeError exception.
4. If E does not have an [[AggregateErrors]] internal slot, throw a TypeError exception.
5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
features: [AggregateError]
---*/
var getter = Object.getOwnPropertyDescriptor(
AggregateError.prototype, 'errors'
).get;
assert.throws(TypeError, function() {
getter.call(new Error());
}, 'this is an instance of Error, no [[AggregateErrors]]');
assert.throws(TypeError, function() {
getter.call(AggregateError);
}, 'AggregateError does not have an [[AggregateErrors]] internal');

View File

@ -0,0 +1,46 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-aggregate-error.prototype.errors
description: Throws a TypeError exception when `this` is not Object
info: |
get AggregateError.prototype.errors
1. Let E be the this value.
2. If Type(E) is not Object, throw a TypeError exception.
...
features: [AggregateError, Symbol]
---*/
var getter = Object.getOwnPropertyDescriptor(
AggregateError.prototype, 'errors'
).get;
assert.throws(TypeError, function() {
getter.call(undefined);
}, 'this is undefined');
assert.throws(TypeError, function() {
getter.call(null);
}, 'this is null');
assert.throws(TypeError, function() {
getter.call(42);
}, 'this is 42');
assert.throws(TypeError, function() {
getter.call('1');
}, 'this is a string');
assert.throws(TypeError, function() {
getter.call(true);
}, 'this is true');
assert.throws(TypeError, function() {
getter.call(false);
}, 'this is false');
var s = Symbol('s');
assert.throws(TypeError, function() {
getter.call(s);
}, 'this is a Symbol');

View File

@ -0,0 +1,25 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.message
description: >
The `AggregateError.prototype.message` property descriptor.
info: |
The initial value of the message property of the prototype for a given AggregateError
constructor is the empty String.
17 ECMAScript Standard Built-in Objects:
Every other data property described (...) has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
verifyProperty(AggregateError.prototype, 'message', {
value: '',
enumerable: false,
writable: true,
configurable: true
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.name
description: >
The `AggregateError.prototype.name` property descriptor.
info: |
The initial value of AggregateError.prototype.name is "AggregateError".
17 ECMAScript Standard Built-in Objects:
Every other data property described (...) has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
verifyProperty(AggregateError.prototype, 'name', {
value: 'AggregateError',
enumerable: false,
writable: true,
configurable: true
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype
description: >
Property descriptor of AggregateError.prototype
info: |
AggregateError.prototype
The initial value of AggregateError.prototype is the intrinsic object %AggregateErrorPrototype%.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
assert.sameValue(typeof AggregateError.prototype, 'object');
verifyProperty(AggregateError, 'prototype', {
enumerable: false,
writable: false,
configurable: false
});

View File

@ -0,0 +1,16 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-properties-of-the-aggregate-error-prototype-objects
description: The prototype of AggregateError.prototype constructor is Error.prototype
info: |
Properties of the AggregateError Prototype Object
- has a [[Prototype]] internal slot whose value is the intrinsic object %Error.prototype%.
features: [AggregateError]
---*/
var proto = Object.getPrototypeOf(AggregateError.prototype);
assert.sameValue(proto, Error.prototype);

View File

@ -0,0 +1,39 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Gets the Object message, returning abrupt completion
info: |
AggregateError.prototype.toString ( )
...
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var nameCalled = 0;
var obj = {
get name() {
nameCalled += 1;
},
get message() {
called += 1;
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
method.call(obj);
});
assert.sameValue(called, 1);
assert.sameValue(nameCalled, 1);

View File

@ -0,0 +1,54 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
If message value is the empty string, return name
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var result = method.call({
name: 'the name',
message: '',
});
assert.sameValue(result, 'the name', 'explicit from own property');
result = false;
result = method.call(Object.create({
name: 'the name',
message: '',
}));
assert.sameValue(result, 'the name', 'explicit from prototype');
result = false;
result = method.call({
name: 'the name',
message: undefined,
});
assert.sameValue(result, 'the name', 'message is undefined');
result = false;
result = method.call({
name: 'the name!',
message: { toString() { return ''; } },
});
assert.sameValue(result, 'the name!', 'return name');

View File

@ -0,0 +1,83 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString on the message object value
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError, Symbol.toPrimitive]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var obj = {
message: {
[Symbol.toPrimitive]() {
called += 1;
return 'from @@toPrimitive';
},
toString() {
throw new Test262Error();
},
valueOf() {
throw new Test262Error();
},
},
name: '',
};
var result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from @@toPrimitive');
called = 0;
obj = {
message: {
[Symbol.toPrimitive]: undefined,
toString() {
called += 1;
return 'from the toString method';
},
valueOf() {
throw new Test262Error();
},
},
name: '',
};
result = false;
result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from the toString method');
called = 0;
obj = {
message: {
[Symbol.toPrimitive]: undefined,
toString: undefined,
valueOf() {
called += 1;
return 'from the valueOf method';
},
},
name: '',
};
result = false;
result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from the valueOf method');

View File

@ -0,0 +1,35 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(Symbol msg)
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError, Symbol]
---*/
var method = AggregateError.prototype.toString;
var obj = { name: '', message: Symbol() };
assert.throws(TypeError, function() {
method.call(obj);
}, 'own property');
obj = Object.create({ name: '', message: Symbol() });
assert.throws(TypeError, function() {
method.call(obj);
}, 'from prototype');

View File

@ -0,0 +1,38 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(msg) where it can return "undefined"
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var obj = {
message: {
toString() {
return undefined;
}
},
name: 'hi',
};
assert.sameValue(method.call(obj), 'hi\u003A\u0020undefined', 'with name');
obj.name = '';
assert.sameValue(method.call(obj), 'undefined', 'without name');

View File

@ -0,0 +1,36 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(message)
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var obj = { name: '' };
obj.message = 0;
assert.sameValue(method.call(obj), '0', 'Number 0');
obj.message = null;
assert.sameValue(method.call(obj), 'null', 'null');
obj.message = false;
assert.sameValue(method.call(obj), 'false', 'false');
obj.message = true;
assert.sameValue(method.call(obj), 'true', 'true');
obj.message = 1;
assert.sameValue(method.call(obj), '1', 'Number 1');

View File

@ -0,0 +1,64 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
An undefined message property value is cast to 'AggregateError'
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var result = method.call({
message: undefined,
});
assert.sameValue(result, 'AggregateError', 'explicit from own property');
result = false;
result = method.call({});
assert.sameValue(result, 'AggregateError', 'implicit');
result = false;
result = method.call(Object.create({
message: undefined,
}));
assert.sameValue(result, 'AggregateError', 'explicit from prototype');
result = false;
result = method.call({
message: undefined,
name: 'a name',
});
assert.sameValue(result, 'a name', 'explicit from own property, name is set');
result = false;
result = method.call({
name: 'a name',
});
assert.sameValue(result, 'a name', 'implicit, name is set');
result = false;
result = method.call(Object.create({
message: undefined,
name: 'a name',
}));
assert.sameValue(result, 'a name', 'explicit from prototype, name is set');

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Gets the Object message
info: |
AggregateError.prototype.toString ( )
...
5. Let msg be ? Get(O, "message").
...
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var nameCalled = 0;
var obj = {
get name() {
nameCalled += 1;
},
get message() {
called += 1;
}
};
method.call(obj);
assert.sameValue(nameCalled, 1);
assert.sameValue(called, 1);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Gets the Object name, returning abrupt completion
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
...
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var obj = {
get name() {
called += 1;
throw new Test262Error();
}
};
assert.throws(Test262Error, () => {
method.call(obj);
});
assert.sameValue(called, 1);

View File

@ -0,0 +1,70 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
If name value is the empty string, return msg
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var result = method.call({
name: '',
message: 'the message',
});
assert.sameValue(result, 'the message', 'explicit from own property');
result = false;
result = method.call(Object.create({
name: '',
message: 'the message',
}));
assert.sameValue(result, 'the message', 'explicit from prototype');
result = false;
result = method.call({
name: '',
message: '',
});
assert.sameValue(result, '', 'both name and msg are the empty string');
result = false;
result = method.call({
name: '',
message: undefined,
});
assert.sameValue(result, 'message', 'return msg');
result = false;
result = method.call({
name: { toString() { return ''; } },
message: 'the message!',
});
assert.sameValue(result, 'the message!', 'own name property is cast to an empty string');
result = false;
result = method.call(Object.create({
name: { toString() { return ''; } },
message: 'the message!',
}));
assert.sameValue(result, 'the message!', 'chained name property is cast to an empty string');

View File

@ -0,0 +1,83 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString on the name object value
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError, Symbol.toPrimitive]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var obj = {
name: {
[Symbol.toPrimitive]() {
called += 1;
return 'from @@toPrimitive';
},
toString() {
throw new Test262Error();
},
valueOf() {
throw new Test262Error();
},
},
message: '',
};
var result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from @@toPrimitive');
called = 0;
obj = {
name: {
[Symbol.toPrimitive]: undefined,
toString() {
called += 1;
return 'from the toString method';
},
valueOf() {
throw new Test262Error();
},
},
message: '',
};
result = false;
result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from the toString method');
called = 0;
obj = {
name: {
[Symbol.toPrimitive]: undefined,
toString: undefined,
valueOf() {
called += 1;
return 'from the valueOf method';
},
},
message: '',
};
result = false;
result = method.call(obj);
assert.sameValue(called, 1);
assert.sameValue(result, 'from the valueOf method');

View File

@ -0,0 +1,34 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(name)
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError, Symbol]
---*/
var method = AggregateError.prototype.toString;
var obj = { name: Symbol(), message: '' };
assert.throws(TypeError, function() {
method.call(obj);
}, 'own property');
obj = Object.create({ name: Symbol(), message: '' });
assert.throws(TypeError, function() {
method.call(obj);
}, 'from prototype');

View File

@ -0,0 +1,38 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(name) where it can return "undefined"
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var obj = {
name: {
toString() {
return undefined;
}
},
message: '',
};
assert.sameValue(method.call(obj), 'undefined', 'without message');
obj.message = 'lol';
assert.sameValue(method.call(obj), 'undefined\u003A\u0020lol', 'with message');

View File

@ -0,0 +1,36 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
ToString(name)
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var obj = { message: '' };
obj.name = 0;
assert.sameValue(method.call(obj), '0', 'Number 0');
obj.name = null;
assert.sameValue(method.call(obj), 'null', 'null');
obj.name = false;
assert.sameValue(method.call(obj), 'false', 'false');
obj.name = true;
assert.sameValue(method.call(obj), 'true', 'true');
obj.name = 1;
assert.sameValue(method.call(obj), '1', 'Number 1');

View File

@ -0,0 +1,68 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
An undefined name property value is cast to 'AggregateError'
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var result = method.call({
name: undefined,
message: '',
});
assert.sameValue(result, 'AggregateError', 'explicit from own property');
result = false;
result = method.call({
message: '',
});
assert.sameValue(result, 'AggregateError', 'implicit');
result = false;
result = method.call(Object.create({
name: undefined,
message: '',
}));
assert.sameValue(result, 'AggregateError', 'explicit from prototype');
result = false;
result = method.call({
name: undefined,
message: 'a message',
});
assert.sameValue(result, 'AggregateError\u003A\u0020a message', 'explicit from own property, message is set');
result = false;
result = method.call({
message: 'a message',
});
assert.sameValue(result, 'AggregateError\u003A\u0020a message', 'implicit, message is set');
result = false;
result = method.call(Object.create({
name: undefined,
message: 'a message',
}));
assert.sameValue(result, 'AggregateError\u003A\u0020a message', 'explicit from prototype, message is set');

View File

@ -0,0 +1,30 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Gets the Object name
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
...
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var called = 0;
var obj = {
get name() {
called += 1;
}
};
method.call(obj);
assert.sameValue(called, 1);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Property descriptor of AggregateError.prototype.toString.length
info: |
AggregateError.prototype.toString
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]
features: [AggregateError]
---*/
verifyProperty(AggregateError.prototype.toString, 'length', {
value: 0,
enumerable: false,
writable: false,
configurable: true
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Property descriptor of AggregateError.prototype.toString.name
info: |
AggregateError.prototype.toString
17 ECMAScript Standard Built-in Objects
Functions that are specified as get or set accessor functions of built-in
properties have "get " or "set " prepended to the property name string.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
verifyProperty(AggregateError.prototype.toString, 'name', {
value: 'toString',
enumerable: false,
writable: false,
configurable: true
});

View File

@ -0,0 +1,23 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Property descriptor of AggregateError.prototype.toString
info: |
ES Section 17
Every other data property (...) has the attributes { [[Writable]]: true, [[Enumerable]]: false,
[[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [AggregateError]
---*/
assert.sameValue(typeof AggregateError.prototype.toString, 'function');
verifyProperty(AggregateError.prototype, 'toString', {
configurable: true,
writable: true,
enumerable: false,
});

View File

@ -0,0 +1,38 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Returns a string concatenating name and msg when both are defined
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
3. Let name be ? Get(O, "name").
4. If name is undefined, set name to "AggregateError"; otherwise set name to ? ToString(name).
5. Let msg be ? Get(O, "message").
6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
7. If name is the empty String, return msg.
8. If msg is the empty String, return name.
9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE) and msg.
features: [AggregateError]
---*/
var method = AggregateError.prototype.toString;
var obj = {
name: 'foo',
message: 'bar',
};
assert.sameValue(method.call(obj), 'foo\u003A\u0020bar');
obj = new AggregateError(['a', 'b', 'c'], 'Hello World!');
assert.sameValue(method.call(obj), 'AggregateError\u003A\u0020Hello World!');
obj = new AggregateError(['a', 'b', 'c']);
assert.sameValue(method.call(obj), 'AggregateError');

View File

@ -0,0 +1,45 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-aggregate-error.prototype.toString
description: >
Property descriptor of AggregateError.prototype.toString
info: |
AggregateError.prototype.toString ( )
1. Let O be the this value.
2. If Type(O) is not Object, throw a TypeError exception.
features: [AggregateError, Symbol]
---*/
var method = AggregateError.prototype.toString;
assert.throws(TypeError, () => {
method.call(undefined);
}, 'undefined');
assert.throws(TypeError, () => {
method.call(null);
}, 'null');
assert.throws(TypeError, () => {
method.call(false);
}, 'false');
assert.throws(TypeError, () => {
method.call(true);
}, 'true');
assert.throws(TypeError, () => {
method.call(42);
}, 'number');
assert.throws(TypeError, () => {
method.call('string');
}, 'string');
var s = Symbol();
assert.throws(TypeError, () => {
method.call(s);
}, 'symbol');