Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,107 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 catched = false;
function f1()
{
var arguments = 1;
}
try
{
f1();
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);
catched = false;
function f2()
{
var a = arguments;
}
try
{
f2();
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);
catched = false;
try
{
eval('abc');
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);
catched = false;
try
{
Function('abc');
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);
catched = false;
try
{
new Function('abc');
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);
catched = false;
try
{
var a = Date.now();
} catch (e)
{
assert (e === CompactProfileError);
catched = true;
}
assert(catched);

View file

@ -0,0 +1,36 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 fail() {
assert (0);
return true;
}
if (false && fail()) {
assert (0);
}
if (true && false && fail()) {
assert (0);
}
if (true || fail()) {
} else {
assert (0);
}
if (false || true || fail()) {
} else {
assert (0);
}

View file

@ -0,0 +1,131 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 f_arg (arguments)
{
return arguments;
}
assert (f_arg (1) === 1);
function f (a, b, c)
{
return arguments;
}
args = f();
assert (args[0] === undefined);
args = f (1, 2, 3, 4, 5);
assert (args[0] === 1);
assert (args[1] === 2);
assert (args[2] === 3);
assert (args[3] === 4);
assert (args[4] === 5);
assert (args[5] === undefined);
assert (args.callee === f);
assert (typeof args.caller === 'undefined');
function g (a, b, c)
{
assert (arguments[0] === 1);
assert (arguments[1] === undefined);
assert (arguments[2] === undefined);
a = 'a';
b = 'b';
c = 'c';
assert (arguments[0] === 'a');
assert (arguments[1] === 'b');
assert (arguments[2] === 'c');
arguments [0] = 1;
arguments [1] = 2;
arguments [2] = 3;
assert (a === 1);
assert (b === 2);
assert (c === 3);
delete arguments [0];
arguments[0] = 'new value';
assert (a === 1);
a = 'a';
b = 'b';
c = 'c';
assert (arguments[0] === 'new value');
assert (arguments[1] === 'b');
assert (arguments[2] === 'c');
}
g (1);
fn_expr = function (a, b, c)
{
'use strict';
assert (arguments[0] === 1);
assert (arguments[1] === undefined);
assert (arguments[2] === undefined);
a = 'a';
b = 'b';
c = 'c';
assert (arguments[0] === 1);
assert (arguments[1] === undefined);
assert (arguments[2] === undefined);
arguments [0] = 1;
arguments [1] = 'p';
arguments [2] = 'q';
assert (a === 'a');
assert (b === 'b');
assert (c === 'c');
delete arguments [0];
arguments[0] = 'new value';
assert (a === 'a');
a = 'a';
b = 'b';
c = 'c';
assert (arguments[0] === 'new value');
assert (arguments[1] === 'p');
assert (arguments[2] === 'q');
function check_type_error_for_property (obj, prop) {
try {
var v = obj[prop];
assert (false);
}
catch (e) {
assert (e instanceof TypeError);
}
}
check_type_error_for_property (arguments, 'caller');
check_type_error_for_property (arguments, 'callee');
}
fn_expr (1);
(function () {
var a = [arguments];
})();

View file

