• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15var a = 21;
16var b = 10;
17var c;
18
19c = a + b;
20assert(c == 31);
21
22c = a - b;
23assert(c == 11);
24
25c = a * b;
26assert(c == 210);
27
28c = a / b;
29assert(c >= 2.1 - 0.000001 && c <= 2.1 + 0.000001);
30
31c = a % b;
32assert(c == 1);
33
34c = a++;
35assert(c == 21);
36
37c = a--;
38assert(c == 22);
39
40var o = { p : 1 };
41
42assert (++o.p === 2);
43assert (o.p === 2);
44assert (--o.p === 1);
45assert (o.p === 1);
46
47try {
48  eval ('++ ++ a');
49  assert (false);
50}
51catch (e) {
52  assert (e instanceof ReferenceError);
53}
54
55assert (0.1 + 0.2 != 0.3);
56