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:
@@ -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'));
|
||||
})();
|
||||
@@ -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, ...)");
|
||||
})();
|
||||
})();
|
||||
@@ -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);
|
||||
})();
|
||||
@@ -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');
|
||||
})();
|
||||
@@ -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);
|
||||
})();
|
||||
Reference in New Issue
Block a user