gux/tests/builtins.gux

68 lines
1.2 KiB
Plaintext

############
# BOOLEANS #
############
assert true;
assert !false;
assert !!true;
assert true && true;
assert !(true && false);
assert !(false && true);
assert !(false && false);
assert true || true;
assert true || false;
assert false || true;
assert !(false || false);
assert true == true;
assert false == false;
assert true != false;
assert false != true;
############
# INTEGERS #
############
assert 5 == 5;
assert 5 != 2;
assert 1 + 2 == 3;
assert 1 + -2 == -1;
assert 1 - 2 == -1;
assert 1 - -2 == 3;
assert 3 * 6 == 18;
assert 12 / 2 == 6;
assert 3 / 2 == 1;
assert 12 % 7 == 5;
assert 2 ** 3 == 8;
assert 1 + 2 * 3 == 7;
assert (1 + 2) * 3 == 9;
#########
# FLOAT #
#########
assert 2.3 == 2.3;
assert 2.3 != 2.4;
assert 1.0 + 2.0 == 3.0;
assert 1.0 + -2.0 == -1.0;
assert 1.0 - 2.0 == -1.0;
assert 1.0 - -2.0 == 3.0;
assert 3.0 * 6.0 == 18.0;
assert 12.0 / 2.0 == 6.0;
assert 3.0 / 2.0 == 1.5;
assert 12.0 % 7.0 == 5.0;
assert 2.0 ** 3.0 == 8.0;
###########
# STRINGS #
###########
assert "hello" == "hello";
assert "hello" != "world";
assert 3 * "a" == "aaa";
assert "a" * 3 == "aaa";
assert "a" + "b" == "ab";
assert 2 * "a" + "b" == "aab";
assert 2 * ("a" + 3 * "b") == "abbbabbb";