Set function `length` and `name` in `CreateBuiltinFunction`

This commit is contained in:
ExE Boss 2020-12-14 03:00:00 +01:00 committed by Rick Waldron
parent 11624af8d0
commit 8f904d8cc8
17 changed files with 347 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Function constructor property order
info: |
Set order: "length", "name", ...
---*/
var propNames = Object.getOwnPropertyNames(Function);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Function constructor property order
info: |
Set order: "length", "name", ...
---*/
var propNames = Object.getOwnPropertyNames(Function.prototype);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Object constructor property order
info: |
Set order: "length", "name", ...
---*/
var propNames = Object.getOwnPropertyNames(Object);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,30 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise.all resolve element function property order
info: |
Set order: "length", "name"
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function() {}, function() {});
}
NotPromise.resolve = function(v) {
return v;
};
Promise.all.call(NotPromise, [thenable]);
var propNames = Object.getOwnPropertyNames(resolveElementFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise.allSettled reject element function property order
info: |
Set order: "length", "name"
features: [Promise.allSettled]
---*/
var rejectElementFunction;
var thenable = {
then: function(_, reject) {
rejectElementFunction = reject;
}
};
function NotPromise(executor) {
executor(function() {}, function() {});
}
NotPromise.resolve = function(v) {
return v;
};
Promise.allSettled.call(NotPromise, [thenable]);
var propNames = Object.getOwnPropertyNames(rejectElementFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise.allSettled resolve element function property order
info: |
Set order: "length", "name"
features: [Promise.allSettled]
---*/
var resolveElementFunction;
var thenable = {
then: function(fulfill) {
resolveElementFunction = fulfill;
}
};
function NotPromise(executor) {
executor(function() {}, function() {});
}
NotPromise.resolve = function(v) {
return v;
};
Promise.allSettled.call(NotPromise, [thenable]);
var propNames = Object.getOwnPropertyNames(resolveElementFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise.any resolve element function property order
info: |
Set order: "length", "name"
features: [Promise.any]
---*/
var rejectElementFunction;
var thenable = {
then: function(_, reject) {
rejectElementFunction = reject;
}
};
function NotPromise(executor) {
executor(function() {}, function() {});
}
NotPromise.resolve = function(v) {
return v;
};
Promise.any.call(NotPromise, [thenable]);
var propNames = Object.getOwnPropertyNames(rejectElementFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,23 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise executor function property order
info: |
Set order: "length", "name"
---*/
var executorFunction;
function NotPromise(executor) {
executorFunction = executor;
executor(function() {}, function() {});
}
Promise.resolve.call(NotPromise);
var propNames = Object.getOwnPropertyNames(executorFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise constructor property order
info: |
Set order: "length", "name", ...
---*/
var propNames = Object.getOwnPropertyNames(Promise);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,20 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise reject function property order
info: |
Set order: "length", "name"
---*/
var rejectFunction;
new Promise(function(_, reject) {
rejectFunction = reject;
});
var propNames = Object.getOwnPropertyNames(rejectFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,20 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Promise resolve function property order
info: |
Set order: "length", "name"
---*/
var resolveFunction;
new Promise(function(resolve) {
resolveFunction = resolve;
});
var propNames = Object.getOwnPropertyNames(resolveFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,16 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Proxy constructor property order
info: |
Set order: "length", "name", ...
features: [Proxy]
---*/
var propNames = Object.getOwnPropertyNames(Proxy);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,17 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Proxy revocation function property order
info: |
Set order: "length", "name"
---*/
var revocationFunction = Proxy.revocable({}, {}).revoke;
var propNames = Object.getOwnPropertyNames(revocationFunction);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,20 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: "%ThrowTypeError% function property order"
info: |
Set order: "length", "name"
---*/
var ThrowTypeError = Object.getOwnPropertyDescriptor(function() {
"use strict";
return arguments;
}(), "callee").get;
var propNames = Object.getOwnPropertyNames(ThrowTypeError);
var lengthIndex = propNames.indexOf("length");
var nameIndex = propNames.indexOf("name");
assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1,
"The `length` property comes before the `name` property on built-in functions");

View File

@ -0,0 +1,16 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: Collator bound compare function property order
info: |
Set order: "length", "name"
includes: [compareArray.js]
---*/
var compareFn = new Intl.Collator().compare;
assert.compareArray(
Object.getOwnPropertyNames(compareFn),
['length', 'name']
);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: DateTimeFormat bound format function property order
info: |
Set order: "length", "name"
includes: [compareArray.js]
---*/
var formatFn = new Intl.DateTimeFormat().format;
assert.compareArray(
Object.getOwnPropertyNames(formatFn),
['length', 'name']
);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2020 ExE Boss. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createbuiltinfunction
description: NumberFormat bound format function property order
info: |
Set order: "length", "name"
includes: [compareArray.js]
---*/
var formatFn = new Intl.NumberFormat().format;
assert.compareArray(
Object.getOwnPropertyNames(formatFn),
['length', 'name']
);