From 3fb35d7d472ce4bdae9e462f386504455427a7d8 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 1 Apr 2021 11:12:26 -0500 Subject: [PATCH] Add a test for `string/replace-char` This adds a test for the `string/replace-char` 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 8f96c70..f95714f 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -369,3 +369,23 @@ str2 gen/string str3 gen/string] (check-replace str1 str2 str3))) + + +;; string/replace-char + +(defn check-replace-char + [value char1 char2] + (let [start-state (-> state/empty-state + (state/push-to-stack :string value) + (state/push-to-stack :char char1) + (state/push-to-stack :char char2)) + end-state ((:string_replace_char @core/instruction-table) start-state) + expected-result (string/replace value char1 char2)] + (= expected-result + (state/peek-stack end-state :string)))) + +(defspec replace-char-spec 100 + (prop/for-all [str gen/string + char1 gen/char + char2 gen/char] + (check-replace str char1 char2))) \ No newline at end of file