Skip to content

Commit

Permalink
Merge pull request #200 from nbuilding/SheepTester-patch-1
Browse files Browse the repository at this point in the history
Add a few more tests for floats and strings
  • Loading branch information
Ashvin-Ranjan authored Jul 2, 2021
2 parents b95c92d + 9edb5ce commit fe1457e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
26 changes: 26 additions & 0 deletions tests/assertions/basics.n
Original file line number Diff line number Diff line change
@@ -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}
17 changes: 14 additions & 3 deletions tests/assertions/tuples-lists-records.n
Original file line number Diff line number Diff line change
@@ -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")
19 changes: 19 additions & 0 deletions tests/syntax/literals.n
Original file line number Diff line number Diff line change
@@ -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",),],)

0 comments on commit fe1457e

Please sign in to comment.