From 227a41b3762703c1fb5110bda9a1113c69f164c8 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Tue, 16 Mar 2021 22:43:59 -0500 Subject: [PATCH] Add test for `string/contains` This adds a test for the `string/contains` instruction --- .../push/instructions/string_spec.clj | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj index 8b4dc61..10700a4 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -58,4 +58,22 @@ (defspec conj-char-spec 100 (prop/for-all [str gen/string char gen/char] - (check-concat str char))) \ No newline at end of file + (check-concat str char))) + + +;; string/contains + +(defn check-contains + [value1 value2] + (let [start-state (-> state/empty-state + (state/push-to-stack :string value1) + (state/push-to-stack :string value2)) + end-state ((:string_contains @core/instruction-table) start-state) + expected-result (string/includes? value2 value1)] + (= expected-result + (state/peek-stack end-state :boolean)))) + +(defspec contains-spec 100 + (prop/for-all [str1 gen/string + str2 gen/string] + (check-contains str1 str2))) \ No newline at end of file