1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-29 21:45:14 +00:00

(struct ...) with duped keys will use last value.

This commit is contained in:
Calvin Rose
2020-04-11 12:49:39 -05:00
parent 5ed76f197a
commit 8bc2987a71
4 changed files with 18 additions and 7 deletions

View File

@@ -328,5 +328,11 @@
(assert (= true ;(map truthy? [0 "" true @{} {} [] '()])) "truthy values")
(assert (= false ;(map truthy? [nil false])) "non-truthy values")
# Struct and Table duplicate elements
(assert (= {:a 3 :b 2} {:a 1 :b 2 :a 3}) "struct literal duplicate keys")
(assert (= {:a 3 :b 2} (struct :a 1 :b 2 :a 3)) "struct constructor duplicate keys")
(assert (deep= @{:a 3 :b 2} @{:a 1 :b 2 :a 3}) "table literal duplicate keys")
(assert (deep= @{:a 3 :b 2} (table :a 1 :b 2 :a 3)) "table constructor duplicate keys")
(end-suite)