ucg/integration_tests/comparisons_test.ucg
Jeremy Wall b87d75c5c7 TESTS: Add a whole raft of integration tests.
* Integrate them into the build::comopile_test module as well.
2018-08-20 22:16:42 -05:00

56 lines
1006 B
Plaintext

// Simple Comparisons
let one = 1;
let two = 2;
let foo = "foo";
let bar = "bar";
let tpl1 = {
foo = "bar",
one = 1
};
let tpl2 = tpl1{};
let tpl3 = {
bar = "foo",
two = 1
};
let list = [1, 2, 3];
let list2 = list;
let list3 = [1, 2];
assert "one == one";
assert "one == one";
assert "one >= one";
assert "two > one";
assert "two >= two";
assert "tpl1 == tpl2";
assert "tpl1 != tpl3";
assert "list == list2";
assert "list != list3";
// Deep Comparisons
let tpl4 = {
foo = "bar",
lst = [1, 2, 3],
inner = {
fld = "value",
}
};
let copy = tpl4;
let extra = tpl4{one = 1};
let less = {
foo = "bar"
};
assert "tpl4.inner == copy.inner";
assert "tpl4.inner.fld == copy.inner.fld";
assert "tpl4.lst == copy.lst";
assert "tpl4.foo == copy.foo";
assert "tpl4 == copy";
assert "tpl4 != extra";
assert "tpl4 != less";
// Expression comparisons
assert "2 == 1+1";
assert "(1+1) == 2";
assert "(1+1) == (1+1)";
let want = "foo";
assert "select want, 1, { foo=2, } == 2";