2018-08-20 22:16:42 -05:00
|
|
|
// 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];
|
|
|
|
|
2018-11-06 19:40:56 -06:00
|
|
|
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;
|
|
|
|
|;
|
2018-08-20 22:16:42 -05:00
|
|
|
|
|
|
|
// 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"
|
|
|
|
};
|
|
|
|
|
2018-11-06 19:40:56 -06:00
|
|
|
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;
|
|
|
|
|;
|
2018-08-20 22:16:42 -05:00
|
|
|
|
|
|
|
// Expression comparisons
|
2018-11-06 19:40:56 -06:00
|
|
|
assert |2 == 1+1;|;
|
|
|
|
assert |(1+1) == 2;|;
|
|
|
|
assert |(1+1) == (1+1);|;
|
2018-08-20 22:16:42 -05:00
|
|
|
let want = "foo";
|
2018-11-06 19:40:56 -06:00
|
|
|
assert |
|
|
|
|
select want, 1, { foo=2, } == 2;
|
|
|
|
|;
|