mirror of
https://github.com/kanaka/mal.git
synced 2024-10-26 14:22:25 +03:00
step A: Test that metadata doesn't break empty collections.
In the BBC BASIC implementation, the empty list, vector, and hash-mapp are distinguished values and detected by their address. Adding metadata to them makes a copy, and then they don't work properly any more.
This commit is contained in:
parent
edc9b5dedd
commit
bfb315c852
@ -222,18 +222,30 @@
|
||||
(meta (with-meta [1 2 3] "abc"))
|
||||
;=>"abc"
|
||||
|
||||
(with-meta [] "abc")
|
||||
;=>[]
|
||||
|
||||
(meta (with-meta (list 1 2 3) {"a" 1}))
|
||||
;=>{"a" 1}
|
||||
|
||||
(list? (with-meta (list 1 2 3) {"a" 1}))
|
||||
;=>true
|
||||
|
||||
(with-meta (list) {"a" 1})
|
||||
;=>()
|
||||
|
||||
(empty? (with-meta (list) {"a" 1}))
|
||||
;=>true
|
||||
|
||||
(meta (with-meta {"abc" 123} {"a" 1}))
|
||||
;=>{"a" 1}
|
||||
|
||||
(map? (with-meta {"abc" 123} {"a" 1}))
|
||||
;=>true
|
||||
|
||||
(with-meta {} {"a" 1})
|
||||
;=>{}
|
||||
|
||||
;;; Not actually supported by Clojure
|
||||
;;;(meta (with-meta (atom 7) {"a" 1}))
|
||||
;;;;=>{"a" 1}
|
||||
|
Loading…
Reference in New Issue
Block a user