aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-21 13:00:53 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-21 13:00:53 -0500
commitf868d02b08688c04509d1abda5af89a182033d88 (patch)
treeaf64c48127e0edfebb348edabbccbcc402d2070b /test
parent90573ba7a15bb47a11c1eb6f69ed04c01b69724d (diff)
Add `NULL` as a syntax for null values.
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm8
-rw-r--r--test/optionals.tm56
-rw-r--r--test/paths.tm10
-rw-r--r--test/reductions.tm10
-rw-r--r--test/structs.tm2
-rw-r--r--test/tables.tm16
-rw-r--r--test/text.tm20
7 files changed, 61 insertions, 61 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index 7fa1ef62..a6de26ce 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -164,11 +164,11 @@ func main():
= [1, 2, 3, 4, 5]
>> ["a", "b", "c"]:find("b")
- = 2?
+ = 2 : Int?
>> ["a", "b", "c"]:find("XXX")
- = !Int
+ = NULL : Int?
>> [10, 20]:first(func(i:&Int): i:is_prime())
- = !Int
+ = NULL : Int?
>> [4, 5, 6]:first(func(i:&Int): i:is_prime())
- = 2?
+ = 2 : Int?
diff --git a/test/optionals.tm b/test/optionals.tm
index eba1a685..8efae414 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -4,7 +4,7 @@ struct Struct(x:Int, y:Text):
if should_i:
return Struct(123, "hello")
else:
- return !Struct
+ return NULL
enum Enum(X, Y(y:Int)):
func maybe(should_i:Bool->Enum?):
@@ -75,13 +75,13 @@ func maybe_thread(should_i:Bool->Thread?):
func main():
>> 5?
- = 5? : Int?
+ = 5 : Int?
>> if no:
!Int
else:
5
- = 5? : Int?
+ = 5 : Int?
>> 5? or -1
= 5 : Int
@@ -98,9 +98,9 @@ func main():
do:
!! Ints:
>> yep := maybe_int(yes)
- = 123?
+ = 123 : Int?
>> nope := maybe_int(no)
- = !Int
+ = NULL : Int?
>> if yep:
>> yep
= 123
@@ -113,9 +113,9 @@ func main():
!! ...
!! Int64s:
>> yep := maybe_int64(yes)
- = 123?
+ = 123 : Int64?
>> nope := maybe_int64(no)
- = !Int64
+ = NULL : Int64?
>> if yep:
>> yep
= 123
@@ -128,9 +128,9 @@ func main():
!! ...
!! Arrays:
>> yep := maybe_array(yes)
- = [10, 20, 30]?
+ = [10, 20, 30] : [Int]?
>> nope := maybe_array(no)
- = ![Int]
+ = NULL : [Int]?
>> if yep:
>> yep
= [10, 20, 30]
@@ -143,9 +143,9 @@ func main():
!! ...
!! Bools:
>> yep := maybe_bool(yes)
- = no?
+ = no : Bool?
>> nope := maybe_bool(no)
- = !Bool
+ = NULL : Bool?
>> if yep:
>> yep
= no
@@ -158,9 +158,9 @@ func main():
!! ...
!! Text:
>> yep := maybe_text(yes)
- = "Hello"?
+ = "Hello" : Text?
>> nope := maybe_text(no)
- = !Text
+ = NULL : Text?
>> if yep:
>> yep
= "Hello"
@@ -173,9 +173,9 @@ func main():
!! ...
!! Nums:
>> yep := maybe_num(yes)
- = 12.3?
+ = 12.3 : Num?
>> nope := maybe_num(no)
- = !Num
+ = NULL : Num?
>> if yep:
>> yep
= 12.3
@@ -188,9 +188,9 @@ func main():
!! ...
!! Lambdas:
>> yep := maybe_lambda(yes)
- = func() [optionals.tm:54]?
+ = func() [optionals.tm:54] : func()?
>> nope := maybe_lambda(no)
- = !func()
+ = NULL : func()?
>> if yep:
>> yep
= func() [optionals.tm:54]
@@ -203,9 +203,9 @@ func main():
!! ...
!! Structs:
>> yep := Struct.maybe(yes)
- = Struct(x=123, y="hello")?
+ = Struct(x=123, y="hello") : Struct?
>> nope := Struct.maybe(no)
- = !Struct
+ = NULL : Struct?
>> if yep:
>> yep
= Struct(x=123, y="hello")
@@ -218,9 +218,9 @@ func main():
!! ...
!! Enums:
>> yep := Enum.maybe(yes)
- = Enum.Y(123)?
+ = Enum.Y(123) : Enum?
>> nope := Enum.maybe(no)
- = !Enum
+ = NULL : Enum?
>> if yep:
>> yep
= Enum.Y(123)
@@ -233,9 +233,9 @@ func main():
!! ...
!! C Strings:
>> yep := maybe_c_string(yes)
- = CString("hi")?
+ = CString("hi") : CString?
>> nope := maybe_c_string(no)
- = !CString
+ = NULL : CString?
>> if yep:
>> yep
= CString("hi")
@@ -250,7 +250,7 @@ func main():
>> yep := maybe_channel(yes)
# No "=" test here because channels use addresses in the text version
>> nope := maybe_channel(no)
- = !|:Int|
+ = NULL : |:Int|?
>> if yep: >> yep
else: fail("Falsey: $yep")
>> if nope:
@@ -263,7 +263,7 @@ func main():
>> yep := maybe_thread(yes)
# No "=" test here because threads use addresses in the text version
>> nope := maybe_thread(no)
- = !Thread
+ = NULL : Thread?
>> if yep: >> yep
else: fail("Falsey: $yep")
>> if nope:
@@ -284,9 +284,9 @@ func main():
>> (5? == 5?)
= yes
>> {!Int, !Int}
- = {!Int}
+ = {NULL}
>> [5?, !Int, !Int, 6?]:sorted()
- = [!Int, !Int, 5?, 6?]
+ = [NULL, NULL, 5, 6]
do:
>> value := if var := 5?:
@@ -323,4 +323,4 @@ func main():
= yes
>> [Struct(5,"A")?, Struct(6,"B"), Struct(7,"C")]
- = [Struct(x=5, y="A")?, Struct(x=6, y="B")?, Struct(x=7, y="C")?]
+ = [Struct(x=5, y="A"), Struct(x=6, y="B"), Struct(x=7, y="C")]
diff --git a/test/paths.tm b/test/paths.tm
index 5e901453..62cecec6 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -23,9 +23,9 @@ func main():
>> tmpfile:write("Hello world")
>> tmpfile:append("!")
>> tmpfile:read()
- = "Hello world!"?
+ = "Hello world!" : Text?
>> tmpfile:read_bytes()
- = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21]? : [Byte]?
+ = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21] : [Byte]?
>> tmpdir:files():has(tmpfile)
= yes
@@ -36,9 +36,9 @@ func main():
fail("Couldn't read lines in $tmpfile")
>> (./does-not-exist.xxx):read()
- = !Text
+ = NULL : Text?
>> (./does-not-exist.xxx):read_bytes()
- = ![Byte]
+ = NULL : [Byte]?
if lines := (./does-not-exist.xxx):by_line():
fail("I could read lines in a nonexistent file")
else:
@@ -84,7 +84,7 @@ func main():
>> (./foo.txt):ends_with(".txt")
= yes
>> (./foo.txt):matches($|{..}/foo{..}|)
- = [".", ".txt"]?
+ = [".", ".txt"] : [Text]?
>> (./foo.txt):replace($/.txt/, ".md")
= (./foo.md)
diff --git a/test/reductions.tm b/test/reductions.tm
index a844081f..23ccf097 100644
--- a/test/reductions.tm
+++ b/test/reductions.tm
@@ -2,10 +2,10 @@ struct Foo(x,y:Int)
func main():
>> (+: [10, 20, 30])
- = 60?
+ = 60 : Int?
>> (+: [:Int])
- = !Int
+ = NULL : Int?
>> (+: [10, 20, 30]) or 0
= 60
@@ -14,10 +14,10 @@ func main():
= 0
>> (_max_: [3, 5, 2, 1, 4])
- = 5?
+ = 5 : Int?
>> (_max_:abs(): [1, -10, 5])
- = -10?
+ = -10 : Int?
>> (_max_: [Foo(0, 0), Foo(1, 0), Foo(0, 10)])!
= Foo(x=1, y=0)
@@ -37,7 +37,7 @@ func main():
= yes
>> (<=: [:Int])
- = !Bool
+ = NULL : Bool?
>> (<=: [5, 4, 3, 2, 1])!
= no
diff --git a/test/structs.tm b/test/structs.tm
index d4b0a87e..26b24d62 100644
--- a/test/structs.tm
+++ b/test/structs.tm
@@ -60,7 +60,7 @@ func test_text():
>> a := @CorecursiveA(b)
>> b.other = a
>> a
- = @CorecursiveA(@CorecursiveB(@~1?)?)
+ = @CorecursiveA(@CorecursiveB(@~1))
func main():
test_literals()
diff --git a/test/tables.tm b/test/tables.tm
index 650e4e18..85ce5e01 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -3,11 +3,11 @@ func main():
= {"one":1, "two":2}
>> t:get("one")
- = 1?
+ = 1 : Int?
>> t:get("two")
- = 2?
+ = 2 : Int?
>> t:get("???")
- = !Int
+ = NULL : Int?
>> t:get("one")!
= 1
>> t:get("???") or -1
@@ -22,7 +22,7 @@ func main():
>> t.length
= 2
>> t.fallback
- = !{Text:Int}
+ = NULL : {Text:Int}?
>> t.keys
= ["one", "two"]
@@ -33,16 +33,16 @@ func main():
= {"three":3; fallback={"one":1, "two":2}}
>> t2:get("one")
- = 1?
+ = 1 : Int?
>> t2:get("three")
- = 3?
+ = 3 : Int?
>> t2:get("???")
- = !Int
+ = NULL : Int?
>> t2.length
= 1
>> t2.fallback
- = {"one":1, "two":2}?
+ = {"one":1, "two":2} : {Text:Int}?
t2_str := ""
for k,v in t2:
diff --git a/test/text.tm b/test/text.tm
index 45d5c28f..cd00940f 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -35,7 +35,7 @@ func main():
>> Text.from_bytes([:Byte 0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
= "Amélie"
>> Text.from_bytes([Byte(0xFF)])
- = !Text
+ = NULL : Text?
>> amelie2 := "Am$(\U65\U301)lie"
>> amelie2:split()
@@ -189,13 +189,13 @@ func main():
!! Test text:find()
>> " one two three ":find($/{id}/, start=-999)
- = !Match
+ = NULL : Match?
>> " one two three ":find($/{id}/, start=999)
- = !Match
+ = NULL : Match?
>> " one two three ":find($/{id}/)
- = Match(text="one", index=2, captures=["one"])?
+ = Match(text="one", index=2, captures=["one"]) : Match?
>> " one two three ":find($/{id}/, start=5)
- = Match(text="two", index=8, captures=["two"])?
+ = Match(text="two", index=8, captures=["two"]) : Match?
!! Test text slicing:
>> "abcdef":slice()
@@ -222,7 +222,7 @@ func main():
= ["PENGUIN"]
>> Text.from_codepoint_names(["not a valid name here buddy"])
- = !Text
+ = NULL : Text?
>> "one two; three four":find_all($/; {..}/)
= [Match(text="; three four", index=8, captures=["three four"])]
@@ -247,13 +247,13 @@ func main():
= " good(x, fn(y), BAD(z), w) "
>> "Hello":matches($/{id}/)
- = ["Hello"]?
+ = ["Hello"] : [Text]?
>> "Hello":matches($/{lower}/)
- = ![Text]
+ = NULL : [Text]?
>> "Hello":matches($/{upper}/)
- = ![Text]
+ = NULL : [Text]?
>> "Hello...":matches($/{id}/)
- = ![Text]
+ = NULL : [Text]?
if matches := "hello world":matches($/{id} {id}/):
>> matches