Merge jerry-test-suite into jerry tests (#3907)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-06-17 13:00:41 +02:00
committed by GitHub
parent 8719f72e61
commit cc4ac497b7
1576 changed files with 11216 additions and 29149 deletions
+19
View File
@@ -0,0 +1,19 @@
// 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 tc_15_03_04_02__001() {
assert(Function.prototype.toString.hasOwnProperty('length'));
assert(delete Function.prototype.toString.length);
assert(!Function.prototype.toString.hasOwnProperty('length'));
})();
+185
View File
@@ -0,0 +1,185 @@
// 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 tc_19_01_02__003() {
function test_set_prototype_of_success(o, proto, msg)
{
assert(o === Object.setPrototypeOf(o, proto));
if (msg)
{
print(msg + " PASS");
}
}
(function test_nonobject_o(undefined)
{
test_set_prototype_of_success(true, new Object(), "Object.setPrototypeOf(boolean, ...)");
test_set_prototype_of_success(3.14, new Object(), "Object.setPrototypeOf(number, ...)");
test_set_prototype_of_success("xyz", new Object(), "Object.setPrototypeOf(string, ...)");
})()
})();
(function tc_19_01_02__006() {
function test_set_prototype_of_success_set(o, proto, msg)
{
assert(o === Object.setPrototypeOf(o, proto));
assert(proto === Object.getPrototypeOf(o));
if (msg)
{
print(msg + " PASS");
}
}
(function test_set_prototype_of(undefined)
{
test_set_prototype_of_success_set(new Object(), new Object(), "Object.setPrototypeOf(o1, o2)");
test_set_prototype_of_success_set(new Object(), null, "Object.setPrototypeOf(o, null)");
})()
})();
(function tc_19_01_02__004() {
function test_set_prototype_of_error(o, proto, msg)
{
var name = "";
try
{
Object.setPrototypeOf(o, proto);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
if (msg)
{
print(msg + " PASS (XFAIL)");
}
}
function test_set_prototype_of_success_set(o, proto, msg)
{
assert(o === Object.setPrototypeOf(o, proto));
assert(proto === Object.getPrototypeOf(o));
if (msg)
{
print(msg + " PASS");
}
}
(function test_nonextensible_o(undefined)
{
var o = new Object();
var o_proto = Object.getPrototypeOf(o);
Object.preventExtensions(o);
test_set_prototype_of_success_set(o, o_proto, "Object.setPrototypeOf(o_nonext, o_nonext.__proto__)");
test_set_prototype_of_error(o, new Object(), "Object.setPrototypeOf(o_nonext, ...)");
})()
})();
(function tc_19_01_02__002() {
function test_set_prototype_of_error(o, proto, msg)
{
var name = "";
try
{
Object.setPrototypeOf(o, proto);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
if (msg)
{
print(msg + " PASS (XFAIL)");
}
}
(function test_nonobject_proto(undefined)
{
test_set_prototype_of_error(new Object(), undefined, "Object.setPrototypeOf(..., undefined)");
test_set_prototype_of_error(new Object(), true, "Object.setPrototypeOf(..., boolean)");
test_set_prototype_of_error(new Object(), 3.14, "Object.setPrototypeOf(..., number)");
test_set_prototype_of_error(new Object(), "xyz", "Object.setPrototypeOf(..., string)");
})()
})();
(function tc_19_01_02__005() {
function test_set_prototype_of_error(o, proto, msg)
{
var name = "";
try
{
Object.setPrototypeOf(o, proto);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
if (msg)
{
print(msg + " PASS (XFAIL)");
}
}
(function test_circularity(undefined)
{
var o = new Object();
test_set_prototype_of_error(o, o, "Object.setPrototypeOf(o, o)");
})()
})();
(function tc_19_01_02__001() {
function test_set_prototype_of_error(o, proto, msg)
{
var name = "";
try
{
Object.setPrototypeOf(o, proto);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
if (msg)
{
print(msg + " PASS (XFAIL)");
}
}
(function test_incoercible_o(undefined)
{
test_set_prototype_of_error(undefined, new Object(), "Object.setPrototypeOf(undefined, ...)");
test_set_prototype_of_error(null, new Object(), "Object.setPrototypeOf(null, ...)");
})();
})();
+661
View File
@@ -0,0 +1,661 @@
// 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 tc_22_02_02__004() {
function foo(v, k)
{
return this.num + v + k;
}
var a = Float32Array.from([10,20,30], foo, {num:0.5});
assert(a[0] === 10.5);
assert(a[1] === 21.5);
assert(a[2] === 32.5);
})();
(function tc_22_02_02__002() {
var a = Object.getPrototypeOf(Int8Array);
assert(a.length === 3);
})();
(function tc_22_02_02__003() {
var a = Object.getPrototypeOf(Int8Array);
var b = new Int8Array();
var c = Object.getPrototypeOf(Object.getPrototypeOf(b));
assert(c === a.prototype);
})();
(function tc_22_02_02__005() {
var name = "";
try
{
Int16Array.from.call(1);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
name = "";
try
{
Int16Array.from.call(Float32Array);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
name = "";
try
{
Int16Array.from.call(Float32Array, [1,2,3], 1);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
name = "";
try
{
Int16Array.from.call(Number, [1,2,3]);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
})();
(function tc_22_02_02__001() {
var a = Object.getPrototypeOf(Int8Array);
assert(a.name === "TypedArray");
})();
(function tc_22_02_01__013() {
var a = new Float32Array(2);
a[0] = 0.1;
a[1] = -2.3;
assert(a[0] === 0.10000000149011612);
assert(a[1] === -2.299999952316284);
})();
(function tc_22_02_01__021() {
var a = new Float32Array([0.1, 0.2, 0.3]);
var b = a.hasOwnProperty(1);
var c = a.hasOwnProperty(3);
assert (b === true);
assert (c === false);
})();
(function tc_22_02_01__002() {
var a = new Int8Array(5);
assert(a instanceof Int8Array);
})();
(function tc_22_02_01__006() {
var a = new Int8Array([1,2,3]);
assert(a instanceof Int8Array);
})();
(function tc_22_02_01__009() {
Int8Array.prototype[10] = 10;
var a = new Int8Array(5);
assert(a[10] === undefined);
})();
(function tc_22_02_01__015() {
var a = new Int32Array(8);
a[0] = 0xffffffff;
a[1] = 0xff00000001;
a[2] = 0xff80000001;
a[3] = -2.3;
a[4] = Number.NEGATIVE_INFINITY;
a[5] = NaN;
a[6] = 10e17;
a[7] = -10e17;
assert(a[0] === -1);
assert(a[1] === 1);
assert(a[2] === -2147483647);
assert(a[3] === -2);
assert(a[4] === 0);
assert(a[5] === 0);
assert(a[6] === -1486618624);
assert(a[7] === 1486618624);
})();
(function tc_22_02_01__018() {
var a = new Uint16Array(2);
a[0] = 0x123456789A;
a[1] = -2.3;
assert(a[0] === 0x789A);
assert(a[1] === 65534);
})();
(function tc_22_02_01__020() {
var name = "";
try
{
new Int16Array(Float32Array.prototype);
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
})();
(function tc_22_02_01__016() {
var a = new Int8Array(3);
a[0] = 0xff;
a[1] = 0xff01;
a[2] = -2.3;
assert(a[0] === -1);
assert(a[1] === 1);
assert(a[2] === -2);
})();
(function tc_22_02_01__010() {
var a = new Float32Array([0.1, -3.4, 65535.9]);
var b = new Int16Array(a);
var c = new Uint8Array(a);
var d = new Int32Array(a);
assert(b[0] === 0);
assert(b[1] === -3);
assert(b[2] === -1);
assert(c[0] === 0);
assert(c[1] === 253);
assert(c[2] === 255);
assert(d[0] === 0);
assert(d[1] === -3);
assert(d[2] === 65535);
})();
(function tc_22_02_01__008() {
var a = new Int8Array([1.5,1000,-9]);
a[2] = a[1] * a[0];
assert(a[2] === -24);
})();
(function tc_22_02_01__014() {
var a = new Int16Array(3);
a[0] = 0xffff;
a[1] = 0xff0001;
a[2] = -2.3;
assert(a[0] === -1);
assert(a[1] === 1);
assert(a[2] === -2);
})();
(function tc_22_02_01__007() {
var a = new Int8Array(5);
assert(a[2] === 0);
})();
(function tc_22_02_01__017() {
var a = new Uint32Array(2);
a[0] = 0x123456789A;
a[1] = -2.3;
assert(a[0] === 0x3456789A);
assert(a[1] === 4294967294);
})();
(function tc_22_02_01__001() {
var a = new Int8Array();
assert(a instanceof Int8Array);
})();
(function tc_22_02_01__003() {
var a = new Int8Array('5');
assert(a instanceof Int8Array);
})();
(function tc_22_02_01__019() {
var a = new Uint8Array(2);
a[0] = 0x123456789A;
a[1] = -2.3;
assert(a[0] === 0x9A);
assert(a[1] === 254);
})();
(function tc_22_02_01__005() {
var a = new ArrayBuffer(5);
var b = new Int8Array(a);
assert(b instanceof Int8Array);
})();
(function tc_22_02_01__012() {
var a = new Float64Array(2);
a[0] = 0.1;
a[1] = -2.3;
assert(a[0] === 0.1);
assert(a[1] === -2.3);
})();
(function tc_22_02_01__011() {
var a = new Uint8ClampedArray([1.5, 2.5, -1.5, 10000]);
assert(a[0] === 2);
assert(a[1] === 2);
assert(a[2] === 0);
assert(a[3] === 255);
})();
(function tc_22_02_01__004() {
var a = new Int8Array(5);
var b = new Int8Array(a);
assert(a instanceof Int8Array);
})();
(function tc_22_02_03__015() {
var total = new Float32Array([-1.5, 0, 1.5, 2]).reduce(function(a, b, c) {
return a + b + c;
}, 10);
assert(total === 18);
})();
(function tc_22_02_03__003() {
var a = new Int8Array(5);
assert(a.byteLength === 5);
})();
(function tc_22_02_03__020() {
var uint8 = new Uint8Array(4);
uint8.set([10, "11", 12]);
assert(uint8[0] === 10 && uint8[1] === 11 && uint8[2] === 12);
uint8.set([13, 14.3, 15], 1);
assert(uint8[0] === 10 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([16], NaN);
assert(uint8[0] === 16 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([17], "");
assert(uint8[0] === 17 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([18], "0");
assert(uint8[0] === 18 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([19], false);
assert(uint8[0] === 19 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([20], 0.2);
assert(uint8[0] === 20 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([21], 0.9);
assert(uint8[0] === 21 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([22], null);
assert(uint8[0] === 22 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([23], {});
assert(uint8[0] === 23 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([24], []);
assert(uint8[0] === 24 && uint8[1] === 13 && uint8[2] === 14 && uint8[3] === 15);
uint8.set([25], true);
assert(uint8[0] === 24 && uint8[1] === 25 && uint8[2] === 14 && uint8[3] === 15);
})();
(function tc_22_02_03__011() {
var a = new Float32Array([1.25, 2.5, 3.75]);
var b = a.map(function(num) {
return num * 2;
});
assert(a[0] === 1.25);
assert(a[1] === 2.5);
assert(a[2] === 3.75);
assert(b[0] === 2.5);
assert(b[1] === 5);
assert(b[2] === 7.5);
})();
(function tc_22_02_03__002() {
var a = new Int8Array(5);
assert(a.byteOffset === 0);
})();
(function tc_22_02_03__012() {
var a = new Float32Array([1.1, 2.2, 3.3, 4.4]);
var count = 0;
function f_every(num)
{
count++;
return num < 3;
}
var ret = a.every(f_every);
assert(ret === false);
assert(count === 3);
})();
(function tc_22_02_03__007() {
var a = new Uint8Array([10, 20, 30, 40]);
var o = {
"small":0,
"large":0
};
var func = function(v, k)
{
if (v < 25)
{
this.small = this.small + k;
}
else
{
this.large = this.large + k;
}
}
var ret = a.forEach(func, o);
assert(ret === undefined);
assert(o.small === 1);
assert(o.large === 5);
})();
(function tc_22_02_03__021() {
var float64 = new Float64Array(4);
float64.set([10.1, "11.2", 12.3]);
assert(float64[0] === 10.1 && float64[1] === 11.2 && float64[2] === 12.3);
float64.set([13.1, 14.2, 15.3], 1);
assert(float64[0] === 10.1 && float64[1] === 13.1 && float64[2] === 14.2 && float64[3] === 15.3);
try
{
float64.set([17.1, 18.2, 19.3], 2);
assert(false);
} catch (e)
{
assert(e instanceof RangeError)
}
})();
(function tc_22_02_03__009() {
var a = new Uint8Array([1, 2, 3, 4]);
var count = 0;
function f_every(num)
{
count++;
return num < 3;
}
var ret = a.every(f_every);
assert(ret === false);
assert(count === 3);
})();
(function tc_22_02_03__014() {
var a = new Float32Array([-1.1, 0.1, 2.5, 3.0]);
var o = {
"small":0,
"large":0
};
var func = function(v, k)
{
if (v < 2)
{
this.small = this.small + k;
}
else
{
this.large = this.large + k;
}
}
var ret = a.forEach(func, o);
assert(ret === undefined);
assert(o.small === 1);
assert(o.large === 5);
})();
(function tc_22_02_03__001() {
var a = new Int8Array(5);
assert(a.length === 5);
})();
(function tc_22_02_03__010() {
var a = new Uint8Array([1, 2, 3, 4]);
var count = 0;
function f_some(num)
{
count++;
return num > 3;
}
var ret = a.some(f_some);
assert(ret === true);
assert(count === 4);
})();
(function tc_22_02_03__006() {
var a = new Int8Array([1,2,3,4,5]);
var b = new Int8Array(a.buffer, 2, 3);
b[0] = 5.6;
assert(a[2] === 5);
})();
(function tc_22_02_03__018() {
var a = new Float32Array([-1.5, 0, 1.5]);
var b = a.reverse()
assert(a === b);
assert(a[0] === 1.5);
assert(a[1] === 0);
assert(a[2] === -1.5);
})();
(function tc_22_02_03__008() {
var a = new Uint8Array([1, 2, 3]);
var b = a.map(function(num) {
return num * 2;
});
assert(a[0] === 1);
assert(a[1] === 2);
assert(a[2] === 3);
assert(b[0] === 2);
assert(b[1] === 4);
assert(b[2] === 6);
})();
(function tc_22_02_03__016() {
var total = new Float32Array([-1.5, 0, 1.5, 2]).reduceRight(function(a, b) {
return a - b;
});
assert (total === 2)
})();
(function tc_22_02_03__013() {
var a = new Float32Array([1.1, 2.2, 3.3, 4.4]);
var count = 0;
function f_some(num)
{
count++;
return num > 3;
}
var ret = a.some(f_some);
assert(ret === true);
assert(count === 3);
})();
(function tc_22_02_03__005() {
var a = new Int8Array([1,2,3,4,5]);
var b = new Int8Array(a.buffer, 2, 3);
assert(a.buffer === b.buffer);
assert(b.length === 3);
assert(b.byteOffset === 2);
assert(b.byteLength === 3);
})();
(function tc_22_02_03__017() {
var a = new Float32Array([-1.5, 0, 1.5, 2]);
var b = a.filter(function(x){
return x > 0;
});
assert(a[0] === -1.5);
assert(a[1] === 0);
assert(a[2] === 1.5);
assert(a[3] === 2);
assert(b[0] === 1.5);
assert(b[1] === 2);
assert(b.length === 2);
})();
(function tc_22_02_03__019() {
var uint8 = new Uint8Array(4);
assert(uint8.set.length === 1)
try
{
uint8.set([1], -1);
assert(false);
} catch (e)
{
assert(e instanceof RangeError);
}
try
{
uint8.set([1], - (Math.pow(2, 32) + 1));
assert(false);
} catch (e)
{
assert(e instanceof RangeError);
}
try
{
uint8.set([1], -Infinity);
assert(false);
} catch (e)
{
assert(e instanceof RangeError);
}
try
{
uint8.set([1], Infinity);
assert(false);
} catch (e)
{
assert(e instanceof RangeError);
}
try
{
uint8.set([1], (Math.pow(2, 32) + 1));
assert(false);
} catch (e)
{
assert(e instanceof RangeError);
}
try
{
uint8.set([17, 18, 19], 2);
assert(false);
} catch (e)
{
assert(e instanceof RangeError)
}
})();
(function tc_22_02_03__004() {
var a = new Int8Array(5);
assert(a.buffer instanceof ArrayBuffer);
})();
(function tc_22_02_06__001() {
assert(Int8Array.prototype.BYTES_PER_ELEMENT === 1);
assert(Uint8Array.prototype.BYTES_PER_ELEMENT === 1);
assert(Uint8ClampedArray.prototype.BYTES_PER_ELEMENT === 1);
assert(Int16Array.prototype.BYTES_PER_ELEMENT === 2);
assert(Uint16Array.prototype.BYTES_PER_ELEMENT === 2);
assert(Int32Array.prototype.BYTES_PER_ELEMENT === 4);
assert(Uint32Array.prototype.BYTES_PER_ELEMENT === 4);
assert(Float32Array.prototype.BYTES_PER_ELEMENT === 4);
assert(Float64Array.prototype.BYTES_PER_ELEMENT === 8);
})();
(function tc_22_02_05__001() {
assert(Int8Array.BYTES_PER_ELEMENT === 1);
assert(Uint8Array.BYTES_PER_ELEMENT === 1);
assert(Uint8ClampedArray.BYTES_PER_ELEMENT === 1);
assert(Int16Array.BYTES_PER_ELEMENT === 2);
assert(Uint16Array.BYTES_PER_ELEMENT === 2);
assert(Int32Array.BYTES_PER_ELEMENT === 4);
assert(Uint32Array.BYTES_PER_ELEMENT === 4);
assert(Float32Array.BYTES_PER_ELEMENT === 4);
assert(Float64Array.BYTES_PER_ELEMENT === 8);
})();
+155
View File
@@ -0,0 +1,155 @@
// 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 tc_24_01_02__010() {
var a = new ArrayBuffer(NaN);
assert(a.byteLength === 0);
})();
(function tc_24_01_02__009() {
var a = new ArrayBuffer(undefined);
assert(a.byteLength === 0);
})();
(function tc_24_01_02__012() {
var name = "";
try
{
var a = new ArrayBuffer(-1.9);
}
catch (e)
{
name = e.name;
}
assert(name === "RangeError");
})();
(function tc_24_01_02__003() {
var a = new ArrayBuffer("5");
assert(typeof a === 'object');
assert(a.byteLength === 5);
})();
(function tc_24_01_02__013() {
var name = "";
try
{
var a = new ArrayBuffer(Math.pow(2, 32) - 1);
}
catch (e)
{
name = e.name;
}
assert(name === "RangeError");
})();
(function tc_24_01_02__002() {
var a = new ArrayBuffer(5);
assert(typeof a === 'object');
assert(a.byteLength === 5);
})();
(function tc_24_01_02__007() {
var a = new ArrayBuffer("string");
assert(a.byteLength === 0);
})();
(function tc_24_01_02__006() {
var a = new ArrayBuffer(5.5);
assert(a.byteLength === 5);
})();
(function tc_24_01_02__004() {
var name = "";
try
{
var a = ArrayBuffer();
}
catch (e)
{
name = e.name;
}
assert(name === "TypeError");
})();
(function tc_24_01_02__005() {
assert(ArrayBuffer.length === 1);
})();
(function tc_24_01_02__001() {
var a = new ArrayBuffer();
assert(typeof a === 'object');
assert(a.byteLength === 0);
})();
(function tc_24_01_02__008() {
var obj = {};
var a = new ArrayBuffer(obj);
assert(a.byteLength === 0);
})();
(function tc_24_01_02__011() {
var a = new ArrayBuffer(-0.3);
assert(a.byteLength === 0);
var b = new ArrayBuffer(-0.9);
assert(b.byteLength === 0);
})();
(function tc_24_01_04__002() {
var a = new ArrayBuffer(5);
assert(a.byteLength === 5);
})();
(function tc_24_01_04__006() {
var a = new ArrayBuffer(5);
var b = a.slice (3, 2);
assert(b.byteLength === 0);
})();
(function tc_24_01_04__001() {
assert(ArrayBuffer.prototype.constructor === ArrayBuffer);
})();
(function tc_24_01_04__004() {
var a = new ArrayBuffer(5);
var b = a.slice (1, 3);
assert(b.byteLength === 2);
})();
(function tc_24_01_04__003() {
var a = new ArrayBuffer(5);
a.byteLength = 10;
assert(a.byteLength === 5);
})();
(function tc_24_01_04__007() {
var a = new ArrayBuffer(5);
var b = a.slice();
assert(b.byteLength === 5);
})();
(function tc_24_01_04__005() {
var a = new ArrayBuffer(5);
var b = a.slice(1, -2);
assert(b.byteLength === 2);
})();
(function tc_24_01_03__001() {
assert(typeof ArrayBuffer.prototype === 'object');
})();
+254
View File
@@ -0,0 +1,254 @@
// 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 tc_25_04_05__004() {
var a = new Promise(function(f, r){
f("a");
});
var b = new Promise(function(f, r){
f(a);
})
b.then(function(x) {
assert (x === "a");
})
})();
(function tc_25_04_05__002() {
var obj = {name:""};
var a = new Promise(function(f, r){
obj.name = obj.name + "a";
f(obj);
});
a.then(function(x) {
x.name = x.name + "b";
return x;
}).then(null, function(x) {
x.name = x.name + "c";
return x;
}).then(function(x) {
x.name = x.name + "d";
assert (obj.name === "aebd");
});
obj.name = obj.name + "e";
assert (obj.name === "ae")
})();
(function tc_25_04_05__006() {
var p = Promise.resolve(1).then(function(x) {
assert(x === 1);
return Promise.resolve(2);
}).then(function(x) {
assert(x === 2);
return Promise.reject(3);
}).catch(function(x) {
assert(x === 3);
});
})();
(function tc_25_04_05__001() {
assert (Promise.length === 1);
})();
(function tc_25_04_05__003() {
var a = new Promise(function(f, r){
r(0);
});
a
.then(function f1(x) {
return x + 1;
}, function r1(x){
return x + 10;
})
.then(function f2(x) {
throw x + 100
})
.then(function f3(x) {
return x + 1000
}, function r3(x) {
return x + 10000
})
.then(function(x) {
assert (x === 10110);
})
})();
(function tc_25_04_05__005() {
Promise.reject("abc").catch(function(x)
{
assert (x === "abc");
return "def";
}).then(function(x) {
assert (x === "def");
});
})();
(function tc_25_04_04__005() {
var a = Promise.resolve('a');
var b = Promise.resolve('b');
var c = Promise.reject('c');
Promise.all([a, b, 1]).then(function(x)
{
assert (x[0] === 'a');
assert (x[1] === 'b');
assert (x[2] === 1);
}, function(x)
{
assert (false);
});
Promise.all([a, b, c, 1]).then(function(x)
{
assert (false);
}, function(x)
{
assert (x === 'c');
});
Promise.all([]).then(function(x)
{
assert (x.length === 0);
}, function(x)
{
assert (false);
});
Promise.all(a).then(function(x)
{
assert (false);
}, function(x)
{
assert(x.name === "TypeError");
});
})();
(function tc_25_04_04__001() {
Promise.resolve("abc").then(function(x)
{
assert (x === "abc");
});
})();
(function tc_25_04_04__003() {
Promise.reject("abc").then(function(x)
{
assert (false);
}, function(x)
{
assert (x === "abc");
});
})();
(function tc_25_04_04__002() {
var a = new Promise(function(f)
{
var o = {name: "abc"};
f(o);
})
Promise.resolve(a).then(function(x)
{
assert (x.name === "abc");
});
})();
(function tc_25_04_04__004() {
var a = Promise.resolve('a');
var b = Promise.reject('b');
Promise.race([a, b]).then(function(x)
{
assert (x === 'a');
}, function(x)
{
assert (false);
});
Promise.race([b, a]).then(function(x)
{
assert (false);
}, function(x)
{
assert (x === 'b');
});
Promise.race([ ,b, a]).then(function(x)
{
assert (x === undefined);
}, function(x)
{
assert (false);
});
Promise.race(a).then(function(x)
{
assert (false);
}, function(x)
{
assert(x.name === "TypeError");
});
})();
(function tc_25_04_03__002() {
var name1 = "";
var name2 = "";
var name3 = "";
function foo() {};
try
{
new Promise();
}
catch (e)
{
name1 = e.name;
}
try
{
Promise(foo);
}
catch (e)
{
name2 = e.name;
}
try
{
new Promise("string");
}
catch (e)
{
name3 = e.name;
}
assert (name1 === "TypeError");
assert (name2 === "TypeError");
assert (name3 === "TypeError");
})();
(function tc_25_04_03__001() {
function foo() {};
var a = new Promise(foo);
assert (a instanceof Promise);
})();
+119
View File
@@ -0,0 +1,119 @@
// 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 tc_15_07_04_02__006() {
assert(Number.prototype.toString(2) === "0");
})();
(function tc_15_03_04_02__001() {
assert(Function.prototype.toString.hasOwnProperty('length'));
assert(!(delete Function.prototype.toString.length));
assert(Function.prototype.toString.hasOwnProperty('length'));
})();
(function tc_15_03_04_02__004() {
assert(Function.prototype.toString.hasOwnProperty('length'));
assert(!(delete Function.prototype.toString.length));
assert(Function.prototype.toString.hasOwnProperty('length'));
})();
(function tc_15_07_04_05__002() {
assert(Number.prototype.toFixed(0) === "0");
})();
(function tc_15_07_04_05__007() {
assert(Number.prototype.toFixed(Number.NaN) === "0");
})();
(function tc_15_07_04_02__008() {
assert(Number.prototype.toString() === "0");
})();
(function tc_15_07_04_05__004() {
assert (Number.prototype.toFixed(1.1) === "0.0");
})();
(function tc_15_07_03_01__010() {
assert(Number.prototype == +0);
})();
(function tc_13_02__002() {
var foo = function (c, y) {
};
var check = foo.hasOwnProperty("length") && foo.length === 2;
foo.length = 12;
if (foo.length === 12)
check = false;
for (p in foo)
{
if (p === "length")
check = false;
}
delete foo.length;
if (!foo.hasOwnProperty("length"))
check = false;
assert(check === true);
})();
(function tc_15_07_03_01__008() {
delete Number.prototype.toString
assert(Number.prototype.toString() === "[object Number]");
})();
(function tc_15_07_04__002() {
assert(typeof Number.prototype === "object" && Number.prototype == +0.0);
})();
(function tc_15_07_03_01__011() {
assert(1/Number.prototype === Number.POSITIVE_INFINITY);
})();
(function tc_15_07_03_01__004() {
var b = Number.prototype
Number.prototype = 4
assert(Number.prototype != 4 && Number.prototype === b)
})();
(function tc_15_07_03_01__009() {
Number.prototype.toString = Object.prototype.toString;
assert(Number.prototype.toString() === "[object Number]");
})();
(function tc_15_07_04_05__001() {
assert(Number.prototype.toFixed() === "0");
})();
(function tc_15_07_04__001() {
delete Number.prototype.toString
assert(Number.prototype.toString() === "[object Number]");
})();
(function tc_15_07_04_05__005() {
assert(Number.prototype.toFixed(0.9) === "0");
})();
(function tc_15_07_04_05__006() {
assert (Number.prototype.toFixed("1") === "0.0");
})();
(function tc_15_07_04_05__008() {
assert(Number.prototype.toFixed("some string") === "0");
})();
(function tc_15_07_04_05__003() {
assert(Number.prototype.toFixed(1) === "0.0");
})();
+80
View File
@@ -0,0 +1,80 @@
// 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 tc_06__004() {
var arg = 3;
function a() {
return 5 + arg;
}
arg = 4;
var b = function () {
return 6 + arg;
};
arg = 5;
c = function e() {
return 7 + arg;
};
assert(a() + b() + c() === 33);
})();
(function tc_06__005() {
var a = "\u0410\u0411";
var b = "\u0509\u0413";
assert(a < b);
})();
(function tc_06__003() {
var obj = new Object();
function c(arg)
{
var obj = new Object();
obj.par = arg;
obj.print = function () {
return arg;
};
return obj;
}
var a = c(5);
var b = c(6);
assert(a.print() + b.par === 11);
})();
(function tc_06__001() {
var str = "a\u000Ab";
assert(str[1] === '\n');
})();
(function tc_06__002() {
function c(arg)
{
var obj = new Object();
obj.print = function () {
f = arg;
};
return obj;
}
a = c(5);
b = c(6);
a.print.toString = 7;
assert(typeof a.print.toString !== typeof b.print.toString);
})();
+149
View File
@@ -0,0 +1,149 @@
// 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 tc_07_09__002() {
function test()
{
var a = 1, b = 2;
return
a + b
}
var v = test();
assert(v !== 3);
assert(typeof v === "undefined")
})();
(function tc_07_09__008() {
function test()
{
var a = 10, b = 5;
var c = a + b
return c;
}
assert(test() == 15);
})();
(function tc_07_09__004() {
var obj = new Object();
function c(arg)
{
var obj = new Object();
obj.par = arg;
obj.print = function () {
return arg;
}
return obj;
}
var a, b = 1, d = 2, e = 3;
a = b + c
(d + e).print()
assert(a === 6);
})();
(function tc_07_09__005() {
var b = 4, c = 5;
a = b
--c
assert(a === 4 && c === 4);
})();
(function tc_07_09__007() {
var mainloop = 1, cnt = 0;
for (var i = 0; i < 10; ++i)
{
for (var j = 0; j < 10; ++j)
{
if (j == 6)
{
break
mainloop
}
++cnt;
}
}
assert(cnt == 60);
})();
(function tc_07_09__009() {
{
var a, b = 3, c = 30;
a = b + c}
assert (a == 33);
})();
(function tc_07_09__010() {
assert (glob === undefined);
var glob = 34
assert (glob === 34);
})();
(function tc_07_09__003() {
var b = 4, c = 5;
a = b
++c
assert(a === 4 && c === 6);
})();
(function tc_07_09__001() {
{ 1
2 } 3
})();
(function tc_07_09__006() {
var mainloop = 1, cnt = 0;
for (var i = 0; i < 10; ++i)
{
for (var j = 0; j < 10; ++j)
{
if (j == 6)
{
continue
mainloop
}
++cnt;
}
}
assert(cnt == 90);
})();
(function tc_07_06_01__001() {
var package = 1;
})();
(function tc_07_08_05__001() {
/a[a-z]/.exec("abcdefghi");
})();
+253
View File
@@ -0,0 +1,253 @@
// 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 tc_08_02__001() {
var x = null;
})();
(function tc_08_02__002() {
assert(typeof null == 'object');
})();
(function tc_08_05__002() {
assert(typeof -Infinity == 'number');
})();
(function tc_08_05__001() {
a = 0x3e7;
assert(a == 999);
})();
(function tc_08_05__003() {
assert(0 > -Infinity);
})();
(function tc_08_04__009() {
var str = "";
var strObj = new String("");
var strObj_ = new String();
assert(str.constructor === strObj.constructor);
})();
(function tc_08_04__007() {
var str = 'ABC';
var strObj = new String('ABC');
assert(str == strObj);
})();
(function tc_08_04__005() {
var s = 'hello';
assert(s[5] == undefined);
})();
(function tc_08_04__001() {
a = '';
assert(typeof a == "string");
})();
(function tc_08_04__017() {
var __str__ = "\u0041\u0042\u0043" + 'ABC'
assert(__str__ === 'ABCABC');
})();
(function tc_08_04__004() {
var s = 'hello';
assert(s[0] == 'h');
})();
(function tc_08_04__016() {
var str = "";
var strObj = new String;
assert(typeof str != typeof strObj);
})();
(function tc_08_04__015() {
var str = "";
var strObj = new String;
assert(str !== strObj);
})();
(function tc_08_04__014() {
var str = "";
var strObj = new String;
assert(str == strObj);
})();
(function tc_08_04__003() {
var str = "test";
assert(str.constructor === String);
})();
(function tc_08_04__002() {
assert(("x\0a" < "x\0b") && ("x\0b" < "x\0c"));
})();
(function tc_08_04__010() {
var str = "";
var strObj = new String("");
var strObj_ = new String();
assert(str.constructor === strObj_.constructor);
})();
(function tc_08_04__008() {
var str = 'ABC';
var strObj = new String('ABC');
assert(str !== strObj);
})();
(function tc_08_04__011() {
var str = "";
var strObj = new String("");
var strObj_ = new String();
assert(str == strObj);
})();
(function tc_08_04__012() {
var str = "";
var strObj = new String("");
var strObj_ = new String();
assert(str !== strObj);
})();
(function tc_08_04__013() {
var str = "";
var strObj = new String;
assert(str.constructor === strObj.constructor);
})();
(function tc_08_04__006() {
var str = 'ABC';
var strObj = new String('ABC');
assert(str.constructor === strObj.constructor);
})();
(function tc_08_01__011() {
assert (test ());
function test (arg)
{
if (typeof (arg) === "undefined")
return true;
else
return false;
}
})();
(function tc_08_01__009() {
var x;
assert(test1() === void 0);
function test1(x) {
return x;
}
})();
(function tc_08_01__008() {
var x;
assert(x === void 0);
})();
(function tc_08_01__010() {
assert (test ());
function test (arg)
{
if (typeof (arg) === "undefined")
return true;
else
return false;
}
})();
(function tc_08_01__001() {
var a;
assert(typeof (a) === "undefined");
})();
(function tc_08_01__006() {
assert(typeof (void 0) === "undefined");
})();
(function tc_08_01__002() {
var o = {};
assert(typeof (o.empty) === "undefined");
})();
(function tc_08_01__003() {
var a;
var b = null;
assert(a == b);
})();
(function tc_08_01__005() {
a = foo();
assert(typeof (a) === "undefined");
function foo() {
}
})();
(function tc_08_01__007() {
assert(undefined === void 0);
})();
(function tc_08_01__004() {
var a;
assert(!a);
})();
(function tc_08_03__003() {
assert(!(false == true));
})();
(function tc_08_03__001() {
var a = true;
assert(a);
})();
(function tc_08_03__002() {
var a = false;
assert(!a);
})();
(function tc_08_03__004() {
assert(!(false === true));
})();
(function tc_08_12_02__001() {
var prot = {
b: 3
};
function Custom() {
}
Custom.prototype = prot;
var obj = new Custom();
assert(obj.b === 3);
})();
+25
View File
@@ -0,0 +1,25 @@
// 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 tc_10_03_01__001() {
a = 10;
function foo() {
var b = 20;
assert(a + b === 30);
}
foo();
})();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+201
View File
@@ -0,0 +1,201 @@
// 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 tc_13__012() {
function foo(a, b, c, d) {
var deleted = true;
for (i = 0; i < arguments.length; i++)
{
delete arguments[i];
deleted = deleted && (typeof (arguments[i]) === "undefined");
}
return deleted;
}
assert(foo("A", "F", 1, true) === true);
})();
(function tc_13__005() {
var foo = 1;
assert (foo === 1);
function foo()
{
return 1;
}
})();
(function tc_13__013() {
function foo(arguments) {
return arguments;
}
assert(foo(1) === 1);
})();
(function tc_13__010() {
function foo() {
return 1;
}
var object = new Object;
object.fun = foo;
assert(object.fun() === 1);
})();
(function tc_13__001() {
var b = 1;
for (var i = 1; i < 10; ++i)
{
b *= i;
}
var c = b;
assert(c == 362880);
})();
(function tc_13__007() {
function foo(arg) {
return ++arg;
}
assert(foo(1) === 2);
})();
(function tc_13__008() {
function foo(params) {
return arguments.length;
}
assert(foo(1, 'e', true, 5) === 4);
})();
(function tc_13__003() {
assert(function (param1, param2) {
return 1;
}(true, "blah") === 1);
})();
(function tc_13__011() {
function foo(param1) {
return delete arguments;
}
assert(!foo("param"));
})();
(function tc_13__002() {
function foo() {
return 1;
}
assert(foo() === 1);
})();
(function tc_13__009() {
var check = typeof (foo) === "function";
var foo = 1;
check = check && (foo === 1);
function foo() {
return 1;
}
assert(check);
})();
(function tc_13__006() {
function foo() {
}
assert(foo() === undefined);
})();
(function tc_13__004() {
function foo() {
}
assert(typeof foo === "function");
})();
(function tc_13_01__001() {
function arguments (param) {
return true;
}
assert (arguments ());
})();
(function tc_13_02__001() {
var foo = function () {
this.caller = 123;
};
var f = new foo();
assert(f.caller === 123);
})();
(function tc_13_02__007() {
var obj = new function foo()
{
this.prop = 1;
};
assert(obj.prop === 1);
})();
(function tc_13_02__003() {
function foo(arg) {
arg.prop = 3;
}
var obj = new Object();
foo(obj);
assert(obj.prop === 3);
})();
(function tc_13_02__006() {
function foo() {
return;
}
assert(foo() === undefined);
})();
(function tc_13_02__004() {
function foo(arg) {
arg += 3;
}
var num = 1;
foo(num);
assert(num === 1);
})();
(function tc_13_02__005() {
function foo() {
return null;
}
assert(foo() === null);
})();
(function tc_13_02__008() {
function func() {
}
assert(Function.prototype.isPrototypeOf(func));
})();
File diff suppressed because it is too large Load Diff