Support running against Basilisp#840
Conversation
|
Thanks so much for adding this! I'll take a look tomorrow :) |
Thanks for the quick reply! I don't actually have this running quite yet, so you can hold off on reviewing. If me opening the PR while I'm working on it is not preferred, I can close it again. Just let me know! |
Ah, a draft PR is ok. I requested Emma's help since I thought you were ready. Feel free to hack on this. Once you're ready, please just request a review from me and I'll loop others in. |
| (def ^:const max-double #?(:clj Double/MAX_VALUE | ||
| :cljr Double/MaxValue | ||
| :cljs js/Number.MAX_VALUE | ||
| :lpy (.-max sys/float-info) |
There was a problem hiding this comment.
If this is system dependent we should add a comment explaining that here
There was a problem hiding this comment.
@E-A-Griffin just to confirm: by "system dependent" you mean like "the computer I'm using may have different sized floats", yes?
| (is (instance? clojure.lang.BigInt (+ 1 5N))) | ||
| (is (instance? clojure.lang.BigInt (+ 1N 5))) | ||
| (is (instance? clojure.lang.BigInt (+ 1N 5N)))])) | ||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| (testing "cannot pop! after call to persistent!" | ||
| (let [t (transient [0 1]), _ (persistent! t)] | ||
| (is (thrown? #?(:cljs js/Error :cljr Exception :default Error) (pop! t))))) | ||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| false :-1 | ||
| false 'a-sym | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| true 1.0M | ||
| false -1.0M | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| ;; `prn-str` adds it to the end of the string. | ||
| (is (= (str "\"a\" \"string\"" nl) (prn-str "a" "string"))) | ||
| (is (= #?(:cljs (str "nil \"a\" \"string\" \"A\" \" \" 1 17 [:a :b] {:c :d} #{:e}" nl) | ||
| :lpy (str "nil \"a\" \"string\" \"A\" \" \" 1 17.0 [:a :b] {:c :d} #{:e}" nl) |
There was a problem hiding this comment.
Could you add the same
;; Basilisp does not have character types, but will print floats
;; with trailing decimal place.
comment here?
| #?(:cljs | ||
| nil | ||
|
|
||
| :lpy |
There was a problem hiding this comment.
comment would be good here
test/clojure/core_test/repeat.cljc
Outdated
|
|
||
| (testing "n not being a number" | ||
| (are [n x] #?(:cljs (= [] (repeat n x)) | ||
| :lpy (thrown? Exception (vec (repeat n x))) |
There was a problem hiding this comment.
Is this because repeat is lazy? Do you know why wrapping this in vec is required?
There was a problem hiding this comment.
I actually might have fixed this in Basilisp to check the value before creating the lazy seq. Let me double check.
There was a problem hiding this comment.
This is actually not necessary any longer, so I will revert this change.
| true (sorted-map :a 1) | ||
| true (sorted-set :a) | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| #?(:cljs true :default false) (seq [1 2 3])))) | ||
| #?(:cljs true :default false) (seq [1 2 3]) | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| '() nil | ||
| nil nil | ||
| (sorted-set 3.0 1.0 -2.5 4.0) '(-2.5 1.0 3.0 4.0) | ||
| #?@(:lpy [] :default [(sorted-set 3.0 1.0 -2.5 4.0) '(-2.5 1.0 3.0 4.0)]) |
There was a problem hiding this comment.
comment would be good here
test/clojure/core_test/seq.cljc
Outdated
| #?@(:lpy [] :default [(sorted-set 3.0 1.0 -2.5 4.0) '(-2.5 1.0 3.0 4.0)]) | ||
| (range 5 10) '(5 6 7 8 9) | ||
| #?@(:cljs [(int-array 3) '(nil nil nil)] | ||
| :lpy [] |
There was a problem hiding this comment.
comment would be good here
| :c 800 | ||
| nil 40} | ||
| input-sorted-map (into (sorted-map) input-map) | ||
| #?@(:lpy [] :default [input-sorted-map (into (sorted-map) input-map)]) |
There was a problem hiding this comment.
comment would be good here
| (is (= input (into #{} (seq input)))) | ||
| (is (= input-hash (into (hash-set) (seq input)))) | ||
| (is (= input-sorted-map (into (sorted-map) (seq input-sorted-map)))) | ||
| #?(:lpy nil :default (is (= input-sorted-map (into (sorted-map) (seq input-sorted-map))))) |
There was a problem hiding this comment.
comment would be good here
| true (range) | ||
| true (rseq [1 2 3]) | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| false (object-array 3)))) | ||
| false (object-array 3) | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| true "a string" | ||
| true (object-array 3) | ||
|
|
||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
E-A-Griffin
left a comment
There was a problem hiding this comment.
Ton of small suggestions, mostly for comments, thanks for your hard work on this!
| (deftest test-set? | ||
| (are [expected x] (= expected (set? x)) | ||
| true (sorted-set :a) | ||
| #?@(:lpy [] :default [true (sorted-set :a)]) |
There was a problem hiding this comment.
comment would be good here
| false \a | ||
| false (object-array 3)))) | ||
| false (object-array 3) | ||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
test/clojure/core_test/short.cljc
Outdated
| ;; test whether it's a fixed-length integer of some sort. | ||
| (is (int? (short 0))) | ||
| #?@(:cljs [] | ||
| :lpy [] |
There was a problem hiding this comment.
comment would be good here
| (testing "special symbols" | ||
| (are [arg] (special-symbol? 'arg) | ||
| & | ||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| (is (= "ab" (subs "abcde" nil 2))) | ||
| (is (= "a" (subs "abcde" 1 nil)))] | ||
| :lpy | ||
| [(is (= "" (subs "abcde" 2 1))) |
There was a problem hiding this comment.
What is the behavior here?
| (is (= '(0.0) (vals {0 0.0}))) | ||
| (is (= '(:b) (vals {:a :b}))) | ||
| (is (= '(:b :d) (vals {:a :b :c :d}))) | ||
| (is (contains? #{'(:b :d) '(:d :b)} (vals {:a :b :c :d}))) |
| [1 2 3] '(1 2 3) | ||
| [1 2 3] [1 2 3] | ||
| [1 2 3] (sorted-set 1 2 3) | ||
| #?@(:lpy [] :default [[1 2 3] (sorted-set 1 2 3)]) |
There was a problem hiding this comment.
comment would be good here
| false \a | ||
| false (object-array 3)))) | ||
| false (object-array 3) | ||
| #?@(:lpy [] |
There was a problem hiding this comment.
comment would be good here
| [(is (true? (str/ends-with? 'ab "b"))) | ||
| (is (false? (str/ends-with? 'ab "a"))) | ||
| (is (true? (str/ends-with? :ab "b"))) | ||
| (is (false? (str/ends-with? :ab "a")))]) |
There was a problem hiding this comment.
indentation is weird on this file
There was a problem hiding this comment.
Some tabs ended up in there somehow. Fixed.
| (is (thrown? Exception (str/starts-with? :ab ":a"))) | ||
| (is (thrown? Exception (str/starts-with? 'a/b ":a"))) | ||
| (is (thrown? Exception (str/starts-with? :a/b ":a")))] | ||
| :default |
There was a problem hiding this comment.
indentation is weird on this file
No need to tackle that now. When we do it, I'd like to get the Clojure core team involved, so we can make a coordinated effort across dialects. For now, keeping that "Differences from Clojure" document up to date with anything you've learned by making this PR would be appreciated. |
|
Excellent review, @E-A-Griffin. I've gone through the whole PR but had nothing more to add than what she identified. Once we're good with each of these comments being addressed, and you feel good about the PR Chris, I think we're golden! Going forward, Chris, if you have anyone from the Basilisp community who would be interested in helping us write these tests, I'd appreciate the call to action. It's a lot of work and we need to kick up some more momentum for 2026. |
|
@jeaye @E-A-Griffin I believe I have addressed all of the comments. In general I tried to add comments where requested, but in cases where I could easily wrap a test case with (for example) Let me know if you have any other comments. Thanks again for the review! |

This PR adds support for running the test suite against Basilisp:
bb test-lpy.By virtue of running on the Python VM, there are a few idiosyncrasies which repeatedly appear in tests:
booltype is a subclass ofints so there are many instances wheretrueandfalsehave to be specially handled.clojure.teststyle fixtures.seqon maps. These seem to work consistently for all other implementations but not in Basilisp. I'm guessing this may have to do with the fact that Clojure (and perhaps others) have array maps for smaller maps and perhaps array maps have a consistent iteration order?applyis not lazy right now, so I had to suppress 2 test cases in themapcattests which produced an infinite loop. I filed #844 to track that in this repo as well.