Add new runtime tests
This commit is contained in:
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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;
|
||||||
@@ -12,9 +12,20 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
var a = 1;
|
assert((1 + 2) == 3);
|
||||||
var b = 2;
|
assert((2 + 1) == 3);
|
||||||
|
assert((2 + 1) != 4);
|
||||||
|
|
||||||
assert(a+b == 3);
|
assert((7 + 7) == 14);
|
||||||
assert(b+a == 3);
|
assert((7 - 7) == 0);
|
||||||
assert(b+a != 4);
|
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);
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -13,23 +13,30 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
for (; i < 100; i++) {}
|
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++;
|
|
||||||
}
|
}
|
||||||
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 (i = 0; i < 10; i++) {
|
||||||
for (j = 0; j < 10; j++) {}
|
for (j = 0; j < 10; j++) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertEquals (i, 100);
|
assert(i != 100);
|
||||||
assertEquals (j, 100);
|
assert(j != 100);
|
||||||
|
assert(i == 10);
|
||||||
|
assert(j == 10);
|
||||||
@@ -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);
|
||||||
Reference in New Issue
Block a user