Remove ES_NEXT macro (#4915)

- remove all '#JERRY_ESNEXT' macro
- remove 5.1 build profile, update test runner accordingly (Note: all builtins are turn on by default)
- move tests from tests/jerry/esnext into tests/jerry, concatenate files with same names
- add skiplist to some snapshot tests that were supported only in 5.1
- fix doxygen issues that were hidden before (bc. of es.next macro)

Co-authored-by: Martin Negyokru [email protected]
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
This commit is contained in:
Szilagyi Adam authored and GitHub committed 2022-01-31 16:46:00 +01:00
1 parent 76403606d0
commit 4924f9fd31
973 files changed
+1902 -8240

No files matched your search

File renamed without changes.
File renamed without changes.
+242
View File
@@ -142,3 +142,245 @@ function nested_args()
assert(a === 3);
}
nested_args(3);
function f1(a, b, c)
{
'use strict';
assert(!Object.hasOwnProperty(arguments,'caller'));
}
f1(1, 2, 3);
// Normal arguments access
function f2(a = arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a[1] === 2)
}
f2(undefined, 2)
function f3(a = arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a[1] === "R")
}
f3(undefined, "R")
function f4(a = arguments)
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a[1] === -1.5)
}
f4(undefined, -1.5)
// Normal arguments access with eval
function f5(a = arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a[1] === 2)
eval()
}
f5(undefined, 2)
function f6(a = arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a[1] === "R")
eval()
}
f6(undefined, "R")
function f7(a = arguments)
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a[1] === -1.5)
eval()
}
f7(undefined, -1.5)
// Argument access through a function
function f8(a = () => arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a()[1] === 2)
}
f8(undefined, 2)
function f9(a = () => arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a()[1] === "R")
}
f9(undefined, "R")
function f10(a = () => arguments)
{
let arguments = 3.25
assert(arguments === 3.25)
assert(a()[1] === -1.5)
}
f10(undefined, -1.5)
// Argument access through an eval
function f11(a = eval("() => arguments"))
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a()[1] === 2)
}
f11(undefined, 2)
function f12(a = eval("() => arguments"))
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a()[1] === "R")
}
f12(undefined, "R")
function f13(a = eval("() => arguments"))
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a()[1] === -1.5)
}
f13(undefined, -1.5)
// Other cases
try {
function f14(a = arguments)
{
assert(a[1] === 6)
arguments;
let arguments = 1;
}
f14(undefined, 6)
assert(false)
} catch (e) {
assert(e instanceof ReferenceError)
}
try {
eval("'use strict'; function f(a = arguments) { arguments = 5; eval() }");
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
function f15()
{
assert(arguments[0] === "A")
var arguments = 1
assert(arguments === 1)
}
f15("A")
function f16()
{
assert(arguments() === "W")
function arguments() { return "W" }
assert(arguments() === "W")
}
f16("A")
function f17(a = arguments = "Val")
{
assert(arguments === "Val")
}
f17();
function f18(s = (v) => arguments = v, g = () => arguments)
{
const arguments = -3.25
s("X")
assert(g() === "X")
assert(arguments === -3.25)
}
f18()
function f19(e = (v) => eval(v))
{
var arguments = -12.5
e("arguments[0] = 4.5")
assert(e("arguments[0]") === 4.5)
assert(e("arguments[1]") === "A")
assert(arguments === -12.5)
}
f19(undefined, "A");
function f20 (arguments, a = eval('arguments')) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f20(3.1);
function f21 (arguments, a = arguments) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f21(3.1);
function f22 (arguments, [a = arguments]) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f22(3.1, []);
try {
function f23(p = eval("var arguments"), arguments)
{
}
f23()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
try {
function f24(p = eval("var arguments")) {
let arguments;
}
f24()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
try {
function f25(p = eval("var arguments")) {
function arguments() { }
}
f25()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
function f26(arguments, eval = () => eval()) {
assert(arguments === undefined);
}
f26(undefined);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+42
View File
@@ -189,3 +189,45 @@ var value = array.slice(1, {
})
array_check(value, []);
// Constructor creates longer array than expected.
class LongArray extends Array {
constructor(len) {
super (42);
this.fill ("foo");
}
}
var a = new LongArray (5);
a.length = 5;
var sliced = a.slice ();
assert (sliced.length == 5);
assert (JSON.stringify (sliced) == '["foo","foo","foo","foo","foo"]')
// Constructor creates shorter array than expected.
class ShortArray extends Array {
constructor(len) {
super (2);
this.fill ("bar");
}
}
var b = new ShortArray (8);
b.length = 8;
b.fill ("asd", 2);
var sliced2 = b.slice ();
assert (sliced2.length == 8);
assert (JSON.stringify (sliced2) == '["bar","bar","asd","asd","asd","asd","asd","asd"]');
// Constructor creates array of the expected size.
class ExactArray extends Array {
constructor(len) {
super (len);
this.fill ("baz");
}
}
var c = new ExactArray (5);
var sliced3 = c.slice();
assert (sliced3.length == 5);
assert (JSON.stringify (sliced3) == '["baz","baz","baz","baz","baz"]');
+11
View File
@@ -184,3 +184,14 @@ try {
} catch (e) {
assert(e instanceof TypeError);
}
var proxy = new Proxy({length: 5}, {
getOwnPropertyDescriptor() { throw 42.5; }
})
try {
Array.prototype.sort.call(proxy);
assert(false);
} catch (e) {
assert(e === 42.5);
}
+4
View File
@@ -123,3 +123,7 @@ try {
} catch (e) {
assert(e instanceof TypeError);
}
var arrayLike = {get 5() { throw "shouldn't throw"; }};
arrayLike.length = 10;
Array.prototype.unshift.call(arrayLike);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+46
View File
@@ -21,3 +21,49 @@ assert (Boolean.prototype.valueOf() === false);
assert (Object.prototype.toString.call (Number.prototype) === '[object Number]');
assert (Number.prototype.valueOf() === 0);
var prototypes = [
Date.prototype,
RegExp.prototype,
Error.prototype,
EvalError.prototype,
RangeError.prototype,
ReferenceError.prototype,
SyntaxError.prototype,
TypeError.prototype,
URIError.prototype
]
for (proto of prototypes) {
assert (Object.prototype.toString.call (proto) === '[object Object]');
}
try {
Date.prototype.valueOf();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
try {
RegExp.prototype.exec("");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
try {
RegExp.prototype.compile("a", "u");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
assert (RegExp.prototype.source === '(?:)');
assert (RegExp.prototype.global === undefined);
assert (RegExp.prototype.ignoreCase === undefined);
assert (RegExp.prototype.multiline === undefined);
assert (RegExp.prototype.sticky === undefined);
assert (RegExp.prototype.unicode === undefined);
assert (RegExp.prototype.dotAll === undefined);
assert (RegExp.prototype.flags === '');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+52
View File
@@ -75,3 +75,55 @@ catch (e)
assert (typeof Date (2015) == "string");
assert (typeof Date() != typeof (new Date ()));
var sym = Symbol();
var date;
try {
date = new Date(sym, 11, 17, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, sym, 17, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, sym, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, sym, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, sym, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, 24, sym);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, 24, 0, sym);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
File renamed without changes.
File renamed without changes.
+9
View File
@@ -198,3 +198,12 @@ assert (URIError.prototype.constructor === URIError);
assert (URIError.prototype.name === "URIError");
assert (URIError.prototype.message === "");
assert (URIError.prototype.toString() === "URIError");
/* Prototype of NativeErrors should be Error */
assert(Object.getPrototypeOf(EvalError) === Error);
assert(Object.getPrototypeOf(RangeError) === Error);
assert(Object.getPrototypeOf(ReferenceError) === Error);
assert(Object.getPrototypeOf(SyntaxError) === Error);
assert(Object.getPrototypeOf(TypeError) === Error);
assert(Object.getPrototypeOf(URIError) === Error);
assert(Object.getPrototypeOf(AggregateError) === Error);
-254
View File
@@ -1,254 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function f1(a, b, c)
{
'use strict';
assert(!Object.hasOwnProperty(arguments,'caller'));
}
f1(1, 2, 3);
// Normal arguments access
function f2(a = arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a[1] === 2)
}
f2(undefined, 2)
function f3(a = arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a[1] === "R")
}
f3(undefined, "R")
function f4(a = arguments)
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a[1] === -1.5)
}
f4(undefined, -1.5)
// Normal arguments access with eval
function f5(a = arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a[1] === 2)
eval()
}
f5(undefined, 2)
function f6(a = arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a[1] === "R")
eval()
}
f6(undefined, "R")
function f7(a = arguments)
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a[1] === -1.5)
eval()
}
f7(undefined, -1.5)
// Argument access through a function
function f8(a = () => arguments)
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a()[1] === 2)
}
f8(undefined, 2)
function f9(a = () => arguments)
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a()[1] === "R")
}
f9(undefined, "R")
function f10(a = () => arguments)
{
let arguments = 3.25
assert(arguments === 3.25)
assert(a()[1] === -1.5)
}
f10(undefined, -1.5)
// Argument access through an eval
function f11(a = eval("() => arguments"))
{
assert(arguments[1] === 2)
var arguments = 1
assert(arguments === 1)
assert(a()[1] === 2)
}
f11(undefined, 2)
function f12(a = eval("() => arguments"))
{
assert(arguments() === "X")
function arguments() { return "X" }
assert(arguments() === "X")
assert(a()[1] === "R")
}
f12(undefined, "R")
function f13(a = eval("() => arguments"))
{
const arguments = 3.25
assert(arguments === 3.25)
assert(a()[1] === -1.5)
}
f13(undefined, -1.5)
// Other cases
try {
function f14(a = arguments)
{
assert(a[1] === 6)
arguments;
let arguments = 1;
}
f14(undefined, 6)
assert(false)
} catch (e) {
assert(e instanceof ReferenceError)
}
try {
eval("'use strict'; function f(a = arguments) { arguments = 5; eval() }");
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
function f15()
{
assert(arguments[0] === "A")
var arguments = 1
assert(arguments === 1)
}
f15("A")
function f16()
{
assert(arguments() === "W")
function arguments() { return "W" }
assert(arguments() === "W")
}
f16("A")
function f17(a = arguments = "Val")
{
assert(arguments === "Val")
}
f17();
function f18(s = (v) => arguments = v, g = () => arguments)
{
const arguments = -3.25
s("X")
assert(g() === "X")
assert(arguments === -3.25)
}
f18()
function f19(e = (v) => eval(v))
{
var arguments = -12.5
e("arguments[0] = 4.5")
assert(e("arguments[0]") === 4.5)
assert(e("arguments[1]") === "A")
assert(arguments === -12.5)
}
f19(undefined, "A");
function f20 (arguments, a = eval('arguments')) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f20(3.1);
function f21 (arguments, a = arguments) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f21(3.1);
function f22 (arguments, [a = arguments]) {
assert(a === 3.1);
assert(arguments === 3.1);
}
f22(3.1, []);
try {
function f23(p = eval("var arguments"), arguments)
{
}
f23()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
try {
function f24(p = eval("var arguments")) {
let arguments;
}
f24()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
try {
function f25(p = eval("var arguments")) {
function arguments() { }
}
f25()
assert(false)
} catch (e) {
assert(e instanceof SyntaxError)
}
function f26(arguments, eval = () => eval()) {
assert(arguments === undefined);
}
f26(undefined);
@@ -1,55 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Constructor creates longer array than expected.
class LongArray extends Array {
constructor(len) {
super (42);
this.fill ("foo");
}
}
var a = new LongArray (5);
a.length = 5;
var sliced = a.slice ();
assert (sliced.length == 5);
assert (JSON.stringify (sliced) == '["foo","foo","foo","foo","foo"]')
// Constructor creates shorter array than expected.
class ShortArray extends Array {
constructor(len) {
super (2);
this.fill ("bar");
}
}
var b = new ShortArray (8);
b.length = 8;
b.fill ("asd", 2);
var sliced2 = b.slice ();
assert (sliced2.length == 8);
assert (JSON.stringify (sliced2) == '["bar","bar","asd","asd","asd","asd","asd","asd"]');
// Constructor creates array of the expected size.
class ExactArray extends Array {
constructor(len) {
super (len);
this.fill ("baz");
}
}
var c = new ExactArray (5);
var sliced3 = c.slice();
assert (sliced3.length == 5);
assert (JSON.stringify (sliced3) == '["baz","baz","baz","baz","baz"]');
@@ -1,24 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var proxy = new Proxy({length: 5}, {
getOwnPropertyDescriptor() { throw 42.5; }
})
try {
Array.prototype.sort.call(proxy);
assert(false);
} catch (e) {
assert(e === 42.5);
}
@@ -1,17 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var arrayLike = {get 5() { throw "shouldn't throw"; }};
arrayLike.length = 10;
Array.prototype.unshift.call(arrayLike);
-60
View File
@@ -1,60 +0,0 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var prototypes = [
Date.prototype,
RegExp.prototype,
Error.prototype,
EvalError.prototype,
RangeError.prototype,
ReferenceError.prototype,
SyntaxError.prototype,
TypeError.prototype,
URIError.prototype
]
for (proto of prototypes) {
assert (Object.prototype.toString.call (proto) === '[object Object]');
}
try {
Date.prototype.valueOf();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
try {
RegExp.prototype.exec("");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
try {
RegExp.prototype.compile("a", "u");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
assert (RegExp.prototype.source === '(?:)');
assert (RegExp.prototype.global === undefined);
assert (RegExp.prototype.ignoreCase === undefined);
assert (RegExp.prototype.multiline === undefined);
assert (RegExp.prototype.sticky === undefined);
assert (RegExp.prototype.unicode === undefined);
assert (RegExp.prototype.dotAll === undefined);
assert (RegExp.prototype.flags === '');
-65
View File
@@ -1,65 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var sym = Symbol();
var date;
try {
date = new Date(sym, 11, 17, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, sym, 17, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, sym, 3, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, sym, 24, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, sym, 0);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, 24, sym);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
try {
date = new Date(1997, 11, 17, 3, 24, 0, sym);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
-22
View File
@@ -1,22 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* Prototype of NativeErrors should be Error */
assert(Object.getPrototypeOf(EvalError) === Error);
assert(Object.getPrototypeOf(RangeError) === Error);
assert(Object.getPrototypeOf(ReferenceError) === Error);
assert(Object.getPrototypeOf(SyntaxError) === Error);
assert(Object.getPrototypeOf(TypeError) === Error);
assert(Object.getPrototypeOf(URIError) === Error);
assert(Object.getPrototypeOf(AggregateError) === Error);
@@ -1,69 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* extended class */
(function() {
class C extends Function {}
var c = new C("x", "y", "return this.foo + x + y;").bind({foo : 1}, 2);
assert(c(3) === 6);
assert(c instanceof C);
})();
function boundPrototypeChecker(f, proto) {
Object.setPrototypeOf(f, proto);
var boundFunc = Function.prototype.bind.call(f, null);
assert(Object.getPrototypeOf(boundFunc) === proto);
}
/* generator function */
(function() {
var f = function*(){};
boundPrototypeChecker(f, Function.prototype)
boundPrototypeChecker(f, {})
boundPrototypeChecker(f, null);
})();
/* arrow function */
(function() {
var f = () => 5;
boundPrototypeChecker(f, Function.prototype)
boundPrototypeChecker(f, {})
boundPrototypeChecker(f, null);
})();
/* simple class */
(function() {
class C {};
boundPrototypeChecker(C, Function.prototype)
boundPrototypeChecker(C, {})
boundPrototypeChecker(C, null);
})();
/* subclasses */
(function() {
function boundPrototypeChecker(superclass) {
class C extends superclass {
constructor() {
return Object.create(null);
}
}
var boundF = Function.prototype.bind.call(C, null);
assert(Object.getPrototypeOf(boundF) === Object.getPrototypeOf(C));
}
boundPrototypeChecker(function(){});
boundPrototypeChecker(Array);
boundPrototypeChecker(null);
})();
@@ -1,188 +0,0 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function check() {}
if (check.toString() !== "function () { /* ecmascript */ }")
{
var a, b, o, c, f;
/* Function statements. */
a = 6; function f1(a,b=1,c) { return a /* comment */ + b + c } b = 7
assert(f1.toString() === "function f1(a,b=1,c) { return a /* comment */ + b + c }")
a = 6; function * f2(a,b,c=1) {
function x() {}
} b = 7
assert(f2.toString() === "function * f2(a,b,c=1) {\n function x() {}\n }")
a = 6;async function f3 ( a , b , c ) { } b = 7
assert(f3.toString() === "async function f3 ( a , b , c ) { }")
a = 6;async/**/function*f4(a,b,c){} b = 7
assert(f4.toString() === "async/**/function*f4(a,b,c){}")
/* Object initializers. */
o = {f(a) { return a }}
assert(o.f.toString() === "f(a) { return a }")
o = {f:function(a){/**/}}
assert(o.f.toString() === "function(a){/**/}")
o = { [function(){ return 'f' }()] (a = function() {}) {} }
assert(o.f.toString() === "[function(){ return 'f' }()] (a = function() {}) {}")
o = {* f(a) {}}
assert(o.f.toString() === "* f(a) {}")
o = {*[function(){ return 'f' }()](a) {}}
assert(o.f.toString() === "*[function(){ return 'f' }()](a) {}")
o = {async/**/f(a) {}}
assert(o.f.toString() === "async/**/f(a) {}")
o = {/**/async [function(){ return 'f' }()](a) {}/**/}
assert(o.f.toString() === "async [function(){ return 'f' }()](a) {}")
o = {a:1,async/**/*/**/f(a) {},b:1}
assert(o.f.toString() === "async/**/*/**/f(a) {}")
o = {async *//
[function(){ return 'f' }()](a) {}/**/}
assert(o.f.toString() === "async *//\n [function(){ return 'f' }()](a) {}")
o = { get a() {return/**/6} }
assert(Object.getOwnPropertyDescriptor(o, "a").get.toString() === "get a() {return/**/6}")
o = { get[function(){ return 'a' }()](){} }
assert(Object.getOwnPropertyDescriptor(o, "a").get.toString() === "get[function(){ return 'a' }()](){}")
o = { set a(v) {/**/} }
assert(Object.getOwnPropertyDescriptor(o, "a").set.toString() === "set a(v) {/**/}")
o = {/**/set/**/[function(){ return 'a' }()]/**/(v) {/**/}/**/}
assert(Object.getOwnPropertyDescriptor(o, "a").set.toString() === "set/**/[function(){ return 'a' }()]/**/(v) {/**/}")
/* Class static functions. */
c = class { static/**/f() {}/**/ }
assert(c.f.toString() === "f() {}")
c = class { static[function(){ return 'f' }()]() {} }
assert(c.f.toString() === "[function(){ return 'f' }()]() {}")
c = class { static *f() {} }
assert(c.f.toString() === "*f() {}")
c = class {/**/static * [function(){ return 'f' }()](a=6){}/**/}
assert(c.f.toString() === "* [function(){ return 'f' }()](a=6){}")
c = class { static/**/async f() {} }
assert(c.f.toString() === "async f() {}")
c = class {static async[function(){ return 'f' }()]() {/**/}}
assert(c.f.toString() === "async[function(){ return 'f' }()]() {/**/}")
c = class { static async*f() {}}
assert(c.f.toString() === "async*f() {}")
c = class { static async*/**/[function(){ return 'f' }()](){} }
assert(c.f.toString() === "async*/**/[function(){ return 'f' }()](){}")
c = class { static/**/get/**/a() {}}
assert(Object.getOwnPropertyDescriptor(c, "a").get.toString() === "get/**/a() {}")
c = class {static set a(v){}}
assert(Object.getOwnPropertyDescriptor(c, "a").set.toString() === "set a(v){}")
c = class { static get[function(){ return 'a' }()](){} }
assert(Object.getOwnPropertyDescriptor(c, "a").get.toString() === "get[function(){ return 'a' }()](){}")
c = class { static set[function(){ return 'a' }()](v){}//
}
assert(Object.getOwnPropertyDescriptor(c, "a").set.toString() === "set[function(){ return 'a' }()](v){}")
/* Class functions. */
o = Object.getPrototypeOf(new class {/**/f() {}/**/})
assert(o.f.toString() === "f() {}")
o = Object.getPrototypeOf(new class {[function(){ return 'f' }()](){}})
assert(o.f.toString() === "[function(){ return 'f' }()](){}")
o = Object.getPrototypeOf(new class { * /**/ f() {} })
assert(o.f.toString() === "* /**/ f() {}")
o = Object.getPrototypeOf(new class { * [function(){ return 'f' }()]/**/(){} })
assert(o.f.toString() === "* [function(){ return 'f' }()]/**/(){}")
o = Object.getPrototypeOf(new class {async f() {}})
assert(o.f.toString() === "async f() {}")
o = Object.getPrototypeOf(new class {async[function(){ return 'f' }()](){}})
assert(o.f.toString() === "async[function(){ return 'f' }()](){}")
o = Object.getPrototypeOf(new class {/**/get/**/a() {}/**/})
assert(Object.getOwnPropertyDescriptor(o, "a").get.toString() === "get/**/a() {}")
o = Object.getPrototypeOf(new class { set a(v){} })
assert(Object.getOwnPropertyDescriptor(o, "a").set.toString() === "set a(v){}")
o = Object.getPrototypeOf(new class {/**/get/**/[function(){ return 'a' }()]() {}/**/})
assert(Object.getOwnPropertyDescriptor(o, "a").get.toString() === "get/**/[function(){ return 'a' }()]() {}")
o = Object.getPrototypeOf(new class { set/**/[function(){ return 'a' }()]( v ){} })
assert(Object.getOwnPropertyDescriptor(o, "a").set.toString() === "set/**/[function(){ return 'a' }()]( v ){}")
/* Function creators. */
f = Function("a,b", "return a + b")
assert(f.toString() === "function anonymous(a,b\n) {\nreturn a + b\n}")
f = Function("", "")
assert(f.toString() === "function anonymous(\n) {\n\n}")
f = function*(){}.constructor("a,b", "c", "yield a; return b + c")
assert(f.toString() === "function* anonymous(a,b,c\n) {\nyield a; return b + c\n}")
f = async function(){}.constructor("a", "return a + 'x'")
assert(f.toString() === "async function anonymous(a\n) {\nreturn a + 'x'\n}")
f = async function*(){}.constructor("a=3", "return a")
assert(f.toString() === "async function* anonymous(a=3\n) {\nreturn a\n}")
f = Function("a = function(x) { return x + 3 }", "return a")
assert(f().toString() === "function(x) { return x + 3 }")
f = Function("return function(x) { return x + 3 }")
assert(f().toString() === "function(x) { return x + 3 }")
/* Arrow functions. */
f = x => x + 1/**/
assert(f.toString() === "x => x + 1")
f =x => { return x + 1 }/**/
assert(f.toString() === "x => { return x + 1 }")
f = (/**/) => 'x' //
+ y
assert(f.toString() === "(/**/) => 'x' //\n + y")
f = async x => x + 1
assert(f.toString() === "async x => x + 1")
f =/**/async (x,/**/y)=>/**/null
assert(f.toString() === "async (x,/**/y)=>/**/null")
}
Loaded 100 of 973 files, more files were not shown because too many files have changed in this diff. Show more