From 15c375b99a29dc251c55de51aeb2415172619a0a Mon Sep 17 00:00:00 2001 From: chemaclass Date: Fri, 29 May 2026 14:50:40 +0200 Subject: [PATCH] test(phel): mark nil-safe parse-* as documented divergence Phel's parse-long / parse-double / parse-boolean / parse-uuid intentionally return nil for non-string (or unparseable) input instead of throwing, so they chain in when/if-let without guarding. Add :phel branches to the exception blocks asserting nil-return instead of p/thrown?, documenting the difference. Other dialects are unaffected (they fall through to their existing branches). --- test/clojure/core_test/parse_boolean.cljc | 15 ++++++++++++++- test/clojure/core_test/parse_double.cljc | 13 ++++++++++++- test/clojure/core_test/parse_long.cljc | 13 ++++++++++++- test/clojure/core_test/parse_uuid.cljc | 14 +++++++++++++- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/test/clojure/core_test/parse_boolean.cljc b/test/clojure/core_test/parse_boolean.cljc index 04e37174..92299206 100644 --- a/test/clojure/core_test/parse_boolean.cljc +++ b/test/clojure/core_test/parse_boolean.cljc @@ -25,7 +25,20 @@ nil "true ")) (testing "exceptions" - #?(:lpy (are [x] (p/thrown? (parse-boolean x)) + ;; Phel's `parse-boolean` is intentionally nil-safe: it returns `nil` for + ;; any non-string input (and any string other than "true"/"false") + ;; instead of throwing, so it can be chained in `when`/`if-let` without + ;; guarding. Documented divergence. + #?(:phel (are [x] (nil? (parse-boolean x)) + nil + 0 + 0.0 + :key + {} + '() + #{} + []) + :lpy (are [x] (p/thrown? (parse-boolean x)) nil 0 0.0 diff --git a/test/clojure/core_test/parse_double.cljc b/test/clojure/core_test/parse_double.cljc index 9d099eba..e88737cf 100644 --- a/test/clojure/core_test/parse_double.cljc +++ b/test/clojure/core_test/parse_double.cljc @@ -35,7 +35,18 @@ ##Inf "Infinity" ##-Inf "-Infinity")) (testing "exceptions" - #?(:lpy (are [x] (p/thrown? (parse-double x)) + ;; Phel's `parse-double` is intentionally nil-safe: it returns `nil` for + ;; any non-string (or unparseable) input instead of throwing, so it can + ;; be chained in `when`/`if-let` without guarding. Documented divergence. + #?(:phel (are [x] (nil? (parse-double x)) + {} + '() + [] + #{} + :key + 0.0 + 1000) + :lpy (are [x] (p/thrown? (parse-double x)) {} '() [] diff --git a/test/clojure/core_test/parse_long.cljc b/test/clojure/core_test/parse_long.cljc index e450cb95..5d86181e 100644 --- a/test/clojure/core_test/parse_long.cljc +++ b/test/clojure/core_test/parse_long.cljc @@ -33,7 +33,18 @@ 999999999999999 "999999999999999"] :default [999999999999999999 "999999999999999999"]))) (testing "exceptions" - #?(:lpy (are [x] (p/thrown? (parse-long x)) + ;; Phel's `parse-long` is intentionally nil-safe: it returns `nil` for + ;; any non-string (or unparseable) input instead of throwing, so it can + ;; be chained in `when`/`if-let` without guarding. Documented divergence. + #?(:phel (are [x] (nil? (parse-long x)) + {} + '() + [] + #{} + :key + 0.0 + 1000) + :lpy (are [x] (p/thrown? (parse-long x)) {} '() [] diff --git a/test/clojure/core_test/parse_uuid.cljc b/test/clojure/core_test/parse_uuid.cljc index 4d3260a1..be52dae2 100644 --- a/test/clojure/core_test/parse_uuid.cljc +++ b/test/clojure/core_test/parse_uuid.cljc @@ -24,7 +24,19 @@ #uuid "00000012-0034-0056-0078-000000000009" "12-34-56-78-9" #uuid "00000005-0004-0003-0002-009000000001" "5-4-3-DEADBEEF0002-9000000001")) (testing "exceptions" - #?(:lpy (are [x] (p/thrown? (parse-uuid x)) + ;; Phel's `parse-uuid` is intentionally nil-safe: it returns `nil` for + ;; any non-string, non-UUID input instead of throwing, so it can be + ;; chained in `when`/`if-let` without guarding. Documented divergence. + #?(:phel (are [x] (nil? (parse-uuid x)) + {} + '() + [] + #{} + :key + 0.0 + 1000) + + :lpy (are [x] (p/thrown? (parse-uuid x)) {} '() []