From 19b67cdfecbf85ea040f5c2de5bd5a666c2b389e Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Tue, 16 Mar 2021 23:22:40 -0500 Subject: [PATCH] Add test for `string/drop` This adds a test for the `string/drop` instruction --- .../push/instructions/string_spec.clj | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj index 493f087..50ea2de 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -96,9 +96,21 @@ (prop/for-all [str gen/string char gen/char] (check-contains-char str char))) + + +;; string/drop + +(defn check-drop + [value n] + (let [start-state (-> state/empty-state + (state/push-to-stack :string value) + (state/push-to-stack :integer n)) + end-state ((:string_drop @core/instruction-table) start-state) + expected-result (apply str (drop n value))] + (= expected-result (state/peek-stack end-state :string)))) -(defspec contains-char-spec 100 +(defspec drop-spec 100 (prop/for-all [str gen/string - char gen/string] - (check-concat str char))) \ No newline at end of file + int gen/small-integer] + (check-drop str int))) \ No newline at end of file