Make prop/for-all
call more consistent throughout the vector specs
The specs for `vector/_emptyvector`, `vector/_first`, and `vector/_last` all called `prop/for-all` within their 'check' functions, whereas the other specs all called it within their macros. This change makes the three specs mentioned more consistent with the rest of the specs by having them also call `prop/for-all` within their macros.
This commit is contained in:
parent
a606a47ce1
commit
b41c35582a
@ -57,21 +57,21 @@
|
|||||||
;;; vector/_emptyvector
|
;;; vector/_emptyvector
|
||||||
|
|
||||||
(defn check-empty-vector
|
(defn check-empty-vector
|
||||||
[generator value-type]
|
[vect value-type]
|
||||||
(let [stack-type (keyword (str "vector_" value-type))]
|
(let [stack-type (keyword (str "vector_" value-type))
|
||||||
(prop/for-all [vect (gen/vector generator)]
|
start-state (state/push-to-stack state/empty-state
|
||||||
(let [start-state (state/push-to-stack state/empty-state
|
|
||||||
stack-type
|
stack-type
|
||||||
vect)
|
vect)
|
||||||
end-state (vector/_emptyvector stack-type start-state)]
|
end-state (vector/_emptyvector stack-type start-state)]
|
||||||
(= (empty? vect)
|
(= (empty? vect)
|
||||||
(state/peek-stack end-state :boolean))))))
|
(state/peek-stack end-state :boolean))))
|
||||||
|
|
||||||
(defmacro empty-vector-spec
|
(defmacro empty-vector-spec
|
||||||
[generator value-type]
|
[generator value-type]
|
||||||
`(defspec ~(symbol (str "empty-vector-spec-" value-type))
|
`(defspec ~(symbol (str "empty-vector-spec-" value-type))
|
||||||
100
|
100
|
||||||
(check-empty-vector ~generator ~value-type)))
|
(prop/for-all [vect# (gen/vector ~generator)]
|
||||||
|
(check-empty-vector vect# ~value-type))))
|
||||||
|
|
||||||
(empty-vector-spec gen/small-integer "integer")
|
(empty-vector-spec gen/small-integer "integer")
|
||||||
(empty-vector-spec gen/double "float")
|
(empty-vector-spec gen/double "float")
|
||||||
@ -81,10 +81,9 @@
|
|||||||
;;; vector/_first
|
;;; vector/_first
|
||||||
|
|
||||||
(defn check-first
|
(defn check-first
|
||||||
[generator value-type]
|
[vect value-type]
|
||||||
(let [stack-type (keyword (str "vector_" value-type))]
|
(let [stack-type (keyword (str "vector_" value-type))
|
||||||
(prop/for-all [vect (gen/vector generator)]
|
start-state (state/push-to-stack state/empty-state
|
||||||
(let [start-state (state/push-to-stack state/empty-state
|
|
||||||
stack-type
|
stack-type
|
||||||
vect)
|
vect)
|
||||||
end-state (vector/_first stack-type start-state)]
|
end-state (vector/_first stack-type start-state)]
|
||||||
@ -95,13 +94,14 @@
|
|||||||
(and
|
(and
|
||||||
(= (first vect)
|
(= (first vect)
|
||||||
(state/peek-stack end-state (keyword value-type)))
|
(state/peek-stack end-state (keyword value-type)))
|
||||||
(state/empty-stack? end-state stack-type)))))))
|
(state/empty-stack? end-state stack-type)))))
|
||||||
|
|
||||||
(defmacro first-spec
|
(defmacro first-spec
|
||||||
[generator value-type]
|
[generator value-type]
|
||||||
`(defspec ~(symbol (str "first-spec-" value-type))
|
`(defspec ~(symbol (str "first-spec-" value-type))
|
||||||
100
|
100
|
||||||
(check-first ~generator ~value-type)))
|
(prop/for-all [vect# (gen/vector ~generator)]
|
||||||
|
(check-first vect# ~value-type))))
|
||||||
|
|
||||||
(first-spec gen/small-integer "integer")
|
(first-spec gen/small-integer "integer")
|
||||||
(first-spec gen/double "float")
|
(first-spec gen/double "float")
|
||||||
@ -111,10 +111,9 @@
|
|||||||
;;; vector/_last
|
;;; vector/_last
|
||||||
|
|
||||||
(defn check-last
|
(defn check-last
|
||||||
[generator value-type]
|
[vect value-type]
|
||||||
(let [stack-type (keyword (str "vector_" value-type))]
|
(let [stack-type (keyword (str "vector_" value-type))
|
||||||
(prop/for-all [vect (gen/vector generator)]
|
start-state (state/push-to-stack state/empty-state
|
||||||
(let [start-state (state/push-to-stack state/empty-state
|
|
||||||
stack-type
|
stack-type
|
||||||
vect)
|
vect)
|
||||||
end-state (vector/_last stack-type start-state)]
|
end-state (vector/_last stack-type start-state)]
|
||||||
@ -125,13 +124,14 @@
|
|||||||
(and
|
(and
|
||||||
(= (last vect)
|
(= (last vect)
|
||||||
(state/peek-stack end-state (keyword value-type)))
|
(state/peek-stack end-state (keyword value-type)))
|
||||||
(state/empty-stack? end-state stack-type)))))))
|
(state/empty-stack? end-state stack-type)))))
|
||||||
|
|
||||||
(defmacro last-spec
|
(defmacro last-spec
|
||||||
[generator value-type]
|
[generator value-type]
|
||||||
`(defspec ~(symbol (str "last-spec-" value-type))
|
`(defspec ~(symbol (str "last-spec-" value-type))
|
||||||
100
|
100
|
||||||
(check-last ~generator ~value-type)))
|
(prop/for-all [vect# (gen/vector ~generator)]
|
||||||
|
(check-last vect# ~value-type))))
|
||||||
|
|
||||||
(last-spec gen/small-integer "integer")
|
(last-spec gen/small-integer "integer")
|
||||||
(last-spec gen/double "float")
|
(last-spec gen/double "float")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user