mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
Slight change to how assert works to support this. We no longer automatically add a semicolon to the expressions we require the user to right them. This updates the docs to illustrate that and reformats our integration test suite for this and readability.
90 lines
1.1 KiB
Plaintext
90 lines
1.1 KiB
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;
|
|
|; |