mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
42 lines
1.0 KiB
ChaiScript
42 lines
1.0 KiB
ChaiScript
auto i = 1;
|
|
auto j = 2;
|
|
auto k = 3;
|
|
|
|
assert_equal(3, i + j);
|
|
assert_equal(1, +i);
|
|
assert_equal(-1, i - j);
|
|
assert_equal(-1, -i);
|
|
assert_equal(2, j & k);
|
|
assert_equal(-3, ~j);
|
|
assert_equal(1, j ^ k);
|
|
assert_equal(3, i | j);
|
|
assert_equal(2, j / i);
|
|
assert_equal(4, i << j);
|
|
assert_equal(6, j * k);
|
|
assert_equal(1, k % j);
|
|
assert_equal(1, j >> i);
|
|
|
|
assert_equal(0, i &= 2);
|
|
assert_equal(1, j ^= 3);
|
|
assert_equal(3, j |= 2);
|
|
assert_equal(-1, i -= 1);
|
|
assert_equal(6, j <<= 1);
|
|
assert_equal(12, j *= 2);
|
|
assert_equal(6, j /= 2);
|
|
assert_equal(2, j %= 4);
|
|
assert_equal(1, j >>= 1);
|
|
assert_equal(2, j += 1);
|
|
assert_equal(1, --j);
|
|
assert_equal(2, ++j);
|
|
|
|
|
|
assert_throws("Error: \"Error with prefix operator evaluation: cannot modify constant value.\"", fun() { ++4; });
|
|
assert_throws("Error: \"Error with prefix operator evaluation: cannot modify constant value.\"", fun() { --4; });
|
|
|
|
assert_throws("Error: \"Error, cannot assign to constant value.\"", fun() { 5 = 5; });
|
|
assert_throws("Error: \"Error, cannot assign to constant value.\"", fun() { int(5) = 5; });
|
|
|
|
|
|
|
|
|