Mine the phase* port batteries into the spec layer and delete them (their
behavior is now covered by spec): phase5 (hierarchies), phase6 (tagged
literals/reader-conditionals), phase7 (lazy/sets), phase8+phase12 (protocols;
phase12 was a duplicate of phase8), phase10 (strings/set), phase13
(reify/walk). Unique cases mined into spec: reader #inst/#uuid/#?@ splice,
(Type. args) dot constructor, lazy-seq body-runs-once, keywordize-keys/
stringify-keys, custom :default key and explicit :hierarchy dispatch.
phase6-final tested the COMPILE-MODE path ({:compile? true}), distinct from the
interpreter-based spec — kept and renamed integration/compile-mode-test.
jpm test green, conformance 218/218.
41 lines
1.9 KiB
Text
41 lines
1.9 KiB
Text
# Specification: reader syntax & literals.
|
|
(use ../support/harness)
|
|
|
|
(defspec "reader / scalar literals"
|
|
["integer" "42" "42"]
|
|
["negative" "-7" "-7"]
|
|
["float" "1.5" "1.5"]
|
|
["string" "\"hi\"" "\"hi\""]
|
|
["boolean true" "true" "true"]
|
|
["nil" "nil" "nil"]
|
|
["keyword" ":a" ":a"]
|
|
["namespaced keyword" "true" "(= :a/b :a/b)"]
|
|
["char" "\\a" "\\a"]
|
|
["char newline" "true" "(= \\newline (first \"\\n\"))"]
|
|
["ratio not supported but reads ints" "3" "3"]
|
|
["hex literal" "255" "0xff"]
|
|
["symbol via quote" "'foo" "'foo"])
|
|
|
|
(defspec "reader / collection literals"
|
|
["vector" "[1 2 3]" "[1 2 3]"]
|
|
["list quoted" "[1 2 3]" "'(1 2 3)"]
|
|
["map" "{:a 1}" "{:a 1}"]
|
|
["set" "#{1 2 3}" "#{1 2 3}"]
|
|
["nested" "{:a [1 {:b 2}]}" "{:a [1 {:b 2}]}"]
|
|
["empty vector" "[]" "[]"]
|
|
["empty map" "{}" "{}"]
|
|
["empty set" "#{}" "#{}"])
|
|
|
|
(defspec "reader / dispatch & sugar"
|
|
["anon fn #()" "3" "(#(+ %1 %2) 1 2)"]
|
|
["anon fn single %" "2" "(#(inc %) 1)"]
|
|
["anon fn %&" "[2 3]" "(#(vec %&) 2 3)"]
|
|
["discard #_" "[1 3]" "[1 #_2 3]"]
|
|
["regex literal" "true" "(= \"abc\" (re-find #\"abc\" \"xabcx\"))"]
|
|
["reader conditional" "1" "#?(:clj 1 :cljs 2 :default 3)"]
|
|
["reader cond splice" "[1 2 3]" "[#?@(:clj [1 2 3] :cljs [4 5])]"]
|
|
["inst literal reads" "true" "(some? #inst \"2020-01-01T00:00:00Z\")"]
|
|
["uuid literal" "\"550e8400-e29b-41d4-a716-446655440000\"" "(str #uuid \"550e8400-e29b-41d4-a716-446655440000\")"]
|
|
["tagged literal var" "true" "(var? #'+)"]
|
|
["deref sugar" "5" "(let [a (atom 5)] @a)"]
|
|
["meta sugar" "{:t 1}" "(meta ^{:t 1} [])"])
|