Skip to content

Instantly share code, notes, and snippets.

@bensu
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensu/c6302a33e56d5d7eae9e to your computer and use it in GitHub Desktop.
Save bensu/c6302a33e56d5d7eae9e to your computer and use it in GitHub Desktop.
Nashortn minimal failing case
(ns cljs.core-test
(:refer-clojure :exclude [iter])
(:require [cljs.test :refer-macros [deftest testing is]]))
(deftest test-atoms-and-volatile
(let [v (volatile! 1)]
(testing "Testing volatile"
(is (volatile? v))
(is (not (volatile? (atom 1))))
(is (= 2 (vreset! v 2)))
(println "testing volatile")
(is (= 3 (vswap! v inc)))
(is (= 3 @v)))))
(deftest test-transducers
(testing "Testing transducers"
(is (= (sequence (take-nth 2) (range 10))
'(0 2 4 6 8)))
(is (= (keep-indexed identity [:foo nil :bar nil :baz])
(sequence (keep-indexed identity) [:foo nil :bar nil :baz])))
(let [xform (comp (map inc)
(filter even?)
(dedupe)
(mapcat range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(mapcat flatten)
(random-sample 1.0)
(take-nth 1)
(keep #(when (odd? %) (* % %)))
(keep-indexed #(when (even? %1) (* %1 %2)))
(replace {2 "two" 6 "six" 18 "eighteen"})
(take 11)
(take-while #(not= 300 %))
(drop 1)
(drop-while string?)
(remove string?))
data (vec (interleave (range 18) (range 20)))]
(is (= (sequence xform data) '(36 200 10))))))
(defrecord Person [firstname lastname])
(deftest test-records
(let [fred (Person. "Fred" "Mertz")]
))
(deftype MyCustomAtom [^:mutable state]
IDeref
(-deref [_] state)
IReset
(-reset! [_ newval]
(set! state newval)))
(deftest test-919-generic-cas
(testing "testing CLJS-919, CAS should on custom atom types"
(let [a0 (MyCustomAtom. 10)
a1 (MyCustomAtom. 0)]
(compare-and-set! a0 0 20)
(compare-and-set! a1 0 20)
(is (== @a0 10))
(is (== @a1 20)))))
(deftest test-map-new-transducers
(testing "Test distinct, interpose, map-indexed transducers"
(is (= [[0 1] [1 2] [2 3]]
(transduce (map-indexed (fn [i x] [i x])) conj [] [1 2 3])))))
Removing any of Person, `test-transducers`, or`test-map-new-transducers` are removed (or all together, or any combination) we get this error instead:
ERROR in (test-919-generic-cas) (Error:NaN:NaN)
testing CLJS-919, CAS should on custom atom types
expected: (== (clojure.core/deref a0) 10)
actual:
#<Error: No protocol method IDeref.-deref defined for type cljs.core-test/MyCustomAtom: [object Object]>
ERROR in (test-919-generic-cas) (Error:NaN:NaN)
testing CLJS-919, CAS should on custom atom types
expected: (== (clojure.core/deref a1) 20)
actual:
#<Error: No protocol method IDeref.-deref defined for type cljs.core-test/MyCustomAtom: [object Object]>
Ran 4 tests containing 11 assertions.
0 failures, 2 errors.
Tested with 1 out of 4 possible js targets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment