Skip to content

break out chunked-seq, es6-iterator, and interop .equiv test from cljs.core-test #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/test/cljs/cljs/chunked_seq.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.

(ns cljs.chunked-seq
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is are]]))

(deftest test-cljs-2693
(is (chunked-seq? (range 5)))
(is (satisfies? IChunk (chunk-first (range 5))))
(is (nil? (chunk-next (range 32))))
(is (not (chunked-seq? (range 2 -2 0))))
(is (chunked-seq? (range)))
(is (= 5 (count (chunk-first (range 5)))))
(is (= 32 (count (chunk-first (range)))))
(is (= 17 (nth (chunk-first (range 100)) 17)))
(is (= 35 (nth (chunk-first (range 100)) 35)))
(is (= 32 (count (chunk-first (range 100)))))
(is (= 0 (first (range 5))))
(is (= 1 (second (range 5))))
(is (= (range 1 5) (rest (range 5))))
(is (= (range 1 5) (next (range 5)))))
75 changes: 0 additions & 75 deletions src/test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,6 @@
(halt-when :anomaly #(assoc %2 :partial-results %1))
[1 2 {:anomaly :oh-no!} 3 4]))))

(deftest test-obj-equiv
(testing "Object equiv method"
(is (.equiv :foo :foo))
(is (.equiv 'foo 'foo))
(is (.equiv {:foo 1 :bar 2} {:foo 1 :bar 2}))
(is (.equiv [1 2 3] [1 2 3]))
(is (.equiv '(1 2 3) '(1 2 3)))
(is (.equiv (map inc [1 2 3]) (map inc [1 2 3])))
(is (.equiv #{:cat :dog :bird} #{:cat :dog :bird}))
))

(defn seq-iter-match
[coll]
(let [i (-iterator coll)]
Expand Down Expand Up @@ -456,54 +445,6 @@
(is (= true (seq-iter-match test-queue)))
(is (= true (seq-iter-match test-record))))))

(deftest test-es6-interfaces
(testing "ES6 collection interfaces"
(let [iter (es6-iterator [1 2 3])]
(testing "basic iterations"
(is (= (.-value (.next iter)) 1))
(is (= (.-value (.next iter)) 2))
(is (= (.-value (.next iter)) 3))
(is (.-done (.next iter)))))
(is (.has {:foo "bar"} :foo))
(is (= (.get {:foo "bar"} :foo) "bar"))
(is (= (.get {:foo "bar"} :bar :default) :default))
(let [iter (.keys {:foo "bar" :baz "woz"})]
(testing "map key iteration"
(is (#{:foo :baz} (.-value (.next iter))))
(is (#{:foo :baz} (.-value (.next iter))))
(is (.-done (.next iter)))))
(let [eiter (.entries {:foo "bar" :baz "woz"})]
(testing "map entry iteration"
(let [entries #{(seq #js [:foo "bar"]) (seq #js [:baz "woz"])}]
(is (entries (seq (.-value (.next eiter)))))
(is (entries (seq (.-value (.next eiter))))))
(is (.-done (.next eiter)))))
(let [iter (.values {:foo "bar" :baz "woz"})]
(testing "map value iteration"
(is (#{"bar" "woz"} (.-value (.next iter))))
(is (#{"bar" "woz"} (.-value (.next iter))))
(is (.-done (.next iter)))))
(is (.has #{:cat :bird :dog} :bird))
(let [iter (.keys #{:cat :bird :dog})]
(testing "set key iteration"
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (.-done (.next iter)))))
(let [iter (.entries #{:cat :bird :dog})]
(testing "set entry iteration"
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (.-done (.next iter)))))
(let [iter (.values #{:cat :bird :dog})]
(testing "set value iteration"
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (.-done (.next iter)))))
))

(deftest test-reader-literals
(testing "Testing reader literals"
(is (= #queue [1] (into cljs.core.PersistentQueue.EMPTY [1])))
Expand Down Expand Up @@ -1670,22 +1611,6 @@
;; Make sure we didn't delete the alpha? fn
(is (some? alpha-2585?)))

(deftest test-cljs-2693
(is (chunked-seq? (range 5)))
(is (satisfies? IChunk (chunk-first (range 5))))
(is (nil? (chunk-next (range 32))))
(is (not (chunked-seq? (range 2 -2 0))))
(is (chunked-seq? (range)))
(is (= 5 (count (chunk-first (range 5)))))
(is (= 32 (count (chunk-first (range)))))
(is (= 17 (nth (chunk-first (range 100)) 17)))
(is (= 35 (nth (chunk-first (range 100)) 35)))
(is (= 32 (count (chunk-first (range 100)))))
(is (= 0 (first (range 5))))
(is (= 1 (second (range 5))))
(is (= (range 1 5) (rest (range 5))))
(is (= (range 1 5) (next (range 5)))))

(defn fn-2741* ([x]) ([x y]))
(def fn-2741 fn-2741*)

Expand Down
70 changes: 70 additions & 0 deletions src/test/cljs/cljs/interop_test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.

(ns cljs.interop-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is are]]))

(deftest test-obj-equiv
(testing "Object equiv method"
(is (.equiv :foo :foo))
(is (.equiv 'foo 'foo))
(is (.equiv {:foo 1 :bar 2} {:foo 1 :bar 2}))
(is (.equiv [1 2 3] [1 2 3]))
(is (.equiv '(1 2 3) '(1 2 3)))
(is (.equiv (map inc [1 2 3]) (map inc [1 2 3])))
(is (.equiv #{:cat :dog :bird} #{:cat :dog :bird}))
))

(deftest test-es6-interfaces
(testing "ES6 collection interfaces"
(let [iter (es6-iterator [1 2 3])]
(testing "basic iterations"
(is (= (.-value (.next iter)) 1))
(is (= (.-value (.next iter)) 2))
(is (= (.-value (.next iter)) 3))
(is (.-done (.next iter)))))
(is (.has {:foo "bar"} :foo))
(is (= (.get {:foo "bar"} :foo) "bar"))
(is (= (.get {:foo "bar"} :bar :default) :default))
(let [iter (.keys {:foo "bar" :baz "woz"})]
(testing "map key iteration"
(is (#{:foo :baz} (.-value (.next iter))))
(is (#{:foo :baz} (.-value (.next iter))))
(is (.-done (.next iter)))))
(let [eiter (.entries {:foo "bar" :baz "woz"})]
(testing "map entry iteration"
(let [entries #{(seq #js [:foo "bar"]) (seq #js [:baz "woz"])}]
(is (entries (seq (.-value (.next eiter)))))
(is (entries (seq (.-value (.next eiter))))))
(is (.-done (.next eiter)))))
(let [iter (.values {:foo "bar" :baz "woz"})]
(testing "map value iteration"
(is (#{"bar" "woz"} (.-value (.next iter))))
(is (#{"bar" "woz"} (.-value (.next iter))))
(is (.-done (.next iter)))))
(is (.has #{:cat :bird :dog} :bird))
(let [iter (.keys #{:cat :bird :dog})]
(testing "set key iteration"
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (.-done (.next iter)))))
(let [iter (.entries #{:cat :bird :dog})]
(testing "set entry iteration"
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (#{[:cat :cat] [:bird :bird] [:dog :dog]} (seq (.-value (.next iter)))))
(is (.-done (.next iter)))))
(let [iter (.values #{:cat :bird :dog})]
(testing "set value iteration"
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (#{:cat :bird :dog} (.-value (.next iter))))
(is (.-done (.next iter)))))
))
4 changes: 4 additions & 0 deletions src/test/cljs/test_runner.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
[cljs.collections-test]
[cljs.hashing-test]
[cljs.core-test :as core-test]
[cljs.chunked-seq]
[cljs.interop-test]
[cljs.reader-test]
[cljs.binding-test]
[cljs.parse-test]
Expand Down Expand Up @@ -77,6 +79,8 @@
'cljs.collections-test
'cljs.hashing-test
'cljs.core-test
'cljs.chunked-seq
'cljs.interop-test
'cljs.reader-test
'cljs.parse-test
'clojure.set-test
Expand Down