diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj new file mode 100644 index 0000000..7f5b76d --- /dev/null +++ b/test/propeller/push/instructions/string_spec.clj @@ -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))) + +