From 711fc20f017f9f05da7912ddb4eb2d119fc415e0 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 1 Apr 2021 11:30:02 -0500 Subject: [PATCH] Add a test for `string/reverse` This adds a test for the `string/reverse` instruction --- test/propeller/push/instructions/string_spec.clj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj index 64707c6..30c738c 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -444,3 +444,18 @@ (defspec rest-spec 100 (prop/for-all [str gen/string] (check-rest str))) + + +;; string/reverse + +(defn check-reverse + [value] + (let [start-state (state/push-to-stack state/empty-state :string value) + end-state ((:string_reverse @core/instruction-table) start-state) + expected-result (apply str (reverse value))] + (= expected-result + (state/peek-stack end-state :string)))) + +(defspec reverse-spec 100 + (prop/for-all [str gen/string] + (check-reverse str))) \ No newline at end of file