Add test for string/butlast
This adds a test for the `string/butlast` instruction
This commit is contained in:
parent
5c4d033c4f
commit
e21ca24d9d
27
test/propeller/push/instructions/string_spec.clj
Normal file
27
test/propeller/push/instructions/string_spec.clj
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
(ns propeller.push.instructions.string-spec
|
||||||
|
(:require
|
||||||
|
[clojure.test.check.generators :as gen]
|
||||||
|
[clojure.test.check.properties :as prop]
|
||||||
|
[clojure.test.check.clojure-test :as ct :refer [defspec]]
|
||||||
|
[propeller.push.state :as state]
|
||||||
|
[propeller.push.core :as core]
|
||||||
|
[propeller.push.instructions.string :as string]))
|
||||||
|
|
||||||
|
|
||||||
|
;; string/butlast
|
||||||
|
|
||||||
|
(defn check-butlast
|
||||||
|
[value]
|
||||||
|
(let [start-state (state/push-to-stack state/empty-state
|
||||||
|
:string
|
||||||
|
value)
|
||||||
|
end-state ((:string_butlast @core/instruction-table) start-state)
|
||||||
|
expected-result (apply str (butlast value))]
|
||||||
|
(= expected-result
|
||||||
|
(state/peek-stack end-state :string))))
|
||||||
|
|
||||||
|
(defspec butlast-spec 100
|
||||||
|
(prop/for-all [s gen/string]
|
||||||
|
(check-butlast s)))
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user