From 52e50e58c6674560056a4dcb787099d739284b02 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 6 Apr 2025 16:34:23 -0400 Subject: Change Set syntax from {x} to |x| --- test/enums.tm | 2 +- test/optionals.tm | 4 ++-- test/serialization.tm | 4 ++-- test/sets.tm | 31 +++++++++++++++++-------------- test/structs.tm | 4 ++-- test/tables.tm | 4 ++-- 6 files changed, 26 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/test/enums.tm b/test/enums.tm index a11f95f9..cbea69f5 100644 --- a/test/enums.tm +++ b/test/enums.tm @@ -42,7 +42,7 @@ func main(): = yes >> x := Foo.One(123) - >> t := {x} + >> t := |x| >> t.has(x) = yes >> t.has(Foo.Zero) diff --git a/test/optionals.tm b/test/optionals.tm index bf3e1633..40512557 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -245,8 +245,8 @@ func main(): = no >> (5? == 5?) = yes - >> nones : {Int?} = {none, none} - >> also_nones : {Int?} = {none} + >> nones : |Int?| = |none, none| + >> also_nones : |Int?| = |none| >> nones == also_nones >> [5?, none, none, 6?].sorted() = [none, none, 5, 6] diff --git a/test/serialization.tm b/test/serialization.tm index b3ccc67a..a09cf2f9 100644 --- a/test/serialization.tm +++ b/test/serialization.tm @@ -76,9 +76,9 @@ func main(): = yes do: - >> obj := {10, 20, 30} + >> obj := |10, 20, 30| >> bytes := obj.serialized() - >> deserialize(bytes -> {Int}) == obj + >> deserialize(bytes -> |Int|) == obj = yes do: diff --git a/test/sets.tm b/test/sets.tm index 5179947e..058c1218 100644 --- a/test/sets.tm +++ b/test/sets.tm @@ -1,39 +1,42 @@ func main(): - >> t1 := @{10, 20, 30, 10} - = @{10, 20, 30} + >> t1 := @|10, 20, 30, 10| + = @|10, 20, 30| >> t1.has(10) = yes >> t1.has(-999) = no - >> t2 := {30, 40} + >> t2 := |30, 40| >> t1.with(t2) - >> {10, 20, 30, 40} + >> |10, 20, 30, 40| >> t1.without(t2) - >> {10, 20} + >> |10, 20| >> t1.overlap(t2) - >> {30} + >> |30| - >> {1,2}.is_subset_of({2,3}) + >> |1,2|.is_subset_of(|2,3|) = no - >> {1,2}.is_subset_of({1,2,3}) + >> |1,2|.is_subset_of(|1,2,3|) = yes - >> {1,2}.is_subset_of({1,2}) + >> |1,2|.is_subset_of(|1,2|) = yes - >> {1,2}.is_subset_of({1,2}, strict=yes) + >> |1,2|.is_subset_of(|1,2|, strict=yes) = no >> t1.add_all(t2) >> t1 - = @{10, 20, 30, 40} + = @|10, 20, 30, 40| >> t1.remove_all(t2) >> t1 - = @{10, 20} + = @|10, 20| - >> {3, i for i in 5} - = {3, 1, 2, 4, 5} + >> |3, i for i in 5| + = |3, 1, 2, 4, 5| + + >> empty : |Int| = || + = || diff --git a/test/structs.tm b/test/structs.tm index cf7b6a1c..2b1ff910 100644 --- a/test/structs.tm +++ b/test/structs.tm @@ -32,7 +32,7 @@ func test_metamethods(): >> x < Pair(11, 20) = yes - >> set := {x} + >> set := |x| >> set.has(x) = yes >> set.has(y) @@ -49,7 +49,7 @@ func test_mixed(): = no >> x < Mixed(11, "Hello") = yes - >> set := {x} + >> set := |x| >> set.has(x) = yes >> set.has(y) diff --git a/test/tables.tm b/test/tables.tm index a5f51520..41d041eb 100644 --- a/test/tables.tm +++ b/test/tables.tm @@ -99,8 +99,8 @@ func main(): >> ints : [{Int=Int}] = [{}, {0=0}, {99=99}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 2=-99, 3=3}, {1=1, 99=-99, 3=4}].sorted() = [{}, {0=0}, {1=1, 2=-99, 3=3}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 99=-99, 3=4}, {99=99}] - >> other_ints : [{Int}] = [{/}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}].sorted() - = [{/}, {0, 3}, {1}, {1, 2}, {2}, {99}, {99}] + >> other_ints : [|Int|] = [||, |1|, |2|, |99|, |0, 3|, |1, 2|, |99|].sorted() + = [||, |0, 3|, |1|, |1, 2|, |2|, |99|, |99|] do: # Default values: -- cgit v1.2.3