1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-18 01:07:40 +00:00

Disallow NaN as table/struct key.

Fix bugs and add tests for denormalized tables
and structs.
This commit is contained in:
Calvin Rose
2019-01-28 11:50:33 -05:00
parent c333cbfa55
commit 38a7e4faf1
4 changed files with 23 additions and 13 deletions

View File

@@ -283,5 +283,22 @@
(++ i))
(assert (= i 6) "when macro"))
# Denormal tables and structs
(assert (= (length {1 2 nil 3}) 1) "nil key struct literal")
(assert (= (length @{1 2 nil 3}) 1) "nil key table literal")
(assert (= (length (struct 1 2 nil 3)) 1) "nil key struct ctor")
(assert (= (length (table 1 2 nil 3)) 1) "nil key table ctor")
(assert (= (length (struct (/ 0 0) 2 1 3)) 1) "nan key struct ctor")
(assert (= (length (table (/ 0 0) 2 1 3)) 1) "nan key table ctor")
(assert (= (length {1 2 nil 3}) 1) "nan key struct literal")
(assert (= (length @{1 2 nil 3}) 1) "nan key table literal")
(assert (= (length (struct 2 1 3 nil)) 1) "nil value struct ctor")
(assert (= (length (table 2 1 3 nil)) 1) "nil value table ctor")
(assert (= (length {1 2 3 nil}) 1) "nil value struct literal")
(assert (= (length @{1 2 3 nil}) 1) "nil value table literal")
(end-suite)