diff --git a/tests/jerry/N.arithmetics-2.js b/tests/jerry/N.arithmetics-2.js new file mode 100644 index 000000000..8d7a1e40d --- /dev/null +++ b/tests/jerry/N.arithmetics-2.js @@ -0,0 +1,38 @@ +// 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); + +c = a % b; +assert(c == 1); + +c = a++; +assert(c == 21); + +c = a--; +assert(c == 22); diff --git a/tests/jerry/N.arithmetics-bignums.js b/tests/jerry/N.arithmetics-bignums.js new file mode 100644 index 000000000..9a907dbc4 --- /dev/null +++ b/tests/jerry/N.arithmetics-bignums.js @@ -0,0 +1,24 @@ +// 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 big = 2147483646; + +big++; +assert(big == 2147483647); + +big += 1; +assert(big == 2147483648); // overflow on 32bit numbers + +big++; +assert(big == 2147483649); // overflow on 32bit numbers diff --git a/tests/jerry/N.variables.js b/tests/jerry/N.variables.js new file mode 100644 index 000000000..9a6788f02 --- /dev/null +++ b/tests/jerry/N.variables.js @@ -0,0 +1,20 @@ +// 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 real = 42; +var float = 3.14; +var integer = -4; +var exponent = 1e7; + +a = 42; diff --git a/tests/jerry/arithmetics.js b/tests/jerry/arithmetics.js index d06c7dd79..beb3bfeed 100644 --- a/tests/jerry/arithmetics.js +++ b/tests/jerry/arithmetics.js @@ -12,9 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -var a = 1; -var b = 2; +assert((1 + 2) == 3); +assert((2 + 1) == 3); +assert((2 + 1) != 4); -assert(a+b == 3); -assert(b+a == 3); -assert(b+a != 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); diff --git a/tests/jerry/assignments.js b/tests/jerry/assignments.js new file mode 100644 index 000000000..6618581d3 --- /dev/null +++ b/tests/jerry/assignments.js @@ -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); diff --git a/tests/jerry/N.for.js b/tests/jerry/for.js similarity index 68% rename from tests/jerry/N.for.js rename to tests/jerry/for.js index b4f3ff25c..fc6ff0ef8 100644 --- a/tests/jerry/N.for.js +++ b/tests/jerry/for.js @@ -13,23 +13,30 @@ // limitations under the License. var i = 0; -for (; i < 100; i++) {} -assertEquals (i, 100); - -for (var j = 0; j < 100; j++) {} -assertEquals (i, 100); - -for (i = 0;;) { - if (i == 100) { - break; - assertUnreachable (); - } - i++; +for (; i < 100; i++) { } -assertEquals (i, 100); +assert(i == 100); + +for (var j = 0; j < 100; j++) { +} +assert(j == 100); + +/* +for (i = 0; ; ) { + if (i == 100) { + break; + assert(false); + } + i++; +} +assert(i == 100); +*/ for (i = 0; i < 10; i++) { - for (j = 0; j < 10; j++) {} + for (j = 0; j < 10; j++) { + } } -assertEquals (i, 100); -assertEquals (j, 100); +assert(i != 100); +assert(j != 100); +assert(i == 10); +assert(j == 10); diff --git a/tests/jerry/relational.js b/tests/jerry/relational.js new file mode 100644 index 000000000..90a7447c9 --- /dev/null +++ b/tests/jerry/relational.js @@ -0,0 +1,20 @@ +// 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); +assert((7 < 4) == false); +assert((7 > 4) == true); +//assert((7 <= 11) == true); +//assert((7 >= 11) == false);