Skip to content

Commit

Permalink
Set function length and name in CreateBuiltinFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss authored and rwaldron committed Jan 29, 2021
1 parent 11624af commit 8f904d8
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/built-ins/Function/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
15 changes: 15 additions & 0 deletions test/built-ins/Function/prototype/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
15 changes: 15 additions & 0 deletions test/built-ins/Object/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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");
23 changes: 23 additions & 0 deletions test/built-ins/Promise/executor-function-property-order.js
Original file line number Diff line number Diff line change
@@ -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");
15 changes: 15 additions & 0 deletions test/built-ins/Promise/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
20 changes: 20 additions & 0 deletions test/built-ins/Promise/reject-function-property-order.js
Original file line number Diff line number Diff line change
@@ -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");
20 changes: 20 additions & 0 deletions test/built-ins/Promise/resolve-function-property-order.js
Original file line number Diff line number Diff line change
@@ -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");
16 changes: 16 additions & 0 deletions test/built-ins/Proxy/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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");
20 changes: 20 additions & 0 deletions test/built-ins/ThrowTypeError/property-order.js
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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']
);
Original file line number Diff line number Diff line change
@@ -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']
);
Original file line number Diff line number Diff line change
@@ -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']
);

0 comments on commit 8f904d8

Please sign in to comment.