diff --git a/tests/assertions/basics.n b/tests/assertions/basics.n new file mode 100644 index 00000000..7617851e --- /dev/null +++ b/tests/assertions/basics.n @@ -0,0 +1,26 @@ +// No equivalent in the documentation 😳 + +// Floats are double-precision :postpissedchil: + +// Division of nonzero numbers by zero; negative zero +let inf = 1.0 / 0.0 +assert value 1.0 / -0.0 == -inf +assert value 0.0 == -0.0 + +// NaN +let nan = inf - inf +assert value nan /= nan +assert value 0.0 / 0.0 /= 0.0 / 0.0 + +assert value 0.1 + 0.2 == 0.30000000000000004 + +assert value 9007199254740992.0 + 1.0 == 9007199254740992.0 + +// Strings + +assert value "\{🕴}" == "🕴" +assert value "\0\b\t\n\v\f\r\"\\" == "\u{0}\u{8}\u{9}\u{a}\u{b}\u{c}\u{d}\u{22}\u{5c}" + +// Chars + +assert value \v == \u{b} diff --git a/tests/assertions/tuples-lists-records.n b/tests/assertions/tuples-lists-records.n index 8beb79f5..34eb5134 100644 --- a/tests/assertions/tuples-lists-records.n +++ b/tests/assertions/tuples-lists-records.n @@ -1,9 +1,20 @@ // Based on docs/features/tuples_lists_records.md -assert type 1, \{a} : int, char +let tuplevalue = 1, \{a} +assert type tuplevalue : int, char let recordValue = { value: 1 } assert type recordValue : { value: int } -assert type recordValue.value : int -assert type ["a", "b", "c"] : list[str] +let value = recordvalue.value +assert type value : int +assert value value == 1 + +let listvalue = ["a", "b", "c"] +assert type listvalue : list[str] + +assert value append("d", listvalue) == ["a", "b", "c", "d"] +assert value listvalue == ["a", "b", "c"] + +let listindexvalue = itemAt(1, listvalue) +assert value listindexvalue == yes("b") diff --git a/tests/syntax/literals.n b/tests/syntax/literals.n new file mode 100644 index 00000000..69bb5f38 --- /dev/null +++ b/tests/syntax/literals.n @@ -0,0 +1,19 @@ +// Number and string literal syntax to ensure they're supported + +let binary = 0b10101 +let octal = 0o70707 +let hex = 0x123AbC + +// TODO: Do we allow something like `50e10`? +let scinot = -5.000000000000001e-231 + +let newline = \n +let char = \{🐑} +let unicode = \u{1f382} + +let allTogether = "\n\{🐑}\u{1f382}\\\\\\\\" + +let unit = () + +let trailingComma = { a: (1, 2,); b: 2; } +let inList: map[str, str,] = mapFrom([("ah", "pple",), ("ahh", "ppple",),],)