diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-07-11 16:05:54 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-07-11 16:05:54 -0400 |
| commit | 4153c0af9d4dcc43c0a67cc446a313c46ee5ac33 (patch) | |
| tree | 246154cdf41f487f6d2da2c6b6df5aba50531ab6 /test | |
| parent | a51d48201b5245dc2cc2bfb00e0ac8e7b52203d9 (diff) | |
| parent | 46b0dbc5a448249ddc9a6ce20465f0fa41de6d64 (diff) | |
Merge branch 'main' into decimalsdecimals
Diffstat (limited to 'test')
| -rw-r--r-- | test/enums.tm | 6 | ||||
| -rw-r--r-- | test/functions.tm | 6 | ||||
| -rw-r--r-- | test/integers.tm | 6 | ||||
| -rw-r--r-- | test/lists.tm | 6 | ||||
| -rw-r--r-- | test/nums.tm | 33 | ||||
| -rw-r--r-- | test/optionals.tm | 6 | ||||
| -rw-r--r-- | test/paths.tm | 12 | ||||
| -rw-r--r-- | test/serialization.tm | 47 | ||||
| -rw-r--r-- | test/structs.tm | 24 | ||||
| -rw-r--r-- | test/tables.tm | 6 | ||||
| -rw-r--r-- | test/text.tm | 21 |
11 files changed, 58 insertions, 115 deletions
diff --git a/test/enums.tm b/test/enums.tm index 901298a8..080e5d97 100644 --- a/test/enums.tm +++ b/test/enums.tm @@ -29,8 +29,7 @@ func main() >> one.Two = no - >> Foo.One(10) == Foo.One(10) - = yes + assert Foo.One(10) == Foo.One(10) >> Foo.One(10) == Foo.Zero = no @@ -38,8 +37,7 @@ func main() >> Foo.One(10) == Foo.One(-1) = no - >> Foo.One(10) < Foo.Two(1, 2) - = yes + assert Foo.One(10) < Foo.Two(1, 2) >> x := Foo.One(123) >> t := |x| diff --git a/test/functions.tm b/test/functions.tm index 17ca1e85..7ceca977 100644 --- a/test/functions.tm +++ b/test/functions.tm @@ -8,8 +8,6 @@ func main() >> add(3, 5) = 8 - >> cached_heap(1) == cached_heap(1) - = yes - >> cached_heap(1) == cached_heap(2) - = no + assert cached_heap(1) == cached_heap(1) + assert cached_heap(1) != cached_heap(2) diff --git a/test/integers.tm b/test/integers.tm index 3035ad3b..ee560952 100644 --- a/test/integers.tm +++ b/test/integers.tm @@ -85,8 +85,7 @@ func main() interesting_denominators := [-99, -20, -17, -1, 1, 17, 20, 99] for n in interesting_numerators for d in interesting_denominators - >> (n/d)*d + (n mod d) == n - = yes + assert (n/d)*d + (n mod d) == n >> (0).next_prime() = 2 @@ -94,7 +93,7 @@ func main() = 11 #>> (11).prev_prime() #= 7 - >> (and: p.is_prime() for p in [ + assert (and: p.is_prime() for p in [ 2, 3, 5, 7, 137372146048179869781170214707, 811418847921670560768224995279, @@ -107,7 +106,6 @@ func main() 121475876690852432982324195553, 771958616175795150904761471637, ])! - = yes >> (or: p.is_prime() for p in [ -1, 0, 1, 4, 6, diff --git a/test/lists.tm b/test/lists.tm index 6281532c..fef23f5d 100644 --- a/test/lists.tm +++ b/test/lists.tm @@ -111,16 +111,14 @@ func main() heap_order : @[Int] repeat heap_order.insert(heap.heap_pop() or stop) - >> heap_order[] == heap_order.sorted() - = yes + assert heap_order[] == heap_order.sorted() heap_order[] = [] for i in 10 heap.heap_push((i*13337) mod 37) >> heap repeat heap_order.insert(heap.heap_pop() or stop) - >> heap_order[] == heap_order.sorted() - = yes + assert heap_order[] == heap_order.sorted() do >> [i*10 for i in 5].from(3) diff --git a/test/nums.tm b/test/nums.tm index 3653f18a..362f590f 100644 --- a/test/nums.tm +++ b/test/nums.tm @@ -19,29 +19,20 @@ func main() >> Num.INF = Num.INF - >> Num.INF.isinf() - = yes + assert Num.INF.isinf() >> none_num : Num? = none = none - >> none_num == none_num - = yes - >> none_num < none_num - = no - >> none_num > none_num - = no - >> none_num != none_num - = no + assert none_num == none_num + assert (none_num < none_num) == no + assert (none_num > none_num) == no + assert (none_num != none_num) == no >> none_num <> none_num = Int32(0) - >> none_num == 0.0 - = no - >> none_num < 0.0 - = yes - >> none_num > 0.0 - = no - >> none_num != 0.0 - = yes + assert (none_num == 0.0) == no + assert none_num < 0.0 + assert (none_num > 0.0) == no + assert none_num != 0.0 >> none_num <> 0.0 = Int32(-1) @@ -53,10 +44,8 @@ func main() # >> 0./0. # = none - >> Num.PI.cos()!.near(-1) - = yes - >> Num.PI.sin()!.near(0) - = yes + assert Num.PI.cos()!.near(-1) + assert Num.PI.sin()!.near(0) >> Num.INF.near(-Num.INF) = no diff --git a/test/optionals.tm b/test/optionals.tm index 8e075855..7bdd2fd1 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -241,10 +241,8 @@ func main() = 123 # Test comparisons, hashing, equality: - >> (none == 5?) - = no - >> (5? == 5?) - = yes + assert none != 5? + assert 5? == 5? >> nones : |Int?| = |none, none| >> also_nones : |Int?| = |none| >> nones == also_nones diff --git a/test/paths.tm b/test/paths.tm index 14a15299..d92d4623 100644 --- a/test/paths.tm +++ b/test/paths.tm @@ -1,9 +1,7 @@ # Tests for file paths func main() - >> (/).exists() - = yes - >> (~/).exists() - = yes + assert (/).exists() + assert (~/).exists() >> (~/Downloads/file(1).txt) = (~/Downloads/file(1).txt) @@ -16,8 +14,7 @@ func main() = (~/example.txt) >> tmpdir := (/tmp/tomo-test-path-XXXXXX).unique_directory() - >> (/tmp).subdirectories().has(tmpdir) - = yes + assert (/tmp).subdirectories().has(tmpdir) >> tmpfile := (tmpdir++(./one.txt)) >> tmpfile.write("Hello world") @@ -26,8 +23,7 @@ func main() = "Hello world!"? >> tmpfile.read_bytes()! = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21] - >> tmpdir.files().has(tmpfile) - = yes + assert tmpdir.files().has(tmpfile) if tmp_lines := tmpfile.by_line() then >> [line for line in tmp_lines] diff --git a/test/serialization.tm b/test/serialization.tm index 12917f98..8e1a4a1c 100644 --- a/test/serialization.tm +++ b/test/serialization.tm @@ -7,39 +7,32 @@ func main() do >> obj := Int64(123) >> bytes := obj.serialized() - >> deserialize(bytes -> Int64) == obj - = yes + assert deserialize(bytes -> Int64) == obj do >> obj := 5 >> bytes := obj.serialized() - >> deserialize(bytes -> Int) == obj - = yes + assert deserialize(bytes -> Int) == obj do >> obj := 9999999999999999999999999999999999999999999999999999 >> bytes := obj.serialized() - >> deserialize(bytes -> Int) == obj - = yes + assert deserialize(bytes -> Int) == obj do >> obj := "Héllo" >> bytes := obj.serialized() - >> deserialize(bytes -> Text) - >> deserialize(bytes -> Text) == obj - = yes + assert deserialize(bytes -> Text) == obj do >> obj := [Int64(10), Int64(20), Int64(30)].reversed() >> bytes := obj.serialized() - >> deserialize(bytes -> [Int64]) == obj - = yes + assert deserialize(bytes -> [Int64]) == obj do >> obj := yes >> bytes := obj.serialized() - >> deserialize(bytes -> Bool) == obj - = yes + assert deserialize(bytes -> Bool) == obj do >> obj := @[10, 20] @@ -47,52 +40,44 @@ func main() >> roundtrip := deserialize(bytes -> @[Int]) >> roundtrip == obj = no - >> roundtrip[] == obj[] - = yes + assert roundtrip[] == obj[] do >> obj := {"A"=10, "B"=20; fallback={"C"=30}} >> bytes := obj.serialized() >> roundtrip := deserialize(bytes -> {Text=Int}) - >> roundtrip == obj - = yes - >> roundtrip.fallback == obj.fallback - = yes + assert roundtrip == obj + assert roundtrip.fallback == obj.fallback do >> obj := @Foo("root") >> obj.next = @Foo("abcdef", next=obj) >> bytes := obj.serialized() - >> deserialize(bytes -> @Foo) - # = @Foo(name="root", next=@Foo(name="abcdef", next=@~1)) + >> roundtrip := deserialize(bytes -> @Foo) + assert "$roundtrip" == "$obj" do >> obj := MyEnum.Two(123, "OKAY") >> bytes := obj.serialized() - >> deserialize(bytes -> MyEnum) == obj - = yes + assert deserialize(bytes -> MyEnum) == obj do >> obj := "Hello"? >> bytes := obj.serialized() - >> deserialize(bytes -> Text?) == obj - = yes + assert deserialize(bytes -> Text?) == obj do >> obj := |10, 20, 30| >> bytes := obj.serialized() - >> deserialize(bytes -> |Int|) == obj - = yes + assert deserialize(bytes -> |Int|) == obj do >> obj : Num? = none >> bytes := obj.serialized() - >> deserialize(bytes -> Num?) == obj - = yes + assert deserialize(bytes -> Num?) == obj do cases := [0, -1, 1, 10, 100000, 999999999999999999999999999] for i in cases >> bytes := i.serialized() - >> deserialize(bytes -> Int) == i - = yes + assert deserialize(bytes -> Int) == i diff --git a/test/structs.tm b/test/structs.tm index c340f1c9..a58a9ef7 100644 --- a/test/structs.tm +++ b/test/structs.tm @@ -15,23 +15,18 @@ func test_literals() = Pair(x=10, y=20) >> y := Pair(y=20, 10) = Pair(x=10, y=20) - >> x == y - = yes - >> x == Pair(-1, -2) - = no + assert x == y + assert x != Pair(-1, -2) func test_metamethods() >> x := Pair(10, 20) >> y := Pair(100, 200) >> x == y = no - >> x == Pair(10, 20) - = yes - >> x == Pair(10, 30) - = no + assert x == Pair(10, 20) + assert x != Pair(10, 30) - >> x < Pair(11, 20) - = yes + assert x < Pair(11, 20) >> set := |x| >> set.has(x) = yes @@ -43,12 +38,9 @@ func test_mixed() >> y := Mixed(99, "Hello") >> x == y = no - >> x == Mixed(10, "Hello") - = yes - >> x == Mixed(10, "Bye") - = no - >> x < Mixed(11, "Hello") - = yes + assert x == Mixed(10, "Hello") + assert x != Mixed(10, "Bye") + assert x < Mixed(11, "Hello") >> set := |x| >> set.has(x) = yes diff --git a/test/tables.tm b/test/tables.tm index 9419d875..2254a7a0 100644 --- a/test/tables.tm +++ b/test/tables.tm @@ -89,10 +89,8 @@ func main() = &{"one"=999, "two"=222} do - >> {1=1, 2=2} == {2=2, 1=1} - = yes - >> {1=1, 2=2} == {1=1, 2=999} - = no + assert {1=1, 2=2} == {2=2, 1=1} + assert {1=1, 2=2} != {1=1, 2=999} >> {1=1, 2=2} <> {2=2, 1=1} = Int32(0) diff --git a/test/text.tm b/test/text.tm index 9634f17d..ff55555d 100644 --- a/test/text.tm +++ b/test/text.tm @@ -46,8 +46,7 @@ func main() >> "\[31;1]" = "\e[31;1m" - >> "\{UE9}" == "\{U65}\{U301}" - = yes + assert "\{UE9}" == "\{U65}\{U301}" amelie := "Am\{UE9}lie" >> amelie.split() @@ -120,12 +119,9 @@ func main() c := "É̩" >> c.codepoint_names() = ["LATIN CAPITAL LETTER E WITH ACUTE", "COMBINING VERTICAL LINE BELOW"] - >> c == Text.from_codepoint_names(c.codepoint_names())! - = yes - >> c == Text.from_codepoints(c.utf32_codepoints()) - = yes - >> c == Text.from_bytes(c.bytes())! - = yes + assert c == Text.from_codepoint_names(c.codepoint_names())! + assert c == Text.from_codepoints(c.utf32_codepoints()) + assert c == Text.from_bytes(c.bytes())! >> "one\ntwo\nthree".lines() = ["one", "two", "three"] @@ -248,8 +244,7 @@ func main() b := Text.from_codepoint_names(["COMBINING VERTICAL LINE BELOW"])! >> (a++b).codepoint_names() = ["LATIN SMALL LETTER E", "COMBINING VERTICAL LINE BELOW"] - >> (a++b) == ab - = yes + assert (a++b) == ab >> (a++b).length = 1 @@ -270,14 +265,12 @@ func main() final := Text.from_codepoints([Int32(0x65), Int32(0x300), Int32(0x302), Int32(0x303)]) >> final.length = 1 - >> concat3 == final - = yes + assert concat3 == final concat4 := Text.from_codepoints([Int32(0x65), Int32(0x300)]) ++ Text.from_codepoints([Int32(0x302), Int32(0x303)]) >> concat4.length = 1 - >> concat4 == final - = yes + assert concat4 == final >> "x".left_pad(5) = " x" |
