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
|
||||
|
||||
(defn check-empty-vector
|
||||
[generator value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))]
|
||||
(prop/for-all [vect (gen/vector generator)]
|
||||
(let [start-state (state/push-to-stack state/empty-state
|
||||
[vect value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))
|
||||
start-state (state/push-to-stack state/empty-state
|
||||
stack-type
|
||||
vect)
|
||||
end-state (vector/_emptyvector stack-type start-state)]
|
||||
(= (empty? vect)
|
||||
(state/peek-stack end-state :boolean))))))
|
||||
(state/peek-stack end-state :boolean))))
|
||||
|
||||
(defmacro empty-vector-spec
|
||||
[generator value-type]
|
||||
`(defspec ~(symbol (str "empty-vector-spec-" value-type))
|
||||
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/double "float")
|
||||
@ -81,10 +81,9 @@
|
||||
;;; vector/_first
|
||||
|
||||
(defn check-first
|
||||
[generator value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))]
|
||||
(prop/for-all [vect (gen/vector generator)]
|
||||
(let [start-state (state/push-to-stack state/empty-state
|
||||
[vect value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))
|
||||
start-state (state/push-to-stack state/empty-state
|
||||
stack-type
|
||||
vect)
|
||||
end-state (vector/_first stack-type start-state)]
|
||||
@ -95,13 +94,14 @@
|
||||
(and
|
||||
(= (first vect)
|
||||
(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
|
||||
[generator value-type]
|
||||
`(defspec ~(symbol (str "first-spec-" value-type))
|
||||
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/double "float")
|
||||
@ -111,10 +111,9 @@
|
||||
;;; vector/_last
|
||||
|
||||
(defn check-last
|
||||
[generator value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))]
|
||||
(prop/for-all [vect (gen/vector generator)]
|
||||
(let [start-state (state/push-to-stack state/empty-state
|
||||
[vect value-type]
|
||||
(let [stack-type (keyword (str "vector_" value-type))
|
||||
start-state (state/push-to-stack state/empty-state
|
||||
stack-type
|
||||
vect)
|
||||
end-state (vector/_last stack-type start-state)]
|
||||
@ -125,13 +124,14 @@
|
||||
(and
|
||||
(= (last vect)
|
||||
(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
|
||||
[generator value-type]
|
||||
`(defspec ~(symbol (str "last-spec-" value-type))
|
||||
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/double "float")
|
||||
|
Loading…
x
Reference in New Issue
Block a user