From 4e6ef21576d9ec6a8861246464b1905819b68efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Mon, 8 Mar 2021 21:57:52 +0100 Subject: fix some nice tests for the nullable_types --- progs/tests/nullable_types.sy | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 progs/tests/nullable_types.sy (limited to 'progs/tests') diff --git a/progs/tests/nullable_types.sy b/progs/tests/nullable_types.sy new file mode 100644 index 0000000..2088c53 --- /dev/null +++ b/progs/tests/nullable_types.sy @@ -0,0 +1,33 @@ +test001 :: fn -> int { + a : int? = nil + a = 2 + ret a +} + +test002 :: fn b:bool -> int? { + if b { + ret nil + } else { + ret 0 + } +} + +// TODO(ed): Introduce type type! +test003 :: fn { + a := test002! false + a += 1 + a <=> 1 +} + + +start :: fn { + test001! + nil <=> test002! true + 0 <=> test002! false + q : bool? = true + q <=> true + q = nil + q <=> nil + test003! +} + -- cgit v1.2.1