From 95cad31e7b57311d5acf16f6dff45d409b7e473c Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 1 Apr 2021 11:07:01 -0500 Subject: [PATCH] Add a test for `string/replace` This adds a test for the `string/replace` instruction --- .../push/instructions/string_spec.clj | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj index f29109a..8f96c70 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -349,3 +349,23 @@ (prop/for-all [str gen/string char gen/char] (check-remove-char str char))) + + +;; string/replace + +(defn check-replace + [value1 value2 value3] + (let [start-state (-> state/empty-state + (state/push-to-stack :string value1) + (state/push-to-stack :string value2) + (state/push-to-stack :string value3)) + end-state ((:string_replace @core/instruction-table) start-state) + expected-result (string/replace value1 value2 value3)] + (= expected-result + (state/peek-stack end-state :string)))) + +(defspec replace-spec 100 + (prop/for-all [str1 gen/string + str2 gen/string + str3 gen/string] + (check-replace str1 str2 str3)))