@ -0,0 +1,53 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 = 21;
var b = 10;
var c;
c = a + b;
assert(c == 31);
c = a - b;
assert(c == 11);
c = a * b;
assert(c == 210);
c = a / b;
assert(c >= 2.1 - 0.000001 && c <= 2.1 + 0.000001);
c = a % b;
assert(c == 1);
c = a++;
assert(c == 21);
c = a--;
assert(c == 22);
var o = { p : 1 };
assert (++o.p === 2);
assert (o.p === 2);
assert (--o.p === 1);
assert (o.p === 1);
try {
eval ('++ ++ a');
assert (false);
}
catch (e) {
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,28 @@
// Copyright 2014-2016 Samsung Electronics Co., Ltd.
//
// 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 big = 2147483646;
big++;
assert(big == 2147483647);
big += 1;
assert(big == 2147483648); // overflow on 32bit numbers
big++;
assert(big == 2147483649); // overflow on 32bit numbers
assert ((1152921504606846976).toString() === "1152921504606847000")
assert (1.797693134862315808e+308 === Infinity);

View file

@ -0,0 +1,41 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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((1 + 2) == 3);
assert((2 + 1) == 3);
assert((2 + 1) != 4);
assert((7 + 7) == 14);
assert((7 - 7) == 0);
assert((7 * 7) == 49);
assert((7 / 7) == 1);
assert((7 + 7) == 14);
assert((7 % 7) == 0);
var number = 81;
assert((number + 9) == 90);
assert((number - 9) == 72);
assert((number * 10) == 810);
assert((number / 9) == 9);
assert((number % 79) == 2);
var num1 = 1234567, num2 = 1234000;
assert((num1 % num2) == 567);
assert (1 / (-1 % -1) < 0);
assert (1 / (-1 % 1) < 0);
assert (1 / (1 % -1) > 0);
assert (1 / (1 % 1) > 0);
assert (eval ("x\n\n=\n\n6\n\n/\n\n3") === 2)

View file

@ -0,0 +1,77 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4]
var new_arr = array.concat();
assert(new_arr.length === array.length)
for (i = 0; i < array.length; i++) {
assert(array[i] === new_arr[i]);
}
var obj = { concat : Array.prototype.concat };
var arr1 = ["Apple", 6, "Peach"];
var arr2 = [obj, "Cherry", "Grape"];
var new_array = obj.concat(arr1);
assert(new_array.length === 4);
assert(new_array[0] === obj);
assert(new_array[1] === "Apple");
assert(new_array[2] === 6);
assert(new_array[3] === "Peach");
var new_array = arr1.concat(arr2, obj, 1);
assert(new_array.length === 8);
assert(new_array[0] === "Apple");
assert(new_array[1] === 6);
assert(new_array[2] === "Peach");
assert(new_array[3] === obj);
assert(new_array[4] === "Cherry");
assert(new_array[5] === "Grape");
assert(new_array[6] === obj);
assert(new_array[7] === 1);
var arr1 = [1,2];
var arr2 = [4,5,6,7,8];
var arr3 = [,,9,10];
var arr4 = [];
var expected = [1,2,4,5,6,7,8,,,9,10];
var result = arr1.concat(arr2, arr3, arr4);
assert(result.length === expected.length)
for (i = 0; i < result.length; i++) {
assert(result[i] === expected[i]);
}
var arr1 = [];
arr1.length = 2;
var arr2 = [];
arr2.length = 3;
assert(arr1.concat(arr2).length === arr1.length + arr2.length);
// Checking behavior when unable to get element
var arr = []
Object.defineProperty(arr, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
arr.length = 1;
try {
arr.concat();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,62 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4];
function f(arg1, arg2, arg3) {
assert(arg1 === array[arg2]);
assert(arg3 === array);
return true;
}
assert(array.every(f) === true);
function g(arg1, arg2, arg3) {
if (arg1 === 1) {
return true;
} else {
return false;
}
}
var arr1 = [1, 1, 1, 1, 1, 2];
assert(arr1.every(g) === false);
var arr2 = [1, 1, 1, 1, 1, 1];
assert(arr2.every(g) === true);
// Checking behavior when unable to get length
var obj = { every : Array.prototype.every };
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.every(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { every : Array.prototype.every, length : 1};
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.every(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,79 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4]
function f(arg1, arg2, arg3) {
assert(arg1 === array[arg2]);
assert(arg3 === array);
return true;
}
var filtered = array.filter(f);
assert(filtered.length === array.length);
for (i = 0; i < filtered.length; i++) {
assert(filtered[i] === array[i]);
}
var array = [1, 2, 3, 4, 5, 6, 7, 8];
function g (arg1, arg2, arg3) {
if (arg2 % 2 === 0) {
return true;
} else {
return false;
}
}
filtered = array.filter(g)
assert(filtered.length === 4);
assert(filtered[0] === 1);
assert(filtered[1] === 3);
assert(filtered[2] === 5);
assert(filtered[3] === 7);
var arr = [1,2];
Array.prototype[0] = 3;
var newArr = arr.filter(function() { return true; });
delete Array.prototype[0];
assert(newArr.hasOwnProperty("0"));
assert(newArr[0] === 1);
// Checking behavior when unable to get length
var obj = {};
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.filter = Array.prototype.filter;
try {
obj.filter(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = {}
obj.length = 1;
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.filter = Array.prototype.filter
try {
obj.filter(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,50 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4]
function f(arg1, arg2, arg3) {
assert(arg1 === array[arg2]);
assert(arg3 === array);
}
array.forEach(f);
// Checking behavior when unable to get length
var obj = {};
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.forEach = Array.prototype.forEach;
try {
obj.forEach(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = {}
obj.length = 1;
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.forEach = Array.prototype.forEach
try {
obj.forEach(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,89 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", 19, "bar", obj, "foo", 29, "baz"];
var index = array.indexOf("foo");
assert(index === 0);
assert(array[index] === "foo");
assert(array.indexOf("foo", 1) === 4);
assert(array.indexOf("foo", 5) === -1);
var index = array.indexOf("baz");
assert(index === 6);
assert(array[index] === "baz");
assert(array.indexOf("baz", 7) === -1);
var index = array.indexOf(obj);
assert(index === 3);
assert(array[index] === obj);
assert(array.indexOf("foo", NaN) === 0);
assert(array.indexOf("foo", Infinity) === -1);
assert(array.indexOf("foo", -Infinity) === 0);
assert([true].indexOf(true, -0) === 0);
// Checking behavior when length is zero
var obj = { indexOf : Array.prototype.indexOf, length : 0 };
assert(obj.indexOf("foo") === -1);
// Checking behavior when start index >= length
var arr = [11, 22, 33, 44];
assert(arr.indexOf(44, 4) === -1);
var fromIndex = {
toString: function () {
return {};
},
valueOf: function () {
return {};
}
};
try {
[0, 1].indexOf(1, fromIndex);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// Checking behavior when unable to get length
var obj = { indexOf : Array.prototype.indexOf}
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.indexOf("bar");
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { indexOf : Array.prototype.indexOf, length : 1}
Object.defineProperty(obj, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.indexOf("bar");
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,77 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 ([].join() === "");
assert ([1].join() === "1");
assert ([1, 2].join() === "1,2");
assert ([].join('--') === "");
assert ([1].join("--") === "1");
assert ([1, 2].join('--') === "1--2");
assert ([1,2,3].join({toString: function() { return "--"; }}) === "1--2--3");
// Join should use 'length' to as the number of elements int the array.
var lst = [1,2,3,4];
lst.length = 3;
assert (lst.join() === [1,2,3].join());
// Checking behavior when unable to get length.
var obj = {};
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.join = Array.prototype.join;
try {
obj.join();
// Should not be reached.
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Check join argument fail.
try {
[1,2,3].join({toString: function() { throw new ReferenceError ("foo"); }});
// Should not be reached.
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Check single join element fail.
try {
[1, 2, {toString: function() { throw new ReferenceError ("foo"); }}, 4].join();
// Should not be reached.
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Check join on different object.
var obj_2 = {};
obj_2.length = 3;
obj_2[0] = 1;
obj_2[1] = 2;
obj_2[2] = 3;
obj_2[3] = 4;
obj_2.join = Array.prototype.join;
assert (obj_2.join() === "1,2,3");

View file

@ -0,0 +1,70 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", 19, "bar", obj, "foo", 29, "baz"];
var index = array.lastIndexOf("foo");
assert(index === 4);
assert(array[index] === "foo");
assert(array.lastIndexOf("foo", 3) === 0);
assert(array.lastIndexOf("foo", -8) === -1);
var index = array.lastIndexOf("baz");
assert(index === 6);
assert(array[index] === "baz");
assert(array.lastIndexOf("baz", -2) === -1);
var index = array.lastIndexOf(obj);
assert(index === 3);
assert(array[index] === obj);
assert(array.lastIndexOf("foo", NaN) === 0);
assert(array.lastIndexOf("foo", Infinity) === 4);
assert(array.lastIndexOf("foo", -Infinity) === -1);
var arr = [];
arr[4294967294] = "foo";
assert(arr.lastIndexOf("foo", -1) === 4294967294)
var arr = [1,2];
assert(arr.lastIndexOf(2, undefined) === -1);
assert(arr.lastIndexOf(2) === 1);
// Checking behavior when unable to get length
var obj = { lastIndexOf : Array.prototype.lastIndexOf}
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.lastIndexOf("bar");
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { lastIndexOf : Array.prototype.lastIndexOf, length : 1}
Object.defineProperty(obj, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.lastIndexOf("bar");
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,112 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.
// helper function - simple implementation
Array.prototype.equals = function (array) {
if (this.length != array.length)
return false;
for (var i = 0; i < this.length; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
if (!this[i].equals(array[i]))
return false;
}
else if (this[i] != array[i]) {
return false;
}
}
return true;
}
// check function type
try {
[0].map(new Object());
assert(false);
} catch(e) {
assert(e instanceof TypeError);
}
// various checks
assert ([1, 4, 9].map(Math.sqrt).equals([1, 2, 3]));
assert (isNaN([1, 4, "X"].map(Number)[2]));
var func = function(val, idx) {
return val + idx;
};
assert ([1, 4, 9].map(func).equals([1,5,11]));
assert ([1, "X", 10].map(func).equals([1, "X1", 12]));
var arr = [1,2,3];
arr.length = 5;
assert(arr.map(func).length === arr.length);
var long_array = [0, 1];
assert (long_array.map(func).equals([0,2]));
long_array[100] = 1;
assert (long_array.map(func).equals([0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,101]));
var arr = [1,2];
Array.prototype[0] = 3;
var newArr = arr.map(function(value) { return value; });
delete Array.prototype[0];
assert(newArr.hasOwnProperty("0"));
assert(newArr[0] === 1);
// check behavior when unable to get length
var obj = {};
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.map = Array.prototype.map;
try {
obj.map(func);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// check behavior when unable to get element
var obj = {}
obj.length = 1;
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
obj.map = Array.prototype.map
try {
obj.map(func);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// check thisArg
var thisArg = {add: 10};
var func2 = function(value) {
return this.add + value;
}
assert([1,2].map(func2, thisArg).equals([11, 12]));
// check passed Object
var array_example = [1,2];
Object.defineProperty(array_example, 'const', { 'get' : function () {return "CT";} });
var func3 = function(value, idx, thisobj) {
return value * idx + thisobj.const;
}
assert(array_example.map(func3).equals(["0CT", "2CT"]));

View file

@ -0,0 +1,75 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4]
assert(array.length === 4);
assert(array.pop() === 4)
assert(array.length === 3);
assert(array.pop() === Infinity);
assert(array.length === 2);
var a = array.pop()
assert(a instanceof Array);
assert(array.length === 1);
assert(array.pop() === "foo");
assert(array.length === 0);
assert(array.pop() === undefined);
assert(array.length === 0);
// Checking behavior when unable to get length
var obj = { pop : Array.prototype.pop };
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.pop();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to set length
var obj = { pop : Array.prototype.pop };
Object.defineProperty(obj, 'length', { 'set' : function () {throw new ReferenceError ("foo"); } });
try {
obj.pop();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when no length property defined
var obj = { pop : Array.prototype.pop };
assert(obj.length === undefined)
assert(obj.pop() === undefined)
assert(obj.length === 0)
// Checking behavior when unable to get element
var obj = { pop : Array.prototype.pop, length : 1 };
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.pop();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,75 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 len;
var d = [];
assert (d.length === 0);
len = d.push();
assert (d.length === 0);
assert (d.length === len);
len = d.push(1);
assert (d.length === 1);
assert (d.length === len);
len = d.push(2);
assert (d.length === 2);
assert (d.length === len);
len = d.push('a');
assert (d.length === 3);
assert (d.length === len);
len = d.push('b', 'c', 3);
assert (d.length == 6);
assert (d.length === len);
assert (d[0] === 1);
assert (d[1] === 2);
assert (d[2] === 'a');
assert (d[3] === 'b');
assert (d[4] === 'c');
assert (d[5] === 3);
var a = [];
a.length = 4294967294;
assert(a.push("x") === 4294967295);
assert(a.length === 4294967295);
assert(a[4294967294] === "x");
try {
a.push("y");
assert(false);
} catch (e) {
assert (e instanceof RangeError);
}
assert(a.length === 4294967295)
var o = { length : 4294967294, push : Array.prototype.push };
assert(o.push("x") === 4294967295);
assert(o.length === 4294967295);
assert(o[4294967294] === "x");
try {
assert(o.push("y") === 4294967296);
} catch (e) {
assert(false);
}
assert(o.length === 4294967296);
assert(o[4294967295] === "y");
try {
assert(o.push("z") === 1);
} catch (e) {
assert(false);
}
assert(o.length === 1);
assert(o[0] === "z");

View file

@ -0,0 +1,88 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 func = function(a, b) {
return a + b;
}
// check function type
try {
[0].reduceRight(new Object());
assert(false);
} catch(e) {
assert(e instanceof TypeError);
}
// check for init value
try {
[].reduceRight(func);
assert(false);
} catch(e) {
assert(e instanceof TypeError);
}
try {
var arg2;
[].reduceRight(func, arg2);
assert(false);
} catch(e) {
assert(e instanceof TypeError);
}
try {
var a = new Array();
a.length = 10;
a.reduceRight(func);
assert (false);
} catch (e) {
assert (e instanceof TypeError)
}
// various checks
assert([].reduceRight(func, 1) === 1);
assert([0].reduceRight(func) === 0);
assert([0, 1].reduceRight(func) === 1);
assert([0, 1].reduceRight(func, 1) === 2);
assert([0, 1, 2, 3].reduceRight(func, 1) === 7);
assert (["A","B"].reduceRight(func) === "BA");
assert (["A","B"].reduceRight(func, "Init:") === "Init:BA");
assert ([0, 1].reduceRight(func, 3.2) === 4.2);
assert ([0, "x", 1].reduceRight(func) === "1x0");
assert ([0, "x", 1].reduceRight(func, 3.2) === "4.2x0");
var long_array = [0, 1];
assert (long_array.reduceRight(func,10) === 11);
long_array[10000] = 1;
assert (long_array.reduceRight(func,10) === 12);
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
return typeof prevVal === "undefined";
}
var obj = { 0: 11, length: 1 };
assert (Array.prototype.reduceRight.call(obj, callbackfn, undefined) === true && accessed);

View file

@ -0,0 +1,73 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 func = function(a, b) {
return a + b;
}
// check function type
try {
[0].reduce(new Object());
assert(false);
}
catch(e) {
assert(e instanceof TypeError);
}
// check for init value
try {
[].reduce(func);
assert(false);
}
catch(e) {
assert(e instanceof TypeError);
}
// various checks
assert ([].reduce(func, 1) === 1);
assert ([0].reduce(func) === 0);
assert ([0, 1].reduce(func) === 1);
assert ([0, 1].reduce(func, 1) === 2);
assert ([0, 1, 2, 3].reduce(func, 1) === 7);
assert (["A","B"].reduce(func) === "AB");
assert (["A","B"].reduce(func, "Init:") === "Init:AB");
assert ([0, 1].reduce(func, 3.2) === 4.2);
assert ([0, "x", 1].reduce(func) === "0x1");
assert ([0, "x", 1].reduce(func, 3.2) === "3.2x1");
var long_array = [0, 1];
assert (long_array.reduce(func,10) === 11);
long_array[10000] = 1;
assert (long_array.reduce(func,10) === 12);
var accessed = false;
function callbackfn(prevVal, curVal, idx, obj) {
accessed = true;
return typeof prevVal === "undefined";
}
var obj = { 0: 11, length: 1 };
assert (Array.prototype.reduce.call(obj, callbackfn, undefined) === true && accessed);

View file

@ -0,0 +1,46 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = [4, 3, 2, 1, 0]
array.reverse();
for (i = 0; i < array.length; i++) {
assert(array[i] === i);
}
// Checking behavior when unable to get length
var obj = { reverse : Array.prototype.reverse };
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.reverse();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { reverse : Array.prototype.reverse, length : 3 };
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.reverse();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,80 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4]
assert(array.length === 4);
assert(array.shift() === "foo");
assert(array.length === 3);
var a = array.shift();
assert(a instanceof Array);
assert(array.length === 2);
assert(array.shift() === Infinity);
assert(array.length === 1);
assert(array.shift() === 4);
assert(array.length === 0);
assert(array.shift() === undefined);
assert(array.length === 0);
var referenceErrorThrower = function () {
throw new ReferenceError ("foo");
}
// Checking behavior when unable to get length
var obj = { shift : Array.prototype.shift };
Object.defineProperty(obj, 'length', { 'get' : referenceErrorThrower });
try {
obj.shift();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to set length
var obj = { shift : Array.prototype.shift };
Object.defineProperty(obj, 'length', { 'set' : referenceErrorThrower });
try {
obj.shift();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when no length property defined
var obj = { shift : Array.prototype.shift };
assert (obj.length === undefined)
assert (obj.shift() === undefined)
assert (obj.length === 0)
// Checking behavior when unable to get element
var obj = { shift : Array.prototype.shift, length : 1 };
Object.defineProperty(obj, '0', { 'get' : referenceErrorThrower });
try {
obj.shift();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,111 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = [54, undefined, "Lemon", -127];
var array1 = array.slice();
var array2 = array.slice("a", "3");
var array3 = array.slice(-2);
var array4 = array.slice(-12, undefined);
var array5 = array.slice(undefined, -3);
var array6 = array.slice(Infinity, NaN);
var array7 = array.slice(-Infinity, Infinity);
var array8 = array.slice(NaN, -Infinity);
assert (array1.length == 4);
assert (array1[0] == 54);
assert (array1[1] == undefined);
assert (array1[2] == "Lemon");
assert (array1[3] == -127);
assert (array2.length == 3);
assert (array2[0] == 54);
assert (array2[1] == undefined);
assert (array2[2] == "Lemon");
assert (array3.length == 2);
assert (array3[0] == "Lemon");
assert (array3[1] == -127);
assert (array4.length == 4);
assert (array4[0] == 54);
assert (array4[1] == undefined);
assert (array4[2] == "Lemon");
assert (array4[3] == -127);
assert (array5.length == 1);
assert (array5[0] == 54);
assert (array6.length == 0);
assert (array7.length == 4);
assert (array7[0] == 54);
assert (array7[1] == undefined);
assert (array7[2] == "Lemon");
assert (array7[3] == -127);
assert (array8.length == 0);
var array = [];
array[4294967293] = "foo";
array.length = 4294967295;
var result = array.slice(4294967293, -1)
assert(result.length === 1)
assert(result[0] === "foo")
array[0] = "bar";
var result = array.slice(-4294967295, -4294967294)
assert(result.length === 1)
assert(result[0] === "bar")
var array = [];
array[0] = "foo";
var result = array.slice(4294967296, 4294967297);
assert(result.length === 0);
array[4294967293] = "bar";
var result = array.slice(-4294967297, -4294967296);
assert(result.length === 0);
var arr = [1,2];
Array.prototype[0] = 3;
var newArr = arr.slice(0, 1);
delete Array.prototype[0];
assert(newArr.hasOwnProperty("0"));
assert(newArr[0] === 1);
// Checking behavior when unable to get length
var obj = { slice : Array.prototype.slice };
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.slice(1, 2);
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { length : 1, slice : Array.prototype.slice };
Object.defineProperty(obj, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.slice(0, 1);
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,62 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["foo", [], Infinity, 4];
function f(arg1, arg2, arg3) {
assert(arg1 === array[arg2]);
assert(arg3 === array);
return false;
}
assert(array.some(f) === false);
function g(arg1, arg2, arg3) {
if (arg1 === 1) {
return true;
} else {
return false;
}
}
var arr1 = [2, 2, 2, 2, 2, 2];
assert(arr1.some(g) === false);
var arr2 = [2, 2, 2, 2, 2, 1];
assert(arr2.some(g) === true);
// Checking behavior when unable to get length
var obj = { some : Array.prototype.some };
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.some(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { some : Array.prototype.some, length : 1};
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.some(f);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,95 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = ["Peach", "Apple", "Orange", "Grape", "Cherry", "Apricot", "Grapefruit"];
array.sort();
assert(array[0] === "Apple");
assert(array[1] === "Apricot");
assert(array[2] === "Cherry");
assert(array[3] === "Grape");
assert(array[4] === "Grapefruit");
assert(array[5] === "Orange");
assert(array[6] === "Peach");
var array = [6, 4, 5, 1, 2, 9, 7, 3, 0, 8];
// Default comparison
array.sort();
for (i = 0; i < array.length; i++) {
assert(array[i] === i);
}
// Using custom comparison function
function f(arg1, arg2) {
if (arg1 < arg2) {
return 1;
} else if (arg1 > arg2) {
return -1;
} else {
return 0;
}
}
array.sort(f);
for (i = 0; i < array.length; i++) {
assert(array[array.length - i - 1] === i);
}
// Sorting sparse array
var array = [1,,2,,3,,4,undefined,5];
var expected = [1,2,3,4,5,undefined,,,,];
array.sort();
assert(array.length === expected.length);
for (i = 0; i < array.length; i++) {
assert(expected.hasOwnProperty (i) === array.hasOwnProperty (i));
assert(array[i] === expected[i]);
}
// Checking behavior when provided comparefn is not callable
var obj = {};
var arr = [];
try {
arr.sort(obj);
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// Checking behavior when unable to get length
var obj = { sort : Array.prototype.sort}
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.sort();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = { sort : Array.prototype.sort, length : 1}
Object.defineProperty(obj, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.sort();
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,176 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 setDefaultValues()
{
return [54, undefined, -127, "sunshine"];
}
var array = setDefaultValues();
var array1 = array.splice();
assert (array.length == 4);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array[2] == -127);
assert (array[3] == "sunshine");
assert (array1.length == 0);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array2 = array.splice(2);
assert (array.length == 2);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array2.length == 2);
assert (array2[0] == -127);
assert (array2[1] == "sunshine");
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array3 = array.splice(2, 1);
assert (array.length == 3);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array[2] == "sunshine");
assert (array3.length == 1);
assert (array3[0] == -127);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array4 = array.splice(0, 3, 6720, "Szeged");
assert (array.length == 3);
assert (array[0] == 6720);
assert (array[1] == "Szeged");
assert (array[2] == "sunshine");
assert (array4.length == 3);
assert (array4[0] == 54);
assert (array4[1] == undefined);
assert (array4[2] == -127);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array5 = array.splice(-2, -2, 6720, "Szeged");
assert (array.length == 6);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array[2] == 6720);
assert (array[3] == "Szeged");
assert (array[4] == -127);
assert (array[5] == "sunshine");
assert (array5.length == 0);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array6 = array.splice(undefined, undefined, undefined);
assert (array.length == 5);
assert (array[0] == undefined);
assert (array[1] == 54);
assert (array[2] == undefined);
assert (array[3] == -127);
assert (array[4] == "sunshine");
assert (array6.length == 0);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array7 = array.splice(Infinity, NaN);
assert (array.length == 4);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array[2] == -127);
assert (array[3] == "sunshine");
assert (array7.length == 0);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array8 = array.splice(-Infinity, Infinity);
assert (array.length == 0);
assert (array8.length == 4);
assert (array8[0] == 54);
assert (array8[1] == undefined);
assert (array8[2] == -127);
assert (array8[3] == "sunshine");
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array9 = array.splice(NaN, -Infinity);
assert (array.length == 4);
assert (array[0] == 54);
assert (array[1] == undefined);
assert (array[2] == -127);
assert (array[3] == "sunshine");
assert (array9.length == 0);
// --------------------------------------------------------
array = setDefaultValues(); // 54, undefined, -127, "sunshine"
var array10 = array.splice(-3, 4, Infinity, "university");
assert (array.length == 3);
assert (array[0] == 54);
assert (array[1] == Infinity);
assert (array[2] == "university");
assert (array10.length == 3);
assert (array10[0] == undefined);
assert (array10[1] == -127);
assert (array10[2] == "sunshine");
var array = [];
array[4294967294] = "foo";
var result = array.splice(4294967294, 1, "x")
assert(result.length === 1)
assert(result[0] === "foo")
assert(array[4294967294] === "x")
array[0] = "bar";
var result = array.splice(-4294967295, 1, "y");
assert(result.length === 1)
assert(result[0] === "bar")
assert(array[0] === "y")
var arr = [1,2];
Array.prototype[0] = 3;
var newArr = arr.splice(0, 1);
delete Array.prototype[0];
assert(newArr.hasOwnProperty("0"));
assert(newArr[0] === 1);
// Checking behavior when unable to get length
var obj = {splice : Array.prototype.splice};
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.splice(1, 2, "item1", "item2");
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Checking behavior when unable to get element
var obj = {length : 1, splice : Array.prototype.splice};
Object.defineProperty(obj, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj.splice(0, 1, "item1", "item2");
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,57 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 ([].toLocaleString() === "");
assert ([1].toLocaleString() === "1");
assert ([1,2].toLocaleString() === "1,2");
assert ([1,2,3].toLocaleString() === "1,2,3");
var test_ok = {
length: 1,
toLocaleString: function() { return "1"; }
};
assert ([3, test_ok, 4, test_ok].toLocaleString() === "3,1,4,1");
var obj = { toLocaleString: function() {} };
var test_non_str_locale = [undefined, obj, null, obj, obj];
assert(test_non_str_locale.toLocaleString() === ",undefined,,undefined,undefined");
var test_fail = {
toLocaleString: "FAIL"
};
try {
[test_fail].toLocaleString();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
var test_fail_call = {
toLocaleString: function() { throw new ReferenceError("foo"); }
};
try {
[1, 2, test_fail_call].toLocaleString();
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,64 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.
// Our own join method if the internal join is not implemented.
function join(sep)
{
sep = sep ? sep : ",";
var result = "";
for (var i = 0; i < this.length; ++i) {
result += this[i];
if (i + 1 < this.length) {
result += sep;
}
}
return result;
}
// Force fallback to object.prototype.toString()
Array.prototype.join = 1;
assert ([1].toString() === "[object Array]");
Array.prototype.join = join;
assert ([1, 2].toString() === "1,2");
var test = [1,2,3];
test.join = function() { throw ReferenceError ("foo"); };
try {
test.toString();
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// Test if the join returns a ReferenceError
var arr = [1,2]
Object.defineProperty(arr, 'join', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
arr.toString();
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,104 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 array = []
assert(array.length === 0);
array.unshift("foo");
assert(array.length === 1);
assert(array[0] === "foo");
array.unshift(new Array())
assert(array.length === 2);
assert(array[0] instanceof Array);
assert(array[1] === "foo")
array.unshift(Infinity);
assert(array.length === 3);
assert(array[0] === Infinity);
assert(array[1] instanceof Array);
assert(array[2] === "foo")
array.unshift("bar", 0);
assert(array.length === 5);
assert(array[0] === "bar");
assert(array[1] === 0);
assert(array[2] === Infinity);
assert(array[3] instanceof Array);
assert(array[4] === "foo")
// Checking behavior when no length property defined
var obj = { unshift : Array.prototype.unshift };
assert(obj.length === undefined);
obj.unshift(1,2,3);
assert(obj.length === 3);
// Checking behavior when unable to get length
var obj = { unshift : Array.prototype.unshift };
Object.defineProperty(obj, 'length', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.unshift(1);
assert(false)
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable to set length
var obj = { unshift : Array.prototype.unshift };
Object.defineProperty(obj, 'length', { 'set' : function () {throw new ReferenceError ("foo"); } });
try {
obj.unshift(2);
assert(false)
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when unable shift elements
var obj = { unshift : Array.prototype.unshift, length : 1 };
Object.defineProperty(obj, '0', { 'get' : function () {throw new ReferenceError ("foo"); } });
try {
obj.unshift(3);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
var obj = { unshift : Array.prototype.unshift, length : 1 };
Object.defineProperty(obj, '0', { 'set' : function () {throw new ReferenceError ("foo"); } });
try {
obj.unshift(4);
assert(false);
} catch (e) {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Checking behavior when a property is not defined
var obj = { '0' : "foo", '2' : "bar", length : 3, unshift : Array.prototype.unshift };
assert(obj.unshift("baz") === 4);
assert(obj[0] === "baz");
assert(obj[1] === "foo");
assert(obj[2] === undefined);
assert(obj[3] === "bar");

View file

@ -0,0 +1,157 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 cars = ["Saab", "Volvo", "BMW"];
assert (cars[0] === "Saab");
assert (cars[1] === "Volvo");
assert (cars[2] === "BMW");
var cars1 = new Array("Saab", "Volvo", "BMW");
assert (cars[0] === cars1[0]);
assert (cars[1] === cars1[1]);
assert (cars[2] === cars1[2]);
var a = new Array();
assert (typeof (a) === "object");
assert (Array.isArray (a));
assert (Array.isArray ([1, 2, 3]));
var b = new Array (30000);
assert(b.length === 30000);
assert (b[20000] === undefined);
b[20000] = 1;
assert (b[20000] === 1);
b[20000] = 10;
assert (b[20000] === 10);
assert(b.length === 30000);
assert(b[10000] === undefined);
Object.defineProperty (b, '10000', {value : 25, writable : false});
assert(b[10000] === 25);
b[10000] = 30;
assert(b[10000] === 25);
assert(b.length === 30000);
assert(b[50000] === undefined);
assert(b.length === 30000);
b[50000] = 5;
assert(b.length === 50001);
assert(b[50000] === 5);
b[50000] = 10;
assert(b[50000] === 10);
Object.defineProperty (b, '50000', {writable : false});
assert(b[50000] === 10);
b[50000] = 20;
assert(b[50000] === 10);
Object.defineProperty (b, '50000', {writable : true});
assert(b[50000] === 10);
b[50000] = 30;
assert(b[50000] === 30);
b.length = 5;
assert(b[50000] === undefined);
assert(([1, 2, 3]).length === 3);
assert(Array.prototype.constructor === Array);
assert(Array.prototype.length === 0);
Array.prototype[0] = 'string value';
assert(Array.prototype.length === 1);
assert(Array.prototype[0] === 'string value');
var c = [0,,,'3'];
assert (c[0] === 0);
assert (c[1] === undefined);
assert (c[2] === undefined);
assert (c[3] === '3');
b[0] = 1;
c[0] += b[0];
assert (c[0] == 1);
var arr = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240,
241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256,
257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288,
289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320,
321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336,
337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352,
353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368,
369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400,
401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416,
417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432,
433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448,
449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464,
465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480,
481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496,
497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512,
513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528,
529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544,
545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560,
561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576,
577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592,
593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608,
609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624,
625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640,
641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656,
657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672,
673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688,
689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704,
705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720,
721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736,
737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752,
753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768,
769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784,
785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800,
801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816,
817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832,
833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848,
849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864,
865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880,
881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896,
897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912,
913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928,
929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944,
945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960,
961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976,
977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992,
993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008,
1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024 ];
for (i = 0; i < 1024; i++)
{
assert (arr[i] === i + 1);
}
var elision = [0,,2 ,3];
assert (elision.hasOwnProperty(1) == false);

View file

@ -0,0 +1,21 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 b = 5;
assert((b += 10) == 15);
assert((b -= 3) == 12);
assert((b *= 10) == 120);
assert((b /= 10) == 12);
assert((b %= 10) == 2);

View file

@ -0,0 +1,21 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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((5 & 2) === 0);
assert((2 & 2) === 2);
assert((5 | 2) === 7);
assert((5 | 5) === 5);
assert((5 ^ 2) === 7);
assert((5 ^ 5) === 0);
assert((~5) == -6);

View file

@ -0,0 +1,158 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
/* with */
for (var i = 0; i < 10; i++)
{
with ({})
{
break;
assert (false);
}
}
assert (i === 0);
for (var i = 0; i < 10; i++)
{
with ({})
{
continue;
assert (false);
}
}
assert (i === 10);
/* try */
for (var i = 0; i < 10; i++)
{
try
{
break;
assert (false);
}
catch (e)
{
}
}
assert (i === 0);
for (var i = 0; i < 10; i++)
{
try
{
continue;
assert (false);
}
catch (e)
{
}
}
assert (i === 10);
/* catch */
for (var i = 0; i < 10; i++)
{
try
{
throw new TypeError ();
assert (false);
}
catch (e)
{
break;
assert (false);
}
}
assert (i === 0);
for (var i = 0; i < 10; i++)
{
try
{
throw new TypeError ();
assert (false);
}
catch (e)
{
continue;
assert (false);
}
}
assert (i === 10);
/* finally */
for (var i = 0; i < 10; i++)
{
try
{
throw new TypeError ();
assert (false);
}
catch (e)
{
}
finally
{
break;
assert (false);
}
}
assert (i === 0);
for (var i = 0; i < 10; i++)
{
try
{
throw new TypeError ();
assert (false);
}
catch (e)
{
}
finally
{
continue;
assert (false);
}
}
assert (i === 10);
/* with - switch */
str = '';
for (var i = 0; i < 10; i++)
{
with ({})
{
switch (i)
{
case 0:
str += 'A';
break;
default:
str += 'B';
continue;
}
str += 'C';
}
}
assert (str === 'ACBBBBBBBBB');

View file

@ -0,0 +1,27 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.prototype.toString = Object.prototype.toString;
assert(Array.toString() === "[object Function]");
assert(Number.toString() === "[object Function]");
assert(String.toString() === "[object Function]");
assert(Boolean.toString() === "[object Function]");
assert(Object.toString() === "[object Function]");
assert(Function.toString() === "[object Function]");
assert(Date.toString() === "[object Function]");
assert(RegExp.toString() === "[object Function]");
assert(Math.toString() === "[object Math]");
assert(JSON.toString() === "[object JSON]");

View file

@ -0,0 +1,46 @@
// Copyright 2015-2016 Samsung Electronics Co., Ltd.
// Copyright 2015-2016 University of Szeged.
//
// 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 d = new Date(1999, 1, 1);
assert (d.getYear() === 99);
d = new Date(1874, 4, 9);
assert (d.getYear() === -26);
d = new Date(2015, 8, 17);
assert (d.getYear() === 115);
d = new Date(NaN);
assert (isNaN (d.getYear()));
var d = new Date();
d.setYear(91);
assert (d.getFullYear() === 1991 && d.getYear() === 91);
d = new Date();
d.setYear(NaN);
assert (isNaN(d.valueOf()));
d = new Date();
d.setYear(2015);
assert (d.getFullYear() === 2015);
d = new Date(2000, 1, 29);
d.setYear(2004);
assert (d.getFullYear() === 2004 && d.getMonth() === 1 && d.getDate() === 29);
d.setYear(2015);
assert (d.getFullYear() === 2015 && d.getMonth() === 2 && d.getDate() === 1);
assert (/Thu, 17 Sep 2015 \d{2}:\d{2}:\d{2} GMT/.test (new Date("2015-09-17").toGMTString()));
d = new Date(NaN);
assert (d.toGMTString() === "Invalid Date");

View file

@ -0,0 +1,82 @@
// Copyright 2015-2016 Samsung Electronics Co., Ltd.
// Copyright 2015-2016 University of Szeged.
//
// 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 (Date.length == 7);
assert (Object.prototype.toString.call (Date.prototype) === '[object Date]');
var d;
try
{
d = new Date({toString: function() { throw new Error("foo"); }});
assert (false);
}
catch (e)
{
assert (e instanceof Error);
assert (e.message === "foo");
}
assert (isNaN(Date.prototype.valueOf.call(Date.prototype)));
d = new Date("abcd");
assert (isNaN(d.valueOf()));
d = new Date();
assert (!isNaN(d.valueOf()));
d = new Date("2015-01-01");
assert (d.valueOf() == 1420070400000);
d = new Date(1420070400000);
assert (d.valueOf() == 1420070400000);
d = new Date(2015,0,1,0,0,0,0);
assert (d.valueOf() - (d.getTimezoneOffset() * 60000) == 1420070400000);
d = new Date(8.64e+15);
assert (d.valueOf() == 8.64e+15);
d = new Date(8.64e+15 + 1);
assert (isNaN(d.valueOf()));
d = new Date(20000000, 0, 1);
assert (isNaN(d.valueOf()));
d = new Date(0, 20000000, 1);
assert (isNaN(d.valueOf()));
var Obj = function (val)
{
this.value = val;
this.valueOf = function () { throw new ReferenceError ("valueOf-" + this.value); };
this.toString = function () { throw new ReferenceError ("toString-"+ this.value); };
};
try
{
d = new Date (new Obj (1), new Obj (2));
// Should not be reached.
assert (false);
}
catch (e)
{
assert (e instanceof ReferenceError);
assert (e.message === "valueOf-1");
}
assert (typeof Date (2015) == "string");
assert (typeof Date() != typeof (new Date ()));
assert (Date (Number.NaN) == Date ());

View file

@ -0,0 +1,110 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.
/* 1. test case */
var d = new Date(2015, 6, 9, 12, 13, 14, 121);
assert (d.getFullYear() == 2015);
assert (d.getUTCFullYear() == 2015);
assert (d.getMonth() == 6);
assert (d.getUTCMonth() == 6);
assert (d.getDate() == 9);
assert (d.getUTCDate() == 9);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
assert (d.getHours() == 12);
// FIXME: Missing timezone adjustment.
//assert (d.getUTCHours() == (12 + d.getTimezoneOffset() / 60));
assert (d.getMinutes() == 13);
assert (d.getUTCMinutes() == 13);
assert (d.getSeconds() == 14);
assert (d.getUTCSeconds() == 14);
assert (d.getMilliseconds() == 121);
assert (d.getUTCMilliseconds() == 121);
/* 2. test case */
var d = new Date("2015-07-09T12:13:14.121+01:30");
assert (d.getFullYear() == 2015);
assert (d.getUTCFullYear() == 2015);
assert (d.getMonth() == 6);
assert (d.getUTCMonth() == 6);
assert (d.getDate() == 9);
assert (d.getUTCDate() == 9);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
// FIXME: Missing timezone adjustment.
//assert (d.getHours() == 12);
//assert (d.getUTCHours() == (12 + d.getTimezoneOffset() / 60));
assert (d.getMinutes() == 43);
assert (d.getUTCMinutes() == 43);
assert (d.getSeconds() == 14);
assert (d.getUTCSeconds() == 14);
assert (d.getMilliseconds() == 121);
assert (d.getUTCMilliseconds() == 121);
/* 3. test case */
var d = new Date(0);
assert (d.getFullYear() == 1970);
assert (d.getUTCFullYear() == 1970);
assert (d.getMonth() == 0);
assert (d.getUTCMonth() == 0);
assert (d.getDate() == 1);
assert (d.getUTCDate() == 1);
assert (d.getDay() == 4);
assert (d.getUTCDay() == 4);
// FIXME: Missing timezone adjustment.
// assert (d.getHours() == 0 - (d.getTimezoneOffset() / 60));
assert (d.getUTCHours() == 0);
assert (d.getMinutes() == 0);
assert (d.getUTCMinutes() == 0);
assert (d.getSeconds() == 0);
assert (d.getUTCSeconds() == 0);
assert (d.getMilliseconds() == 0);
assert (d.getUTCMilliseconds() == 0);
/* 4. test case */
var d = new Date("abcd");
assert (isNaN (d));
assert (isNaN (d.getFullYear()));
assert (isNaN (d.getUTCFullYear()));
assert (isNaN (d.getMonth()));
assert (isNaN (d.getUTCMonth()));
assert (isNaN (d.getDate()));
assert (isNaN (d.getUTCDate()));
assert (isNaN (d.getDay()));
assert (isNaN (d.getUTCDay()));
assert (isNaN (d.getHours()));
assert (isNaN (d.getUTCHours()));
assert (isNaN (d.getMinutes()));
assert (isNaN (d.getUTCMinutes()));
assert (isNaN (d.getSeconds()));
assert (isNaN (d.getUTCSeconds()));
assert (isNaN (d.getMilliseconds()));
assert (isNaN (d.getUTCMilliseconds()));
assert (isNaN (d.getTimezoneOffset()));
/* 5. test case */
assert (new Date(2013, -1).getMonth() === 11);
assert (new Date(-2, -2).getFullYear() === -3);
assert (new Date(-1, -1).getFullYear() === -2);
assert (new Date(-1, -1, -1).getMonth() === 10);
assert (new Date(-1, -1, -1, -1).getDate() === 28);
assert (new Date(-1, -1, -1, -1, -1).getHours() === 22);
assert (new Date(-1, -1, -1, -1, -1, -1).getMinutes() === 58);
assert (new Date(-1, -1, -1, -1, -1, -1, -1).getSeconds() === 58);
assert (new Date(-1, -1, -1, -1, -1, -1, -1, -1).getMilliseconds() === 999);

View file

@ -0,0 +1,99 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 wrongFormats = ["",
"2",
"20",
"201",
"2015-",
"2015-01-",
"2015-01-01-",
"qwerty",
"2015-01-01T",
"2015-01-01T1:1",
"2015-01-01T01",
"2015-01-01T01",
"2015-01-01T01:01F",
"T2015",
"2015-01-01Z",
"2015-01-01+01:00",
"2015-01-01T00:00+01",
"2015-01-01T00:00+1",
"2015-01-01T00:00-01",
"2015-01-01T00:00.000",
"2015-01-01T00:00:",
"2015-01-01T00:",
"2015-01-01T00:00:00.1",
"2015-01-01T00:00:00.01",
"2015-01-01T00:00+01:00Z",
"2015/01/01",
"2015-01-32",
"2015--1",
"2015-13",
"2015-01--1",
"-215",
"-215-01-01",
"2015-01-00",
"2015-01-01T25:00",
"2015-01-01T00:60",
"2015-01-01T-1:00",
"2015-01-01T00:-1",
"2e+3"];
for (i in wrongFormats) {
var d = Date.parse(wrongFormats[i]);
assert (isNaN(d));
}
var d;
d = Date.parse(undefined);
assert (isNaN(d));
d = Date.parse({});
assert (isNaN(d));
d = Date.parse(2000 + 15);
assert (d == 1420070400000);
d = Date.parse("2015");
assert (d == 1420070400000);
d = Date.parse("2015-01");
assert (d == 1420070400000);
d = Date.parse("2015-01-01");
assert (d == 1420070400000);
d = Date.parse("2015-01T00:00");
assert (d == 1420070400000);
d = Date.parse("2015-01T00:00:00");
assert (d == 1420070400000);
d = Date.parse("2015-01T00:00:00.000");
assert (d == 1420070400000);
d = Date.parse("2015-01T24:00:00.000");
assert (d == 1420070400000);
d = Date.parse("2015-01T00:00:00.000+03:00");
assert (d == 1420059600000);
d = Date.parse("2015-01T00:00:00.000-03:00");
assert (d == 1420081200000);
d = Date.parse("2015-07-03T14:35:43.123+01:30");
assert (d == 1435928743123);

View file

@ -0,0 +1,244 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 ms = 1;
var sec = 1000 * ms;
var min = 60 * sec;
var hour = 60 * min;
var day = 24 * hour; /* 86400000 */
var d = new Date();
/* 15.9.5.27 Date.prototype.setTime (time) */
assert (d.setTime(0) == 0);
d.setTime(0);
assert (d.setTime(day) == day);
assert (d.getDate() == 2);
/* 15.9.5.28 Date.prototype.setMilliseconds (ms) */
d.setTime(0);
assert (d.setMilliseconds(1) == ms);
assert (d.getMilliseconds() == 1);
/* 15.9.5.29 Date.prototype.setUTCMilliseconds (ms) */
d.setTime(0);
assert (d.setUTCMilliseconds(1) == ms);
assert (d.getUTCMilliseconds() == 1);
/* 15.9.5.30 Date.prototype.setSeconds (sec [, ms ] ) */
d.setTime(0);
assert (d.setSeconds(1) == sec);
assert (d.getSeconds() == 1);
d.setTime(0);
assert (d.setSeconds(1, 1) == sec + ms);
assert (d.getSeconds() == 1);
assert (d.getMilliseconds() == 1);
/* 15.9.5.31 Date.prototype.setUTCSeconds (sec [, ms ] ) */
d.setTime(0);
assert (d.setUTCSeconds(1) == sec);
assert (d.getUTCSeconds() == 1);
d.setTime(0);
assert (d.setUTCSeconds(1, 1) == sec + ms);
assert (d.getUTCSeconds() == 1);
assert (d.getUTCMilliseconds() == 1);
/* 15.9.5.32 Date.prototype.setMinutes (min [, sec [, ms ] ] ) */
d.setTime(0);
assert (d.setMinutes(1) == min);
assert (d.getMinutes() == 1);
d.setTime(0);
assert (d.setMinutes(1, 1) == min + sec);
assert (d.getMinutes() == 1);
assert (d.getSeconds() == 1);
d.setTime(0);
assert (d.setMinutes(1, 1, 1) == min + sec + ms);
assert (d.getMinutes() == 1);
assert (d.getSeconds() == 1);
assert (d.getMilliseconds() == 1);
/* 15.9.5.33 Date.prototype.setUTCMinutes (min [, sec [, ms ] ] ) */
d.setTime(0);
assert (d.setUTCMinutes(1) == min);
assert (d.getUTCMinutes() == 1);
d.setTime(0);
assert (d.setUTCMinutes(1, 1) == min + sec);
assert (d.getUTCMinutes() == 1);
assert (d.getUTCSeconds() == 1);
d.setTime(0);
assert (d.setUTCMinutes(1, 1, 1) == min + sec + ms);
assert (d.getUTCMinutes() == 1);
assert (d.getUTCSeconds() == 1);
assert (d.getUTCMilliseconds() == 1);
/* 15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] ) */
// FIXME: Missing timezone adjustment.
//d.setTime(0);
//assert (d.setHours(1) == hour + d.getTimezoneOffset() * 60000);
//assert (d.getHours() == 1);
//d.setTime(0);
//assert (d.setHours(1, 1) == hour + min + d.getTimezoneOffset() * 60000);
//assert (d.getHours() == 1);
//assert (d.getMinutes() == 1);
//d.setTime(0);
//assert (d.setHours(1, 1, 1) == hour + min + sec + d.getTimezoneOffset() * 60000);
//assert (d.getHours() == 1);
//assert (d.getMinutes() == 1);
//assert (d.getSeconds() == 1);
//d.setTime(0);
//assert (d.setHours(1, 1, 1, 1) == hour + min + sec + ms + d.getTimezoneOffset() * 60000);
//assert (d.getHours() == 1);
//assert (d.getMinutes() == 1);
//assert (d.getSeconds() == 1);
//assert (d.getMilliseconds() == 1);
/* 15.9.5.35 Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] ) */
d.setTime(0);
assert (d.setUTCHours(1) == hour);
assert (d.getUTCHours() == 1);
d.setTime(0);
assert (d.setUTCHours(1, 1) == hour + min);
assert (d.getUTCHours() == 1);
assert (d.getUTCMinutes() == 1);
d.setTime(0);
assert (d.setUTCHours(1, 1, 1) == hour + min + sec);
assert (d.getUTCHours() == 1);
assert (d.getUTCMinutes() == 1);
assert (d.getUTCSeconds() == 1);
d.setTime(0);
assert (d.setUTCHours(1, 1, 1, 1) == hour + min + sec + ms);
assert (d.getUTCHours() == 1);
assert (d.getUTCMinutes() == 1);
assert (d.getUTCSeconds() == 1);
assert (d.getUTCMilliseconds() == 1);
/* 15.9.5.36 Date.prototype.setDate (date) */
d.setTime(0);
assert (d.setDate(0) == -day);
assert (d.getDate() == 31);
d.setTime(0);
assert (d.setDate(1) == 0);
assert (d.getDate() == 1);
/* 15.9.5.37 Date.prototype.setUTCDate (date) */
d.setTime(0);
assert (d.setUTCDate(0) == -day);
assert (d.getUTCDate() == 31);
d.setTime(0);
assert (d.setUTCDate(1) == 0);
assert (d.getUTCDate() == 1);
/* 15.9.5.38 Date.prototype.setMonth (month [, date ] ) */
d.setTime(0);
assert (d.setMonth(0) == 0);
assert (d.getMonth() == 0);
d.setTime(0);
assert (d.setMonth(0, 0) == -day);
assert (d.getMonth() == 11);
assert (d.getDate() == 31);
d.setTime(0);
assert (d.setMonth(1) == 31 * day);
assert (d.getMonth() == 1);
d.setTime(0);
assert (d.setMonth(12) == 365 * day);
assert (d.getMonth() == 0);
d.setTime(0);
assert (d.setMonth(13) == (365 + 31) * day);
assert (d.getMonth() == 1);
/* 15.9.5.39 Date.prototype.setUTCMonth (month [, date ] ) */
d.setTime(0);
assert (d.setUTCMonth(0) == 0);
assert (d.getUTCMonth() == 0);
d.setTime(0);
assert (d.setUTCMonth(0, 0) == -day);
assert (d.getUTCMonth() == 11);
assert (d.getUTCDate() == 31);
d.setTime(0);
assert (d.setUTCMonth(1) == 31 * day);
assert (d.getUTCMonth() == 1);
d.setTime(0);
assert (d.setUTCMonth(12) == 365 * day);
assert (d.getUTCMonth() == 0);
d.setTime(0);
assert (d.setUTCMonth(13) == (365 + 31) * day);
assert (d.getUTCMonth() == 1);
/* 15.9.5.40 Date.prototype.setFullYear (year [, month [, date ] ] ) */
d.setTime(0);
assert (d.setFullYear(0) == -62167219200000);
assert (d.getFullYear() == 0);
d.setTime(0);
assert (d.setFullYear(0, 0) == -62167219200000);
assert (d.getFullYear() == 0);
assert (d.getMonth() == 0);
d.setTime(0);
assert (d.setFullYear(0, 0, 0) == -62167219200000 - day);
assert (d.getFullYear() == -1);
assert (d.getMonth() == 11);
assert (d.getDate() == 31);
d.setTime(0);
assert (d.setFullYear(1970) == 0);
assert (d.getFullYear() == 1970);
/* 15.9.5.41 Date.prototype.setUTCFullYear (year [, month [, date ] ] ) */
d.setTime(0);
assert (d.setUTCFullYear(0) == -62167219200000);
assert (d.getUTCFullYear() == 0);
d.setTime(0);
assert (d.setUTCFullYear(0, 0) == -62167219200000);
assert (d.getUTCFullYear() == 0);
assert (d.getUTCMonth() == 0);
d.setTime(0);
assert (d.setUTCFullYear(0, 0, 0) == -62167219200000 - day);
assert (d.getUTCFullYear() == -1);
assert (d.getUTCMonth() == 11);
assert (d.getUTCDate() == 31);
d.setTime(0);
assert (d.setUTCFullYear(1970) == 0);
assert (d.getUTCFullYear() == 1970);
/* Without argument */
d = new Date();
assert (isNaN (d.setTime()));
assert (isNaN (d.setMilliseconds()));
assert (isNaN (d.setUTCMilliseconds()));
assert (isNaN (d.setSeconds()));
assert (isNaN (d.setUTCSeconds()));
assert (isNaN (d.setMinutes()));
assert (isNaN (d.setUTCMinutes()));
assert (isNaN (d.setHours()));
assert (isNaN (d.setUTCHours()));
assert (isNaN (d.setDate()));
assert (isNaN (d.getUTCDate()));
assert (isNaN (d.setMonth()));
assert (isNaN (d.setUTCMonth()));
assert (isNaN (d.setFullYear()));
assert (isNaN (d.setUTCFullYear()));
assert (isNaN (Date.prototype.setTime()));
assert (isNaN (Date.prototype.setMilliseconds()));
assert (isNaN (Date.prototype.setUTCMilliseconds()));
assert (isNaN (Date.prototype.setSeconds()));
assert (isNaN (Date.prototype.setUTCSeconds()));
assert (isNaN (Date.prototype.setMinutes()));
assert (isNaN (Date.prototype.setUTCMinutes()));
assert (isNaN (Date.prototype.setHours()));
assert (isNaN (Date.prototype.setUTCHours()));
assert (isNaN (Date.prototype.setDate()));
assert (isNaN (Date.prototype.getUTCDate()));
assert (isNaN (Date.prototype.setMonth()));
assert (isNaN (Date.prototype.setUTCMonth()));
assert (isNaN (Date.prototype.setFullYear()));
assert (isNaN (Date.prototype.setUTCFullYear()));

View file

@ -0,0 +1,145 @@
// Copyright 2015-2016 Samsung Electronics Co., Ltd.
// Copyright 2015-2016 University of Szeged.
//
// 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 (new Date (NaN) == "Invalid Date");
assert (new Date (Infinity, 1, 1, 0, 0, 0) == "Invalid Date");
assert (new Date (2015, Infinity, 1, 0, 0, 0) == "Invalid Date");
assert (new Date (2015, 7, 1, 0, Infinity, 0) == "Invalid Date");
assert (new Date (NaN, 1, 1, 0, 0, 0) == "Invalid Date");
assert (new Date (2015, NaN, 1, 0, 0, 0) == "Invalid Date");
assert (new Date (2015, 7, 1, 0, NaN, 0) == "Invalid Date");
assert (/Fri Feb 13 2015 \d{2}:\d{2}:\d{2} GMT\+\d{2}:\d{2}/.test (new Date ("2015-02-13")));
assert (/Wed Jul 08 2015 \d{2}:\d{2}:\d{2} GMT\+\d{2}:\d{2}/.test (new Date ("2015-07-08T11:29:05.023")));
try
{
Date.prototype.toString.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
var date = new Date(0);
assert (/Thu Jan 01 1970 \d{2}:\d{2}:\d{2} GMT\+\d{2}:\d{2}/.test (date.toString()));
assert (date.toUTCString() === "Thu, 01 Jan 1970 00:00:00 GMT");
assert (date.toISOString() === "1970-01-01T00:00:00.000Z");
date = new Date("2015-08-12T09:40:20.000Z")
assert (/Wed Aug 12 2015 \d{2}:\d{2}:\d{2} GMT\+\d{2}:\d{2}/.test (date.toString()));
assert (date.toUTCString() === "Wed, 12 Aug 2015 09:40:20 GMT");
assert (date.toISOString() === "2015-08-12T09:40:20.000Z");
assert (new Date (NaN).toDateString () == "Invalid Date");
assert (new Date ("2015-02-13").toDateString () == "2015-02-13");
assert (new Date ("2015-07-08T11:29:05.023").toDateString () == "2015-07-08");
try
{
Date.prototype.toDateString.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
assert (new Date (NaN).toTimeString () == "Invalid Date");
assert (new Date (Number.POSITIVE_INFINITY).toString () === "Invalid Date");
assert (new Date ("2015-02-13").toTimeString () == "00:00:00.000");
assert (new Date ("2015-07-08T11:29:05.023").toTimeString () == "11:29:05.023");
try
{
Date.prototype.toTimeString.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
assert (new Date ("2015-07-16").toISOString () == "2015-07-16T00:00:00.000Z");
assert (new Date ("2015-07-16T11:29:05.023").toISOString () == "2015-07-16T11:29:05.023Z");
try
{
new Date (NaN).toISOString ();
assert (false);
}
catch (e)
{
assert (e instanceof RangeError);
}
try
{
new Date (Number.POSITIVE_INFINITY).toISOString ();
assert (false);
}
catch (e)
{
assert (e instanceof RangeError);
}
try
{
Date.prototype.toISOString.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
assert (new Date (NaN).toUTCString () == "Invalid Date");
assert (new Date ("2015-07-16").toUTCString () == "Thu, 16 Jul 2015 00:00:00 GMT");
assert (new Date ("2015-07-16T11:29:05.023").toUTCString () == "Thu, 16 Jul 2015 11:29:05 GMT");
try
{
Date.prototype.toUTCString.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
assert (new Date (NaN).toJSON () == null);
assert (new Date ("2015-07-16").toJSON () == "2015-07-16T00:00:00.000Z");
assert (new Date ("2015-07-16T11:29:05.023").toJSON () == "2015-07-16T11:29:05.023Z");
try
{
Date.prototype.toJSON.call(-1);
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
date_time = new Date ("2015-07-08T11:29:05.023").toJSON ();
assert (new Date (date_time).toISOString () == "2015-07-08T11:29:05.023Z");
assert (typeof Date (2015) == "string");
assert (typeof Date() != typeof (new Date ()));
assert (Date () == (new Date ()).toString ());
assert (Date (2015, 1, 1) == (new Date ()).toString ());
assert (Date (Number.NaN) == Date ());
assert (new Date ("2015-07-08T11:29:05.023Z").toISOString() == "2015-07-08T11:29:05.023Z");

View file

@ -0,0 +1,49 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 d;
d = Date.UTC(undefined);
assert (isNaN(d));
d = Date.UTC({});
assert (isNaN(d));
d = Date.UTC(2015);
assert (isNaN(d));
d = Date.UTC(2000 + 15, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 0, 1);
assert (d == 1420070400000);
d = Date.UTC(2015, 0, 1, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 0, 1, 0, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 0, 1, 0, 0, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 0, 1, 0, 0, 0, 0);
assert (d == 1420070400000);
d = Date.UTC(2015, 6, 3, 14, 35, 43, 123);
assert (d == 1435934143123);

View file

@ -0,0 +1,39 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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.
/* argument is not reference */
assert (delete 0 === true);
assert (delete "0" === true);
assert (delete (a = 1) === true);
assert (delete delete a === true);
/* argument is unresolvable reference */
assert (delete undefined_variable === true);
/* argument is object-based reference */
var a = [1];
assert (a[0] === 1);
assert (delete a[0] === true);
assert (a[0] == undefined);
var b = {c:0};
assert (b.c === 0);
assert (delete b.c === true);
assert (b.c === undefined);
/* argument is lexical environment-based reference */
var a = 1;
assert (a === 1);
assert (delete a === false);
assert (a === 1);

View file

@ -0,0 +1,15 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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();

View file

@ -0,0 +1,32 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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((5 == 5) == true);
assert((7 != 2) == true);
var num = 0;
//var obj = new String("0");
var str = "0";
var b = false;
assert(num === num);
//assert(obj === obj);
assert(str === str);
//assert((num === obj) == false);
assert((num === str) == false);
//assert((obj === str) == false);
//assert((null === undefined) == false);
//assert((obj === null) == false);
//assert((obj === undefined) == false);

View file

@ -0,0 +1,200 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 e;
/* Error */
e = new Error ();
assert (e.name === "Error");
assert (e.message === "");
assert (e.toString() === "Error");
e = new Error("some message");
assert (e.name === "Error");
assert (e.message === "some message");
assert (e.toString() === "Error: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (Error.prototype.toString !== Object.prototype.toString);
assert (Error.prototype.constructor === Error);
assert (Error.prototype.name === "Error");
assert (Error.prototype.message === "");
assert (Error.prototype.toString() === "Error");
/* TypeError */
e = new TypeError ();
assert (e.name === "TypeError");
assert (e.message === "");
assert (e.toString() === "TypeError");
e = new TypeError("some message");
assert (e.name === "TypeError");
assert (e.message === "some message");
assert (e.toString() === "TypeError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (TypeError.prototype.toString === Error.prototype.toString);
assert (TypeError.prototype.constructor === TypeError);
assert (TypeError.prototype.name === "TypeError");
assert (TypeError.prototype.message === "");
assert (TypeError.prototype.toString() === "TypeError");
try
{
null[1] = 'abcd';
assert (false);
}
catch (e)
{
assert(e instanceof TypeError);
assert(e instanceof Error);
assert(e instanceof Object);
assert(!(e instanceof Function));
}
/* ReferenceError */
e = new ReferenceError ();
assert (e.name === "ReferenceError");
assert (e.message === "");
assert (e.toString() === "ReferenceError");
e = new ReferenceError("some message");
assert (e.name === "ReferenceError");
assert (e.message === "some message");
assert (e.toString() === "ReferenceError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (ReferenceError.prototype.toString === Error.prototype.toString);
assert (ReferenceError.prototype.constructor === ReferenceError);
assert (ReferenceError.prototype.name === "ReferenceError");
assert (ReferenceError.prototype.message === "");
assert (ReferenceError.prototype.toString() === "ReferenceError");
try
{
var a = non_existing_variable;
assert (false);
}
catch (e)
{
assert(e instanceof ReferenceError);
assert(e instanceof Error);
assert(e instanceof Object);
assert(!(e instanceof Function));
}
/* EvalError */
e = new EvalError ();
assert (e.name === "EvalError");
assert (e.message === "");
assert (e.toString() === "EvalError");
e = new EvalError("some message");
assert (e.name === "EvalError");
assert (e.message === "some message");
assert (e.toString() === "EvalError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (EvalError.prototype.toString === Error.prototype.toString);
assert (EvalError.prototype.constructor === EvalError);
assert (EvalError.prototype.name === "EvalError");
assert (EvalError.prototype.message === "");
assert (EvalError.prototype.toString() === "EvalError");
/* RangeError */
e = new RangeError ();
assert (e.name === "RangeError");
assert (e.message === "");
assert (e.toString() === "RangeError");
e = new RangeError("some message");
assert (e.name === "RangeError");
assert (e.message === "some message");
assert (e.toString() === "RangeError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (RangeError.prototype.toString === Error.prototype.toString);
assert (RangeError.prototype.constructor === RangeError);
assert (RangeError.prototype.name === "RangeError");
assert (RangeError.prototype.message === "");
assert (RangeError.prototype.toString() === "RangeError");
/* SyntaxError */
e = new SyntaxError ();
assert (e.name === "SyntaxError");
assert (e.message === "");
assert (e.toString() === "SyntaxError");
e = new SyntaxError("some message");
assert (e.name === "SyntaxError");
assert (e.message === "some message");
assert (e.toString() === "SyntaxError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (SyntaxError.prototype.toString === Error.prototype.toString);
assert (SyntaxError.prototype.constructor === SyntaxError);
assert (SyntaxError.prototype.name === "SyntaxError");
assert (SyntaxError.prototype.message === "");
assert (SyntaxError.prototype.toString() === "SyntaxError");
/* URIError */
e = new URIError ();
assert (e.name === "URIError");
assert (e.message === "");
assert (e.toString() === "URIError");
e = new URIError("some message");
assert (e.name === "URIError");
assert (e.message === "some message");
assert (e.toString() === "URIError: some message");
e.name = "";
assert (e.toString() === "some message");
e.message = "";
assert (e.toString() === "");
assert (URIError.prototype.toString === Error.prototype.toString);
assert (URIError.prototype.constructor === URIError);
assert (URIError.prototype.name === "URIError");
assert (URIError.prototype.message === "");
assert (URIError.prototype.toString() === "URIError");

View file

@ -0,0 +1,39 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 ('abcd\
efgh' === 'abcdefgh');
assert ('\'' === "'");
assert ("\'" === "'");
assert ('\"' === '"');
assert ("\"" === '"');
//
// TODO
// Extend the test by verifying character codes after String.charCodeAt would be implemented
//
assert ((new String ('\\')).length === 1);
assert ((new String ('\b')).length === 1);
assert ((new String ('\f')).length === 1);
assert ((new String ('\n')).length === 1);
assert ((new String ('\r')).length === 1);
assert ((new String ('\t')).length === 1);
assert ((new String ('\v')).length === 1);
// 'p' is not SingleEscapeCharacter
assert ('\p' === 'p');
var v\u0061riable = 'valu\u0065';
assert (variable === 'value');

View file

@ -0,0 +1,124 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 (eval () === undefined);
assert (eval (undefined) === undefined);
assert (eval (null) === null);
assert (eval (true) === true);
assert (eval (false) === false);
assert (eval (1) === 1);
assert (eval (eval) === eval);
/* Indirect eval */
function f1()
{
var v1 = 'local value';
assert (v1 === 'local value');
assert (typeof (this.v1) === 'undefined');
r = this.eval ('var v1 = "global value";');
assert (v1 === 'local value');
assert (this.v1 === 'global value');
assert (r === undefined);
};
f1 ();
/* Direct eval from strict mode code */
function f2 (global)
{
'use strict';
var v2 = 'local value';
assert (v2 === 'local value');
assert (typeof (global.v2) === 'undefined');
r = eval ('var v2 = "global value";');
assert (v2 === 'local value');
assert (typeof (global.v2) === 'undefined');
assert (r === undefined);
try
{
eval ('arguments = 1;');
assert (false);
}
catch (e)
{
assert (e instanceof SyntaxError);
}
}
f2 (this);
var y;
for (var i = 0; i < 100; i++)
{
var r = eval ('var x =' + ' 1;');
assert (typeof (x) === 'number');
assert (r === undefined);
delete x;
assert (typeof (x) === 'undefined');
r = eval ('"use ' + 's' + 't' + 'r' + 'i' + 'c' + 't"; va' + 'r x = 1;');
assert (typeof (x) === 'undefined');
assert (r === "use strict");
y = 'str';
assert (typeof (y) === 'string');
delete y;
assert (typeof (y) === 'string');
r = eval ('var y = "another ' + 'string";');
assert (y === 'another string');
assert (r == undefined);
delete y;
assert (typeof (y) === 'string');
r = eval ('if (true) 3; else 5;');
assert (r === 3);
}
// Check SyntaxError handling
try
{
eval ('var var;');
assert (false);
}
catch (e)
{
assert (e instanceof SyntaxError);
}
try
{
eval ("v_0 = {a: Math, /[]/};");
assert (false);
}
catch(e)
{
assert (e instanceof SyntaxError);
}
// nested eval with function expressions
code = 'eval("(function (){})")';
code = "eval ('" + code + "')";
eval (code);

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
arguments = 1;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
try{}catch(arguments){};

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var a = { set a(arguments) {} };

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var arguments;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
function f(arguments) {}

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
arguments++;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
++arguments;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
delete a;

View file

@ -0,0 +1,15 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 str = '\x5t';

View file

@ -0,0 +1,15 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 str = '\u004t';

View file

@ -0,0 +1,15 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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\u0028bcd;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
eval = 1;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
try{}catch(eval){};

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var a = { set a(eval) {} };

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var eval;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
function f(eval) {}

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
eval++;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
++eval;

View file

@ -0,0 +1,19 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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.
"use strict";
(function () {
var let = 1;
})();

View file

@ -0,0 +1,26 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
a: for (var i = 0; i < 10; i++)
{
function f ()
{
for (var j = 0; n < 10; j++)
{
break a;
}
}
f ();
}

View file

@ -0,0 +1,18 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
a: a: for (var i = 0; i < 10; i++)
{
break a;
}

View file

@ -0,0 +1,18 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
for (var i = 0; i < 10; i++)
{
break a;
}

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var let = 1;

View file

@ -0,0 +1,15 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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 = {a:1, get a() {return 1}}

View file

@ -0,0 +1,15 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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 = {get a() {return undefined}, get a() {return undefined}}

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var a = {a:1, a:2};

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
var a = 07;

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
function f(a, a) {}

View file

@ -0,0 +1,20 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
// Copyright 2016 University of Szeged.
//
// 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.
label_0:
if (false)
do {
continue label_0;
} while (false);

View file

@ -0,0 +1,29 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
// Copyright 2016 University of Szeged.
//
// 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.
// Copyrnse.
'use stricto
// C_pyrnsq.
'use strictI
// Copyrnse. Functionn f_0(){
'use strictT
// Copyrnse.
'use strict)
// Copyrnse.
'use strict;

View file

@ -0,0 +1,16 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
// Copyright 2016 University of Szeged
//
// 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.
throw new SyntaxError("error");

View file

@ -0,0 +1,16 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
// Copyright 2016 University of Szeged
//
// 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.
throw 0.1234;

View file

@ -0,0 +1,16 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
// Copyright 2016 University of Szeged
//
// 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.
throw "SyntaxError"

View file

@ -0,0 +1,17 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
//
// 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.
"use strict"
with (Array) {}

View file

@ -0,0 +1,283 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
// 1.
var simple_obj = {a: 1, b: 2, c: 3, d: 4};
for (var prop_of_simple_obj in simple_obj) {
simple_obj[prop_of_simple_obj] += 4;
}
assert(simple_obj.a === 5
&& simple_obj.b === 6
&& simple_obj.c === 7
&& simple_obj.d === 8);
// 2.
for
(
var
prop_of_simple_obj in simple_obj
) {
simple_obj[prop_of_simple_obj] -= 4;
}
assert(simple_obj.a === 1
&& simple_obj.b === 2
&& simple_obj.c === 3
&& simple_obj.d === 4);
// 3.
function test() {
var cnt = 0;
for (var prop_of_simple_obj in simple_obj) {
if (prop_of_simple_obj === 'b')
continue;
cnt++;
simple_obj[prop_of_simple_obj] += 4;
}
return cnt;
}
var ret_val = test();
assert((simple_obj.a === 5
&& simple_obj.b === 2
&& simple_obj.c === 7
&& simple_obj.d == 8)
&& ret_val === 3);
// 4.
var array_obj = new Array(1, 2, 3, 4, 5, 6, 7);
var prop_of_array_obj;
array_obj.eight = 8;
for (prop_of_array_obj in array_obj) {
array_obj[prop_of_array_obj] += 1;
}
assert(array_obj[0] === 2
&& array_obj[1] === 3
&& array_obj[2] === 4
&& array_obj[3] === 5
&& array_obj[4] === 6
&& array_obj[5] === 7
&& array_obj[6] === 8
&& array_obj['eight'] === 9);
// 5.
var null_obj = null;
for (var prop_of_null_obj in null_obj) {
assert(false);
}
// 6.
var empty_object = {};
for (var prop_of_empty_object in empty_object) {
assert(false);
}
// 7.
for (var i in undefined) {
assert(false);
}
// 8.
var base_obj = {base_prop: "base"};
function constr() {
this.derived_prop = "derived";
}
constr.prototype = base_obj;
var derived_obj = new constr();
for (var prop_of_derived_obj in derived_obj) {
derived_obj[prop_of_derived_obj] += "A";
}
assert(derived_obj.base_prop === "baseA" && derived_obj.derived_prop === "derivedA");
// 9.
log = {};
count = 0;
for (i in {q : 1})
{
log [i] = true;
count++;
}
assert (count == 1 && 'q' in log);
// 10.
log = {};
count = 0;
for (i in {q : 1, p : 2, get f() { ; }, set f (v) { ; }, get t () { }, set c (v) {}})
{
log [i] = true;
count++;
}
assert (count == 5
&& 'q' in log
&& 'p' in log
&& 'f' in log
&& 't' in log
&& 'c' in log);
// 11.
log = {};
count = 0;
var a = [];
a[5] = 5;
for (var x in a)
{
log[x] = true;
count++;
}
assert (count == 1
&& '5' in log);
// 12.
log = {};
count = 0;
q = { c : 3, d : 4 };
function p_constructor ()
{
this.a = 1;
this.b = 2;
return this;
}
p_constructor.prototype = q;
p = new p_constructor ();
Object.defineProperty (p, 'h', { value : 5, enumerable : false, configurable : true });
Object.defineProperty (q, 'h', { value : 6, enumerable : true, configurable : true });
for (var i in p)
{
log[i] = true;
count++;
}
assert (count == 4
&& 'a' in log
&& 'b' in log
&& 'c' in log
&& 'd' in log);
// 13.
log = {};
count = 0;
function f()
{
var tmp = { a: 1, b: 2, c: 3, d: 4 };
return tmp;
}
for (var i in f())
{
log[i] = true;
count++;
}
assert (count == 4
&& 'a' in log
&& 'b' in log
&& 'c' in log
&& 'd' in log);
// 14.
log = {};
count = 0;
b = 'prop';
c = { prop : 1 };
Boolean.prototype.boolean_prototype_prop = 1;
for (a in b in c)
{
log[a] = true;
count++;
}
assert (count == 1
&& 'boolean_prototype_prop' in log);
// 15.
log = {};
count = 0;
for (a in 'prop' in { prop : 1 })
{
log[a] = true;
count++;
}
assert (count == 1
&& 'boolean_prototype_prop' in log);
// 16.
a = 'str';
b = {};
for ((a in b) ; ; )
{
break;
}
// 17.
log = {};
count = 0;
var base_obj = { base_prop1: "base1", base_prop2: "base2" };
function l () {
this.derived_prop1 = "derived1";
this.derived_prop2 = "derived2";
}
l.prototype = base_obj;
var derived_obj = new l();
for (var prop_of_derived_obj in derived_obj) {
delete derived_obj.derived_prop1;
delete derived_obj.derived_prop2;
delete base_obj.base_prop1;
delete base_obj.base_prop2;
log[prop_of_derived_obj] = true;
count++;
}
assert(count == 1
&& ('base_prop1' in log
|| 'base_prop2' in log
|| 'derived_prop1' in log
|| 'derived_prop2' in log));

View file

@ -0,0 +1,84 @@
// Copyright 2014-2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.
// 1.
var i = 0;
for (; i < 100; i++) {
}
assert(i == 100);
// 2.
for (var j = 0; j < 100; j++) {
}
assert(j == 100);
// 3.
for (i = 0; ; ) {
if (i == 100) {
break;
assert(false);
}
i++;
}
assert(i == 100);
// 4.
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
}
}
assert(i != 100);
assert(j != 100);
assert(i == 10);
assert(j == 10);
// 5.
s = '';
for (
var i = {x: 0};
i.x < 2
;
i.x++
)
{
s += i.x;
}
assert (s === '01');
// 6.
s = '';
for (
var i = {x: 0};
i.x < 2
;
i.x++
)
{
s += i.x;
}
assert (s === '01');
// 7.
a = [];
for (; a[0]; ) {
assert (false);
}

View file

@ -0,0 +1,55 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 f() {
return 'foo';
}
assert ((function() {
if (1 === 0) {
function f() {
return 'bar';
}
}
return f();
})() === 'bar');
function check_syntax_error (s) {
try {
eval (s);
assert (false);
}
catch (e) {
assert (e instanceof SyntaxError);
}
}
check_syntax_error ("'use strict'; function arguments () {}");
check_syntax_error ("'use strict'; var l = function arguments () {}");
check_syntax_error ("function f__strict_mode_duplicate_parameters (p, p) { 'use strict'; }");
function test_strict_mode_propagation_in_func_expr_and_getters_setters () {
var p = function () {
'use strict';
return true;
}
var o = { get prop () { 'use strict'; return true; }, set prop (v) { 'use strict'; } };
function test () {
tmp_eval = eval;
eval = tmp_eval;
}
}

View file

@ -0,0 +1,72 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function f1(x)
{
var c1 = (x >= 1);
var c2 = (x <= 10);
if (c1 === true)
{
if (c2 === true)
{
assert(t);
return;
}
}
assert(t === false);
}
var i;
var t = true;
for(i = 1; i <= 10; i++)
{
f1(i);
}
t = false;
for(i = 11; i <= 20; i++)
{
f1(i);
}
function g (p, p) {
assert (p === arguments[1]);
assert (p === 'second');
}
g ('first', 'second');
try {
f1 ({});
f1 (undefined_variable);
assert (false);
}
catch (e) {
assert (e instanceof ReferenceError);
}
function f2 ()
{
return this;
}
with ({})
{
assert (f2 () === this);
}

View file

@ -0,0 +1,134 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 f = new Function ('');
assert (f () === undefined);
var f = new Function ('"use strict"; f = undefined;');
assert (f () === undefined && f === undefined);
var f = new Function ('"use strict"; q = undefined;');
try
{
f ();
assert (false);
}
catch (e)
{
assert (e instanceof ReferenceError);
}
for (i = 1; i < 10; i ++)
{
var f = new Function ('a', 'b', 'var q = a; b++; function f (k) {return q + k + b++;}; return f;');
var fns = new Array ();
for (var n = 0; n < 10; n++)
{
var r = f (1, 7);
fns[n] = r;
var check_value = 10;
for (var m = 0; m < 100; m++)
{
var value = r (1);
assert (check_value++ === value);
}
}
var check_value = 109;
for (var n = 0; n < 11; n++)
{
for (var m = 0; m < 10; m++)
{
var value = fns [m] (m * n);
assert (value == check_value + m * n);
}
check_value++;
}
}
var f = new Function ("a,b", "c", "return a + b + c;");
assert (f (1,2,3) === 6);
f = new Function ("a,b", "c,d", "return a + b + c + d;");
assert (f (1,2,3,4) === 10);
f = new Function ("a" , "b", "c,d", "return a + b + c + d;");
assert (f (1,2,3,4) === 10);
var f = new Function (" a\t , b", "\u0020c", "return a + b + c;");
assert (f (1,2,3) === 6);
f = new Function ("a, \n b \u0020", "c \t, d\n", "return a + b + c + d;");
assert (f (1,2,3,4) === 10);
f = new Function (" a\t" , "\nb ", " \u0020c , d ", "return a + b + c + d;");
assert (f (1,2,3,4) === 10);
try
{
new Function ({
toString : function () {
throw new TypeError();
},
valueOf : function () {
throw new TypeError();
}
});
assert (false);
}
catch (e)
{
assert (e instanceof TypeError);
}
var p = { toString : function() { throw 1; } };
var body = { toString : function() { throw "body"; } };
try
{
new Function (p, body);
// Should not be reached.
assert (false);
}
catch (e)
{
assert (e === 1);
}
// Check SyntaxError handling
try
{
new Function ('var var;');
assert (false);
}
catch (e)
{
assert (e instanceof SyntaxError);
}
try
{
new Function ('a;b', 'return;');
assert (false);
}
catch (e)
{
assert (e instanceof SyntaxError);
}

View file

@ -0,0 +1,75 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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.
// See a general usage: number addition.
function addNum ()
{
var sum = 0;
for(var i = 0; i < arguments.length; i++)
{
sum += arguments[i];
}
return sum;
}
var array = [6720, 4, 42];
var obj;
obj = addNum.apply(obj, array);
assert (obj === 6766);
// If the arguments are missing.
obj = addNum.apply();
assert (obj === 0);
obj = addNum.apply(obj);
assert (obj === 0);
// If the function is a builtin.
assert (Math.min.apply(null, array) === 4);
assert (Math.max.apply(null, array) === 6720);
// If the function can't be used as caller.
try {
obj = new Function.prototype.apply();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
// If the called function throws an error.
function throwError ()
{
throw new ReferenceError ("foo");
}
try {
obj = throwError.apply(obj, array);
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
// If the array access throws an error.
Object.defineProperty(array, '0', { 'get' : function () { throw new ReferenceError ("foo"); } });
try {
obj = addNum.apply(obj, array);
assert (false);
} catch (e) {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}

View file

@ -0,0 +1,140 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 mul = function(a, b) {
return a * b;
};
var triple = mul.bind(null, 3);
delete mul;
assert (triple(20) === 60);
assert (triple.prototype === undefined);
var dupl = triple.bind({}, 2);
assert (dupl() === 6);
assert (dupl.prototype === undefined);
try {
var obj = {};
var new_func = obj.bind(null, 'foo');
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
var obj1 = {num : 36};
var f1 = function(a) {
return this.num + a;
}
var add36 = f1.bind(obj1);
assert (add36(24) === 60);
var appendfoo = f1.bind(obj1, "foo");
assert (appendfoo() === "36foo");
var f2 = function(a) {
return this.num + a.num;
}
var sum = f2.bind(obj1, obj1);
assert (sum() === 72);
function P(x, y) {
this.x = x;
this.y = y;
}
var P1 = P.bind({}, 2);
var _p1 = new P1();
assert (_p1.x === 2);
assert (_p1.y === undefined);
assert (_p1 instanceof P);
assert (_p1 instanceof P1);
var P2 = P1.bind(null);
var _p2 = new P2();
assert (_p2.x === 2);
assert (_p2.y === undefined);
_p2 = new P2(12, 60);
assert (_p2.x === 2);
assert (_p2.y === 12);
_p2 = new P2({}, 12);
assert (_p2.x === 2);
assert (Object.getPrototypeOf(_p2.y) === Object.prototype);
assert (_p2 instanceof P);
assert (_p2 instanceof P1);
assert (_p2 instanceof P2);
var P3 = P2.bind({}, 5);
var _p3 = new P3(8);
assert (_p3.x === 2);
assert (_p3.y === 5);
assert (_p3 instanceof P);
assert (_p3 instanceof P1);
assert (_p3 instanceof P2);
assert (_p3 instanceof P3);
var P4 = P.bind();
P4(4, 5);
assert (x === 4);
assert (y === 5);
var _x = x;
var _y = y;
var P5 = P.bind(undefined);
P5(5, 4);
assert (x === _y);
assert (y === _x);
var number = Number.constructor;
var bound = number.bind(null, 24);
var foo = new bound();
assert (foo() === undefined);
var number = Number;
var bound = number.bind(null, 3);
var foo = new bound();
assert (foo == 3);
assert (foo instanceof Number);
assert (foo.prototype === undefined);
var func = Number.prototype.toString.bind('foo');
assert (func instanceof Function);
try {
var math = Math.sin;
var bound = math.bind(null, 0);
var foo = new bound();
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}
var foo = function(x, y) { }
var bound = foo.bind(null);
assert(bound.length === 2);
bound = foo.bind(null, 9);
assert(bound.length === 1);
bound = foo.bind(null, 9, 8);
assert(bound.length === 0);

View file

@ -0,0 +1,28 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged
//
// 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 (Math.cos.toString() === "function(){/* ecmascript */}");
function none() { return 1; }
assert (none.toString() === "function(){/* ecmascript */}");
function single(b) { return 1; }
assert (single.toString() === "function(){/* ecmascript */}");
function multiple(a,b) { return 1; }
assert (multiple.toString() === "function(){/* ecmascript */}");
function lots(a,b,c,d,e,f,g,h,i,j,k) { return 1; }
assert (lots.toString() === "function(){/* ecmascript */}");

View file

@ -0,0 +1,33 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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 f_empty()
{
return;
}
function f_42()
{
return 42;
}
function f_expr()
{
var a = 5;
var b = 5;
return a + b;
}
assert(f_expr() === 10);
assert(f_42() === 42);

View file

@ -0,0 +1,36 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
try {
(function() {
function decl() {}
})();
decl();
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
}
try {
var o = {
get p() {
function decl() {
}
}
};
decl();
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
}

View file

@ -0,0 +1,17 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// 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.constructor === Function);
assert(Function.prototype() === undefined);
assert(Function.length === 1);

View file

@ -0,0 +1,28 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 f (arg1, arg2, arg3)
{
this.string = arg1;
this.number = arg2;
this.boolean = arg3;
}
var this_arg = {};
f.call (this_arg, 's', 1, true, null);
assert (this_arg.string === 's');
assert (this_arg.number === 1);
assert (this_arg.boolean === true);

View file

@ -0,0 +1,33 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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 = {}, obj_l;
obj_l = obj;
for (var k = 0; k < 1500; k++)
{
obj_l.prop = {};
obj_l = obj_l.prop;
}
function f (o, i) {
if (--i > 0) {
f ({a:o, b:o}, i);
}
}
for (var i = 0; i < 100; i++)
{
({} + f ({}, 12));
}

View file

@ -0,0 +1,33 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
/*
* Check that in case of 'primitive' base, 'this' argument of [[Call]] is the base value, not ToObject (base).
*/
function test_1 ()
{
'use strict';
Object.defineProperty (Number.prototype,
'getter',
{ get : function () { return this; }, configurable : true });
assert ((10).getter === 10);
assert (typeof ((10).getter) === 'number');
delete Number.prototype.getter;
}
test_1 ();

View file

@ -0,0 +1,34 @@
// Copyright 2016 Samsung Electronics Co., Ltd.
//
// 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 Box(data) {
this._data = data;
}
var box = new Box('=');
Object.defineProperty(Box.prototype, 'data', {
get: function () {
assert(this === box);
return this._data;
},
set: function (data) {
assert(this === box);
this._data = data;
}
});
assert(box.data === '=');
box.data = '+';
assert(box.data === '+');

View file

@ -0,0 +1,60 @@
// Copyright 2015 University of Szeged
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
// Escaping
assert (escape ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f") ===
"%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F");
assert (escape ("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f") ===
"%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F");
assert (escape (" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN") ===
"%20%21%22%23%24%25%26%27%28%29*+%2C-./0123456789%3A%3B%3C%3D%3E%3F@ABCDEFGHIJKLMN");
assert (escape ("OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\x7F") ===
"OPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7F");
assert (escape("\x80\x95\xaf\xfe\xff") === "%80%95%AF%FE%FF");
assert (escape("\u0100\ud800\udc00") === "%u0100%uD800%uDC00");
assert (escape({}) === "%5Bobject%20Object%5D");
assert (escape(true) === "true");
// Unescaping
assert (unescape ("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F") ===
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f");
assert (unescape("%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F") ===
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
assert (unescape("%20%21%22%23%24%25%26%27%28%29*+%2C-./0123456789%3A%3B%3C%3D%3E%3F@ABCDEFGHIJKLMN") ===
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN");
assert (unescape("OPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7F") ===
"OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\x7F");
assert (unescape("%80%95%AF%FE%FF") === "\x80\x95\xaf\xfe\xff");
assert (unescape("%ud800") === "\ud800");
assert (unescape("\ud800") === "\ud800");
assert (unescape("\ud800\udc00") === "\ud800\udc00");
assert (unescape("%ud800%udc00") === "\ud800\udc00");
assert (unescape("\ud800%udc00") === "\ud800\udc00");
assert (unescape("%ud800\udc00") === "\ud800\udc00");
assert (unescape({}) === "[object Object]");
assert (unescape(true) === "true")
assert (unescape() === "undefined");
assert (unescape(1985) === "1985");
assert (unescape("%5#%uu") === "%5#%uu");
// Inversion
var str = "\u0001\u0000\uFFFF";
assert (unescape(escape(str)) === str);

View file

@ -0,0 +1,88 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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(parseFloat("1") === 1);
assert(parseFloat("+1") === 1);
assert(parseFloat("-1") === -1);
assert(parseFloat("1.2") === 1.2);
assert(parseFloat("+1.2") === 1.2);
assert(parseFloat("-1.2") === -1.2);
assert(parseFloat("1.2e3") === 1200);
assert(parseFloat("+1.2e3") === 1200);
assert(parseFloat("-1.2e3") === -1200);
assert(parseFloat(" \n\t 1.2e3") === 1200);
assert(parseFloat("03.02e1") === 30.2);
assert(parseFloat("003.") === 3);
assert(parseFloat(".2e3") === 200);
assert(parseFloat("1.e3") === 1000);
assert(parseFloat("1.2e") === 1.2);
assert(parseFloat("1.e") === 1);
assert(parseFloat("1.e3") === 1000);
assert(parseFloat("1e3") === 1000);
assert(parseFloat("1e") === 1);
assert(parseFloat("1.2e3foo") === 1200);
assert(isNaN(parseFloat("foo1.2e3foo")));
assert(parseFloat("Infinity") === Infinity);
assert(parseFloat("-Infinity") === -Infinity);
assert(parseFloat("Infinityfoo") === Infinity);
assert(parseFloat("-Infinityfoo") === -Infinity);
assert(isNaN(parseFloat("")));
assert(isNaN(parseFloat(".")));
assert(isNaN(parseFloat("..")));
assert(isNaN(parseFloat("+")));
assert(isNaN(parseFloat("-")));
assert(isNaN(parseFloat("e")));
assert(isNaN(parseFloat("a")));
assert(isNaN(parseFloat("e+")));
assert(isNaN(parseFloat("+e-")));
assert(isNaN(parseFloat(".e")));
assert(isNaN(parseFloat(".a")));
assert(isNaN(parseFloat("e3")));
assert(isNaN(parseFloat(".e3")));
assert(parseFloat("1..2") === 1);
assert(parseFloat("1.2.3") === 1.2);
assert(parseFloat("1.2ee3") === 1.2);
assert(parseFloat("0") === 0);
assert(parseFloat(".0") === 0);
assert(parseFloat("0.e3") === 0);
assert(parseFloat("0.0e3") === 0);
assert(parseFloat("1.2eA") === 1.2);
assert(parseFloat("1.ae3") === 1);
assert(parseFloat("\u00a0\u00a01.2e3") === 1200);
assert(parseFloat("\u2029\u2029\u00a01.2e\u00D0") === 1.2);
assert(isNaN(parseFloat("\u2029\u2029\u00a0\u00D01.2e3")));
assert(parseFloat("\u2029\u2029\u00a01.\u20292e\u00D0") === 1);
assert(isNaN(parseFloat("\u2029\u2029")));
var obj = new Object();
var arr = [3,4,5];
var num = 7;
var bool = true;
var undef;
assert(isNaN(parseFloat(obj)));
assert(parseFloat(arr) === 3);
assert(parseFloat(num) === 7);
assert(isNaN(parseFloat(bool)));
assert(isNaN(parseFloat(undef)));
var obj = { toString : function () { throw new ReferenceError("foo") } };
try {
parseFloat(obj);
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
assert(e.message === "foo");
}

View file

@ -0,0 +1,80 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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(parseInt("123") === 123);
assert(parseInt("+123") === 123);
assert(parseInt("-123") === -123);
assert(parseInt("0123") === 123);
assert(parseInt(" 123") === 123);
assert(parseInt(" \n 123") === 123);
assert(parseInt(" \n 123 \t") === 123);
assert(parseInt("0x123") === 291);
assert(parseInt("0X123") === 291);
assert(parseInt("123", 4) === 27);
assert(parseInt("ABC", 16) === 2748);
assert(parseInt("12A3") === 12);
assert(parseInt("12.34") === 12);
assert(isNaN(parseInt("AB")));
assert(isNaN(parseInt("")));
assert(isNaN(parseInt("-")));
assert(isNaN(parseInt("-", 11)));
assert(parseInt("\u00a0123") === 123);
assert(parseInt("\u20291 123\u00D0") === 1);
assert(parseInt("\u00a0123", 13) === 198);
assert(parseInt("\u2029123 1\u00D0", 11) === 146);
assert(isNaN(parseInt("\u0009")));
assert(isNaN(parseInt("\u00A0")));
assert(parseInt("\u00A0\u00A0-1") === parseInt("-1"));
assert(parseInt("\u00A01") === parseInt("1"));
var bool = true;
var obj = new Object();
var num = 8;
var arr = [2,3,4];
var undef;
assert(isNaN(parseInt(bool, bool)));
assert(isNaN(parseInt(bool, obj)));
assert(isNaN(parseInt(bool, num)));
assert(isNaN(parseInt(bool, arr)));
assert(isNaN(parseInt(obj, bool)));
assert(isNaN(parseInt(obj, obj)));
assert(isNaN(parseInt(obj, num)));
assert(isNaN(parseInt(obj, arr)));
assert(isNaN(parseInt(num, bool)));
assert(parseInt(num, obj) === 8);
assert(isNaN(parseInt(num, num)));
assert(parseInt(num, arr) === 8);
assert(isNaN(parseInt(arr, bool)));
assert(parseInt(arr, obj) === 2);
assert(parseInt(arr, num) === 2);
assert(parseInt(arr, arr) === 2);
assert(isNaN(parseInt(undef, bool)));
assert(isNaN(parseInt(undef, obj)));
assert(isNaN(parseInt(undef, num)));
assert(isNaN(parseInt(undef, arr)));
var obj = { toString : function () { throw new ReferenceError("foo") } };
try {
parseInt(obj);
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
assert(e.message === "foo");
}

View file

@ -0,0 +1,133 @@
// Copyright 2015 University of Szeged
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
// URI encoding
function checkEncodeURIParseError (str)
{
try {
encodeURI (str);
assert (false);
} catch(e) {
assert(e instanceof URIError);
}
}
assert (encodeURI ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f") ===
"%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F");
assert (encodeURI ("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f") ===
"%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F");
assert (encodeURI (" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN") ===
"%20!%22#$%25&'()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMN");
assert (encodeURI ("OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\x7F") ===
"OPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7F");
assert (encodeURIComponent ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f") ===
"%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F");
assert (encodeURIComponent ("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f") ===
"%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F");
assert (encodeURIComponent (" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN") ===
"%20!%22%23%24%25%26'()*%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMN");
assert (encodeURIComponent ("OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\x7F") ===
"OPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7F");
assert (encodeURI ("\xe9") == "%C3%A9");
assert (encodeURI ("\ud7ff") == "%ED%9F%BF");
assert (encodeURI ("\ue000") == "%EE%80%80");
assert (encodeURI ("\ud800\udc00") == "%F0%90%80%80");
assert (encodeURI (String.fromCharCode(0xd800, 0xdc00)) == "%F0%90%80%80");
checkEncodeURIParseError ("\ud800");
checkEncodeURIParseError ("\udfff");
// URI decoding
function checkDecodeURIParseError (str)
{
try {
decodeURI (str);
assert (false);
} catch(e) {
assert(e instanceof URIError);
}
}
assert (decodeURI ("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F") ===
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f");
assert (decodeURI ("%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F") ===
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
assert (decodeURI ("%20%21%22%23%24%25%26%27%28%29%2a%2b%2c%2d%2e%2f") ===
" !\"%23%24%%26'()*%2b%2c-.%2f");
assert (decodeURI ("%30%31%32%33%34%35%36%37%38%39%3a%3b%3c%3d%3e%3f") ===
"0123456789%3a%3b<%3d>%3f");
assert (decodeURI ("%40%41%42%43%44%45%46%47%48%49%4a%4b%4c%4d%4e%4f") ===
"%40ABCDEFGHIJKLMNO");
assert (decodeURI ("%50%51%52%53%54%55%56%57%58%59%5a%5b%5c%5d%5e%5f") ===
"PQRSTUVWXYZ[\\]^_");
assert (decodeURI ("%60%61%62%63%64%65%66%67%68%69%6a%6b%6c%6d%6e%6f") ===
"`abcdefghijklmno");
assert (decodeURI ("%70%71%72%73%74%75%76%77%78%79%7a%7b%7c%7d%7e") ===
"pqrstuvwxyz{|}~");
assert (decodeURIComponent ("%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F") ===
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f");
assert (decodeURIComponent ("%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F") ===
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f");
assert (decodeURIComponent ("%20%21%22%23%24%25%26%27%28%29%2a%2b%2c%2d%2e%2f") ===
" !\"#$%&'()*+,-./");
assert (decodeURIComponent ("%30%31%32%33%34%35%36%37%38%39%3a%3b%3c%3d%3e%3f") ===
"0123456789:;<=>?");
assert (decodeURIComponent ("%40%41%42%43%44%45%46%47%48%49%4a%4b%4c%4d%4e%4f") ===
"@ABCDEFGHIJKLMNO");
assert (decodeURIComponent ("%50%51%52%53%54%55%56%57%58%59%5a%5b%5c%5d%5e%5f") ===
"PQRSTUVWXYZ[\\]^_");
assert (decodeURIComponent ("%60%61%62%63%64%65%66%67%68%69%6a%6b%6c%6d%6e%6f") ===
"`abcdefghijklmno");
assert (decodeURIComponent ("%70%71%72%73%74%75%76%77%78%79%7a%7b%7c%7d%7e") ===
"pqrstuvwxyz{|}~");
assert (decodeURI ("%6A%6B%6C%6D%6E%6F") === "jklmno");
assert (decodeURI ("%C3%A9") === "\xe9");
assert (decodeURI ("%e2%b1%a5") === "\u2c65");
/* assert (decodeURI ("%f0%90%90%a8") === "\ud801\udc28"); */
checkDecodeURIParseError ("13%");
checkDecodeURIParseError ("%0g");
checkDecodeURIParseError ("%1G");
checkDecodeURIParseError ("%a");
checkDecodeURIParseError ("%c1%81");
checkDecodeURIParseError ("a%80b");
checkDecodeURIParseError ("%f4%90%80%80");
checkDecodeURIParseError ("%ed%a0%80");
checkDecodeURIParseError ("%ed%b0%80");
checkDecodeURIParseError ("%fa%81%82%83%84");
checkDecodeURIParseError ("%fd%81%82%83%84%85");
// Coerce (automatic toString()) tests
assert (decodeURI ([1, 2, 3]) === "1,2,3");
assert (decodeURI ({ x:1 }) === "[object Object]");
assert (encodeURI (void 0) === "undefined");
assert (encodeURI (216.000e1) === "2160");
// Combining surrogate fragments
assert (decodeURI("\ud800\udc00 \ud800 \udc00") === "\ud800\udc00 \ud800 \udc00");
assert (decodeURI("%f0%90%80%80") === "\ud800\udc00");
assert (decodeURI("\ud800%f0%90%80%80\ud800") === "\ud800\ud800\udc00\ud800");
assert (decodeURI("\udc00%f0%90%80%80\udc00") === "\udc00\ud800\udc00\udc00");
checkDecodeURIParseError ("\ud800%ed%b0%80");
checkDecodeURIParseError ("%ed%a0%80\udc00");

View file

@ -0,0 +1,17 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// 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 (this.hasOwnProperty !== undefined);

View file

@ -0,0 +1,24 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// 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.
a = {};
a['12345']=1;
a['13345']=3;
a['sss45']=4;
a['1'] = 2;
assert (a[12345] === 1);
assert (a[1] === 2);
assert (a[13345] === 3);
assert (a['sss45'] === 4);

Some files were not shown because too many files have changed in this diff Show more