Re-target for ES.Next (#3901)
A list of changes: - 'es2015-subset' profile is deprecated, and an 'es.next' profile is added. - The default profile is changed to 'es.next' - Renamed the JERRY_ES2015 guard to JERRY_ESNEXT - Renamed JERRY_ES2015_BUILTIN_* guards to JERRY_BUILTIN_* - Moved es2015 specific tests to a new 'es.next' subdirectory - Updated docs, targets, and test runners to reflect these changes Resolves #3737. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
assert(Function.prototype.toString.hasOwnProperty('length'));
|
||||
assert(delete Function.prototype.toString.length);
|
||||
assert(!Function.prototype.toString.hasOwnProperty('length'));
|
||||
@@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
assert(Function.prototype.toString.hasOwnProperty('length'));
|
||||
assert(delete Function.prototype.toString.length);
|
||||
assert(!Function.prototype.toString.hasOwnProperty('length'));
|
||||
@@ -0,0 +1,41 @@
|
||||
/* 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 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,43 @@
|
||||
/* 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 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)");
|
||||
})()
|
||||
@@ -0,0 +1,31 @@
|
||||
/* 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 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, ...)");
|
||||
})()
|
||||
@@ -0,0 +1,56 @@
|
||||
/* 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 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, ...)");
|
||||
})()
|
||||
@@ -0,0 +1,42 @@
|
||||
/* 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 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)");
|
||||
})()
|
||||
@@ -0,0 +1,31 @@
|
||||
/* 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 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)");
|
||||
})()
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array();
|
||||
assert(a instanceof Int8Array);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a instanceof Int8Array);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array('5');
|
||||
assert(a instanceof Int8Array);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
var b = new Int8Array(a);
|
||||
assert(a instanceof Int8Array);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
var b = new Int8Array(a);
|
||||
assert(b instanceof Int8Array);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array([1,2,3]);
|
||||
assert(a instanceof Int8Array);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a[2] === 0);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new Int8Array([1.5,1000,-9]);
|
||||
a[2] = a[1] * a[0]; //a[0] = 1; a[1] = -24 (because 1000 is 0x3e8, convert to int8 is 0xe8)
|
||||
assert(a[2] === -24);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
Int8Array.prototype[10] = 10;
|
||||
var a = new Int8Array(5);
|
||||
assert(a[10] === undefined); //Indexed properties will never look at prototype
|
||||
@@ -0,0 +1,29 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,21 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 a = new Float64Array(2);
|
||||
|
||||
a[0] = 0.1;
|
||||
a[1] = -2.3;
|
||||
|
||||
assert(a[0] === 0.1);
|
||||
assert(a[1] === -2.3);
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 a = new Float32Array(2);
|
||||
|
||||
a[0] = 0.1;
|
||||
a[1] = -2.3;
|
||||
|
||||
assert(a[0] === 0.10000000149011612);
|
||||
assert(a[1] === -2.299999952316284);
|
||||
@@ -0,0 +1,24 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,34 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,24 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 a = new Uint32Array(2);
|
||||
|
||||
a[0] = 0x123456789A;
|
||||
a[1] = -2.3;
|
||||
|
||||
assert(a[0] === 0x3456789A);
|
||||
assert(a[1] === 4294967294); // 0x100000000 - 2
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 a = new Uint16Array(2);
|
||||
|
||||
a[0] = 0x123456789A;
|
||||
a[1] = -2.3;
|
||||
|
||||
assert(a[0] === 0x789A);
|
||||
assert(a[1] === 65534); // 0x10000 - 2
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 a = new Uint8Array(2);
|
||||
|
||||
a[0] = 0x123456789A;
|
||||
a[1] = -2.3;
|
||||
|
||||
assert(a[0] === 0x9A);
|
||||
assert(a[1] === 254); // 0x100 - 2
|
||||
@@ -0,0 +1,27 @@
|
||||
/* 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 name = "";
|
||||
|
||||
try
|
||||
{
|
||||
new Int16Array(Float32Array.prototype);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "TypeError");
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = Object.getPrototypeOf(Int8Array);
|
||||
assert(a.name === "TypedArray");
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = Object.getPrototypeOf(Int8Array);
|
||||
assert(a.length === 3);
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
var a = Object.getPrototypeOf(Int8Array);
|
||||
var b = new Int8Array();
|
||||
var c = Object.getPrototypeOf(Object.getPrototypeOf(b));
|
||||
assert(c === a.prototype);
|
||||
@@ -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 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);
|
||||
@@ -0,0 +1,66 @@
|
||||
/* 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 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");
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a.length === 5);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a.byteOffset === 0);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new Int8Array(5);
|
||||
assert(a.buffer instanceof ArrayBuffer);
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,20 @@
|
||||
/* 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 a = new Int8Array([1,2,3,4,5]);
|
||||
var b = new Int8Array(a.buffer, 2, 3);
|
||||
|
||||
b[0] = 5.6;
|
||||
assert(a[2] === 5);
|
||||
@@ -0,0 +1,37 @@
|
||||
/* 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 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); // 0+1
|
||||
assert(o.large === 5); // 2+3
|
||||
@@ -0,0 +1,27 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,27 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,37 @@
|
||||
/* 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 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); // 0+1
|
||||
assert(o.large === 5); // 2+3
|
||||
@@ -0,0 +1,20 @@
|
||||
/* 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 total = new Float32Array([-1.5, 0, 1.5, 2]).reduce(function(a, b, c) {
|
||||
return a + b + c;
|
||||
}, 10);
|
||||
|
||||
assert(total === 18); // 10 + (-1.5) + 0 + 0 + 1 + 1.5 + 2 + 2 + 3
|
||||
@@ -0,0 +1,20 @@
|
||||
/* 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 total = new Float32Array([-1.5, 0, 1.5, 2]).reduceRight(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
assert (total === 2) // 2 - 1.5 - 0 - (-1.5)
|
||||
@@ -0,0 +1,27 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,23 @@
|
||||
/* 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 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);
|
||||
@@ -0,0 +1,74 @@
|
||||
/* 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 uint8 = new Uint8Array(4);
|
||||
|
||||
// 22.2.3.22
|
||||
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
|
||||
{
|
||||
// 22.2.3.22.1 step 20
|
||||
uint8.set([17, 18, 19], 2);
|
||||
assert(false);
|
||||
} catch (e)
|
||||
{
|
||||
assert(e instanceof RangeError)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* 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 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);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* 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 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
|
||||
{
|
||||
// 22.2.3.22.1 step 20
|
||||
float64.set([17.1, 18.2, 19.3], 2);
|
||||
assert(false);
|
||||
} catch (e)
|
||||
{
|
||||
assert(e instanceof RangeError)
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
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,24 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
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);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer();
|
||||
assert(typeof a === 'object');
|
||||
assert(a.byteLength === 0);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
assert(typeof a === 'object');
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer("5");
|
||||
assert(typeof a === 'object');
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,27 @@
|
||||
/* 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 name = "";
|
||||
|
||||
try
|
||||
{
|
||||
var a = ArrayBuffer();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "TypeError");
|
||||
@@ -0,0 +1,16 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
assert(ArrayBuffer.length === 1);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new ArrayBuffer(5.5);
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new ArrayBuffer("string");
|
||||
assert(a.byteLength === 0);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 obj = {};
|
||||
var a = new ArrayBuffer(obj);
|
||||
assert(a.byteLength === 0);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new ArrayBuffer(undefined);
|
||||
assert(a.byteLength === 0);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new ArrayBuffer(NaN);
|
||||
assert(a.byteLength === 0);
|
||||
@@ -0,0 +1,20 @@
|
||||
/* 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 a = new ArrayBuffer(-0.3);
|
||||
assert(a.byteLength === 0);
|
||||
|
||||
var b = new ArrayBuffer(-0.9);
|
||||
assert(b.byteLength === 0);
|
||||
@@ -0,0 +1,26 @@
|
||||
/* 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 name = "";
|
||||
try
|
||||
{
|
||||
var a = new ArrayBuffer(-1.9);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "RangeError");
|
||||
@@ -0,0 +1,26 @@
|
||||
/* 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 name = "";
|
||||
try
|
||||
{
|
||||
var a = new ArrayBuffer(Math.pow(2, 32) - 1);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "RangeError");
|
||||
@@ -0,0 +1,16 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
assert(typeof ArrayBuffer.prototype === 'object');
|
||||
@@ -0,0 +1,16 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
assert(ArrayBuffer.prototype.constructor === ArrayBuffer);
|
||||
@@ -0,0 +1,17 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
a.byteLength = 10;
|
||||
assert(a.byteLength === 5);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
var b = a.slice (1, 3);
|
||||
assert(b.byteLength === 2);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
var b = a.slice(1, -2);
|
||||
assert(b.byteLength === 2);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
var b = a.slice (3, 2);
|
||||
assert(b.byteLength === 0);
|
||||
@@ -0,0 +1,18 @@
|
||||
/* 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 a = new ArrayBuffer(5);
|
||||
var b = a.slice();
|
||||
assert(b.byteLength === 5);
|
||||
@@ -0,0 +1,20 @@
|
||||
/* 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 foo() {};
|
||||
|
||||
var a = new Promise(foo);
|
||||
|
||||
assert (a instanceof Promise);
|
||||
@@ -0,0 +1,50 @@
|
||||
/* 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 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");
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Promise.resolve("abc").then(function(x)
|
||||
{
|
||||
assert (x === "abc");
|
||||
});
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
var a = new Promise(function(f)
|
||||
{
|
||||
var o = {name: "abc"};
|
||||
f(o);
|
||||
})
|
||||
|
||||
Promise.resolve(a).then(function(x)
|
||||
{
|
||||
assert (x.name === "abc");
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
Promise.reject("abc").then(function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
}, function(x)
|
||||
{
|
||||
assert (x === "abc");
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/* 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 a = Promise.resolve('a');
|
||||
var b = Promise.reject('b');
|
||||
|
||||
Promise.race([a, b]).then(function(x)
|
||||
{
|
||||
assert (x === 'a');
|
||||
}, function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
});
|
||||
|
||||
Promise.race([b, a]).then(function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
}, function(x)
|
||||
{
|
||||
assert (x === 'b');
|
||||
});
|
||||
|
||||
Promise.race([ ,b, a]).then(function(x)
|
||||
{
|
||||
assert (x === undefined);
|
||||
}, function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
});
|
||||
|
||||
Promise.race(a).then(function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
}, function(x)
|
||||
{
|
||||
assert(x.name === "TypeError");
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
/* 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 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); // should not run here.
|
||||
});
|
||||
|
||||
Promise.all([a, b, c, 1]).then(function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
}, function(x)
|
||||
{
|
||||
assert (x === 'c');
|
||||
});
|
||||
|
||||
Promise.all([]).then(function(x)
|
||||
{
|
||||
assert (x.length === 0);
|
||||
}, function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
});
|
||||
|
||||
Promise.all(a).then(function(x)
|
||||
{
|
||||
assert (false); // should not run here.
|
||||
}, function(x)
|
||||
{
|
||||
assert(x.name === "TypeError");
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
assert (Promise.length === 1);
|
||||
@@ -0,0 +1,36 @@
|
||||
/* 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 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"; // unreachable
|
||||
return x;
|
||||
}).then(function(x) {
|
||||
x.name = x.name + "d";
|
||||
assert (obj.name === "aebd");
|
||||
});
|
||||
|
||||
obj.name = obj.name + "e";
|
||||
|
||||
assert (obj.name === "ae")
|
||||
@@ -0,0 +1,36 @@
|
||||
/* 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 a = new Promise(function(f, r){
|
||||
r(0);
|
||||
});
|
||||
|
||||
a
|
||||
.then(function f1(x) {
|
||||
return x + 1; // unreachable
|
||||
}, function r1(x){
|
||||
return x + 10;
|
||||
})
|
||||
.then(function f2(x) {
|
||||
throw x + 100
|
||||
})
|
||||
.then(function f3(x) {
|
||||
return x + 1000 //unreachable
|
||||
}, function r3(x) {
|
||||
return x + 10000
|
||||
})
|
||||
.then(function(x) {
|
||||
assert (x === 10110);
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
/* 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 a = new Promise(function(f, r){
|
||||
f("a");
|
||||
});
|
||||
|
||||
var b = new Promise(function(f, r){
|
||||
f(a);
|
||||
})
|
||||
|
||||
b.then(function(x) {
|
||||
assert (x === "a");
|
||||
})
|
||||
@@ -0,0 +1,22 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
Promise.reject("abc").catch(function(x)
|
||||
{
|
||||
assert (x === "abc");
|
||||
return "def";
|
||||
}).then(function(x) {
|
||||
assert (x === "def");
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
// Test the thenable job.
|
||||
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user