diff --git a/src/test/cljs/cljs/chunked_seq.cljs b/src/test/cljs/cljs/chunked_seq.cljs new file mode 100644 index 000000000..73abf707f --- /dev/null +++ b/src/test/cljs/cljs/chunked_seq.cljs @@ -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))))) \ No newline at end of file diff --git a/src/test/cljs/cljs/core_test.cljs b/src/test/cljs/cljs/core_test.cljs index 9d9b4306e..fca3dd11e 100644 --- a/src/test/cljs/cljs/core_test.cljs +++ b/src/test/cljs/cljs/core_test.cljs @@ -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)] @@ -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]))) @@ -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*) diff --git a/src/test/cljs/cljs/interop_test.cljs b/src/test/cljs/cljs/interop_test.cljs new file mode 100644 index 000000000..ee158ec18 --- /dev/null +++ b/src/test/cljs/cljs/interop_test.cljs @@ -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))))) + )) \ No newline at end of file diff --git a/src/test/cljs/test_runner.cljs b/src/test/cljs/test_runner.cljs index a0e411309..10abbdf54 100644 --- a/src/test/cljs/test_runner.cljs +++ b/src/test/cljs/test_runner.cljs @@ -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] @@ -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