Merge pull request #1702 from test262-automation/javascriptcore-test262-automation-export-eaa48b4f0

Import test changes from JavaScriptCore
This commit is contained in:
Leo Balter 2018-09-04 12:35:06 -04:00 committed by GitHub
commit 975ddb311a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 261 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"sourceRevisionAtLastExport": "671be37db3",
"targetRevisionAtLastExport": "eaa48b4f0",
"sourceRevisionAtLastExport": "3d4f832de4",
"targetRevisionAtLastExport": "199f6b315",
"curatedFiles": {
"/stress/Number-isNaN-basics.js": "DELETED_IN_TARGET",
"/stress/Object_static_methods_Object.getOwnPropertyDescriptors-proxy.js": "DELETED_IN_TARGET",

View File

@ -0,0 +1,137 @@
"use strict";
function assert(b) {
if (!b)
throw new Error;
}
function test1() {
function foo(dv) {
return [dv.getFloat32(0), dv.getFloat64(0)];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setFloat64(0, 128431.42342189432, false);
for (let i = 0; i < 10000; ++i) {
let result = foo(dv);
assert(result[0] !== result[1]);
}
}
test1();
function test2() {
function foo(dv) {
return [dv.getFloat32(0), dv.getFloat32(0)];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setFloat64(0, 128431.42342189432, false);
for (let i = 0; i < 10000; ++i) {
let result = foo(dv);
assert(result[0] === result[1]);
}
}
test2();
function test3() {
function foo(dv, ta) {
let a = dv.getFloat64(0, true);
ta[0] = Math.PI;
let b = dv.getFloat64(0, true);
return [a, b];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
let ta = new Float64Array(ab);
for (let i = 0; i < 40000; ++i) {
dv.setFloat64(0, 0.0, true);
let result = foo(dv, ta);
assert(result[0] === 0.0);
assert(result[1] === Math.PI);
}
}
test3();
function test4() {
function foo(dv) {
let a = dv.getInt32(0, true);
let b = dv.getInt32(0, false);
return [a, b];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setInt32(0, 0x11223344, true);
for (let i = 0; i < 40000; ++i) {
let result = foo(dv);
assert(result[0] === 0x11223344);
assert(result[1] === 0x44332211)
}
}
test4();
function test5() {
function foo(dv, littleEndian) {
let a = dv.getInt32(0, littleEndian);
let b = dv.getInt32(0, !littleEndian);
return [a, b];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setInt32(0, 0x11223344, true);
for (let i = 0; i < 40000; ++i) {
let result = foo(dv, true);
assert(result[0] === 0x11223344);
assert(result[1] === 0x44332211)
}
}
test5();
function test6() {
function foo(dv, littleEndian) {
let a = dv.getInt32(0, littleEndian);
let b = dv.getInt32(0, littleEndian);
return [a, b];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setInt32(0, 0x11223344, true);
for (let i = 0; i < 40000; ++i) {
let result = foo(dv, true);
assert(result[0] === 0x11223344);
assert(result[1] === 0x11223344)
}
}
test6();
function test7() {
function foo(dv) {
let a = dv.getInt32(0, true);
let b = dv.getInt32(4, true);
return [a, b];
}
noInline(foo);
let ab = new ArrayBuffer(8);
let dv = new DataView(ab);
dv.setInt32(0, 0x11223344, true);
dv.setInt32(4, 0x12121212, true);
for (let i = 0; i < 40000; ++i) {
let result = foo(dv, true);
assert(result[0] === 0x11223344);
assert(result[1] === 0x12121212);
}
}
test7();

View File

@ -0,0 +1,60 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}
shouldThrow(() => {
Function("@", { toString() { throw 42; } })
}, `42`);
var counter = 0;
class Parameter {
constructor(index)
{
this.index = index;
}
toString() {
shouldBe(this.index, counter);
counter++;
return `x${this.index}`;
}
};
class Body {
constructor(index)
{
this.index = index;
}
toString() {
shouldBe(this.index, counter);
counter++;
return `42`;
}
};
var parameters = [];
for (var i = 0; i < 50; ++i) {
parameters.push(new Parameter(parameters.length));
var args = parameters.slice();
args.push(new Body(args.length));
counter = 0;
Function.apply(this, args);
shouldBe(counter, args.length);
}

View File

@ -0,0 +1,11 @@
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
shouldBe((function test() { }).toString(), `function test() { }`);
shouldBe((() => { }).toString(), `() => { }`);
shouldBe((function* test() { }).toString(), `function* test() { }`);
shouldBe((async function* test() { }).toString(), `async function* test() { }`);
shouldBe((async function test() { }).toString(), `async function test() { }`);
shouldBe((async () => { }).toString(), `async () => { }`);

View File

@ -0,0 +1,25 @@
//@ runDefault("--jitPolicyScale=0", "--useConcurrentJIT=0", "--validateGraphAtEachPhase=1")
let re0 = /a/;
let str0 = 'b';
function foo() {
/a/.exec('b');
for (var i = 0; i < 6; i++) {
}
for (var i = 0; i < 3; i++) {
re0.exec('a');
}
str0.match(/a/);
for (var i = 0; i < 2; i++) {
str0.match(/a/g);
}
}
function bar() {
for (var i = 0; i < 6; i++) {
'a'.match(/b/);
}
}
foo();
bar();
foo();

View File

@ -0,0 +1,12 @@
try {
var a0 = '\ud801';
var a1 = [];
a2 = a0.padEnd(2147483644,'x');
a1[a2];
} catch (e) {
exception = e;
}
if (exception != "Error: Out of memory")
throw "FAILED";

View File

@ -0,0 +1,3 @@
//@ runDefault
// This test passes if it does not crash.
['a'+0].lastIndexOf('a0');

View File

@ -0,0 +1,7 @@
//@ runDefault
// This passes if it does not crash.
new WebAssembly.CompileError({
valueOf() {
throw new Error();
}
});

View File

@ -0,0 +1,4 @@
//@ runDefault
// This test passes if it does not crash.
let x = new DataView(new ArrayBuffer(1));
Object.defineProperty(x, 'foo', {});