From d189ee2ded69a7d78c1c9f40b215244677729f8a Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 6 Jun 2026 19:52:54 -0400 Subject: [PATCH] spec: regression cases for with-meta nil and multi-coll map nil elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Document the two fixed behaviors in the contract spec: (with-meta x nil) clears metadata, and a multi-collection map keeps nil elements (they're values, not end-of-seq). The reader grammar (doc/grammar.ebnf) is unchanged — this session touched semantics/stdlib, not surface syntax. --- test/spec/metadata-spec.janet | 3 ++- test/spec/sequences-spec.janet | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/spec/metadata-spec.janet b/test/spec/metadata-spec.janet index b3df3b5..e92b3c0 100644 --- a/test/spec/metadata-spec.janet +++ b/test/spec/metadata-spec.janet @@ -8,7 +8,8 @@ ["with-meta on map" "{:doc \"x\"}" "(meta (with-meta {:k 1} {:doc \"x\"}))"] ["vary-meta" "{:a 2}" "(meta (vary-meta (with-meta [1] {:a 1}) update :a inc))"] ["meta reader ^" "{:tag :int}" "(meta ^{:tag :int} [1 2])"] - ["with-meta on fn ok" "true" "(fn? (with-meta inc {:a 1}))"]) + ["with-meta on fn ok" "true" "(fn? (with-meta inc {:a 1}))"] + ["with-meta nil clears" "nil" "(meta (with-meta [1 2 3] nil))"]) (defspec "metadata / type hints" # ^Type / ^:kw / ^"str" on a symbol attach as metadata and are otherwise inert: diff --git a/test/spec/sequences-spec.janet b/test/spec/sequences-spec.janet index 8f78525..1e7a065 100644 --- a/test/spec/sequences-spec.janet +++ b/test/spec/sequences-spec.janet @@ -43,6 +43,8 @@ ["map" "[2 3 4]" "(map inc [1 2 3])"] ["map two colls" "[5 7 9]" "(map + [1 2 3] [4 5 6])"] ["map stops at shortest" "[5 7]" "(map + [1 2] [4 5 6])"] + # nil elements are values, not end-of-seq: multi-coll map must not truncate. + ["map keeps nil elements" "[[1 :a] [nil :b] [3 nil]]" "(map vector [1 nil 3] [:a :b nil])"] ["map-indexed" "[[0 :a] [1 :b]]" "(map-indexed vector [:a :b])"] ["mapv" "[2 3 4]" "(mapv inc [1 2 3])"] ["filter" "[2 4]" "(filter even? [1 2 3 4])"]