We're updating the issue view to help you get more done. 

Generative test involving persistent queue reversed order

Description

The following arranges to test that conjing an item onto a persistent queue results in that item being last in the queue:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 (require '[clojure.spec.alpha :as s] '[clojure.spec.gen.alpha :as gen] '[clojure.spec.test.alpha :as st] '[clojure.test.check] '[clojure.test.check.properties]) (s/def ::int-queue (s/coll-of int? :gen #(gen/fmap (fn [x] (into #?(:cljs #queue [] :clj clojure.lang.PersistentQueue/EMPTY) x)) (s/gen (s/coll-of int? :gen-max 5))))) (defn enqueue [int-queue n] (conj int-queue n)) (s/fdef enqueue :args (s/cat :int-queue ::int-queue :n int?) :ret ::int-queue :fn #(= (last (:ret %)) (:n (:args %)))) (st/check `enqueue)

Running this in Clojure works fine. In ClojureScript 1.10.520 you'll get a spec failure and it appears from the error report, the item is at the front of the queue. Here is an example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 [{:spec #object[cljs.spec.alpha.t_cljs$spec$alpha3986], :clojure.spec.test.check/ret {:shrunk {:total-nodes-visited 4, :depth 1, :pass? false, :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/= (cljs.core/last (:ret %)) (:n (:args %)))), :val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha3687], :cljs.spec.alpha/value {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.test.alpha/args (#queue [0] -1), :cljs.spec.test.alpha/val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.alpha/failure :check-failed}}, :result-data #:clojure.test.check.properties{:error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/= (cljs.core/last (:ret %)) (:n (:args %)))), :val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha3687], :cljs.spec.alpha/value {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.test.alpha/args (#queue [0] -1), :cljs.spec.test.alpha/val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.alpha/failure :check-failed}}}, :time-shrinking-ms 4, :smallest [(#queue [0] -1)]}, :failed-after-ms 4, :num-tests 2, :seed 1552588512350, :fail [(#queue [0 0] -1)], :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/= (cljs.core/last (:ret %)) (:n (:args %)))), :val {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha3687], :cljs.spec.alpha/value {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :cljs.spec.test.alpha/args (#queue [0 0] -1), :cljs.spec.test.alpha/val {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :cljs.spec.alpha/failure :check-failed}}, :result-data #:clojure.test.check.properties{:error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/= (cljs.core/last (:ret %)) (:n (:args %)))), :val {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha3687], :cljs.spec.alpha/value {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :cljs.spec.test.alpha/args (#queue [0 0] -1), :cljs.spec.test.alpha/val {:args {:int-queue (0 0), :n -1}, :ret (-1 0 0)}, :cljs.spec.alpha/failure :check-failed}}}, :failing-size 1, :pass? false}, :sym cljs.user/enqueue, :failure #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/= (cljs.core/last (:ret %)) (:n (:args %)))), :val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha3687], :cljs.spec.alpha/value {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.test.alpha/args (#queue [0] -1), :cljs.spec.test.alpha/val {:args {:int-queue (0), :n -1}, :ret (-1 0)}, :cljs.spec.alpha/failure :check-failed}}}]

Environment

None

Status

Assignee

Unassigned

Reporter

Mike Fikes

Labels

Approval

None

Patch

None

Priority

Major