diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/arrays.tm | 46 | ||||
| -rw-r--r-- | test/optionals.tm | 8 |
2 files changed, 27 insertions, 27 deletions
diff --git a/test/arrays.tm b/test/arrays.tm index 8122106c..71e107ef 100644 --- a/test/arrays.tm +++ b/test/arrays.tm @@ -8,42 +8,42 @@ func main() = [] do - >> arr := [10, 20, 30] + >> list := [10, 20, 30] = [10, 20, 30] - >> arr[1] + >> list[1] = 10 - >> arr[-1] + >> list[-1] = 30 - >> arr.length + >> list.length = 3 sum := 0 - for x in arr + for x in list sum += x >> sum = 60 str := "" - for i,x in arr + for i,x in list str ++= "($i,$x)" >> str = "(1,10)(2,20)(3,30)" do - >> arr := [10, 20] ++ [30, 40] + >> list := [10, 20] ++ [30, 40] = [10, 20, 30, 40] - >> arr ++= [50, 60] - >> arr + >> list ++= [50, 60] + >> list = [10, 20, 30, 40, 50, 60] do - >> arr := [10, 20] - >> copy := arr - >> arr ++= [30] - >> arr + >> list := [10, 20] + >> copy := list + >> list ++= [30] + >> list = [10, 20, 30] >> copy = [10, 20] @@ -62,24 +62,24 @@ func main() = [2, 3, 2, 3, 4] do - >> arr := @[10, 20] - >> copy := arr[] - >> arr.insert(30) - >> arr + >> list := @[10, 20] + >> copy := list[] + >> list.insert(30) + >> list = @[10, 20, 30] >> copy = [10, 20] - >> arr[1] = 999 - >> arr + >> list[1] = 999 + >> list = @[999, 20, 30] do - >> arr := &[10, 20, 30] - >> reversed := arr.reversed() + >> list := &[10, 20, 30] + >> reversed := list.reversed() = [30, 20, 10] # Ensure the copy-on-write behavior triggers: - >> arr[1] = 999 + >> list[1] = 999 >> reversed = [30, 20, 10] @@ -148,7 +148,7 @@ func main() >> [i*10 for i in 10].by(2).by(-1) = [90, 70, 50, 30, 10] - # Test iterating over array.from() and array.to() + # Test iterating over list.from() and list.to() xs := ["A", "B", "C", "D"] for i,x in xs.to(-2) for y in xs.from(i+1) diff --git a/test/optionals.tm b/test/optionals.tm index 36f38625..50e700f1 100644 --- a/test/optionals.tm +++ b/test/optionals.tm @@ -25,7 +25,7 @@ func maybe_int64(should_i:Bool->Int64?) else return none -func maybe_array(should_i:Bool->[Int]?) +func maybe_list(should_i:Bool->[Int]?) if should_i return [10, 20, 30] else @@ -114,10 +114,10 @@ func main() else say("Falsey: $nope") do - say("Arrays:") - >> yep := maybe_array(yes) + say("Lists:") + >> yep := maybe_list(yes) = [10, 20, 30]? - >> nope := maybe_array(no) + >> nope := maybe_list(no) = none >> if yep >> yep |
