From d3b876492c2d640c8322d7336beefdc6eca74082 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 18 Mar 2021 23:05:13 -0500 Subject: [PATCH] Add a test for `string/from-char` This adds a test for the `string/from-char` instruction --- .../propeller/push/instructions/string_spec.clj | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/propeller/push/instructions/string_spec.clj b/test/propeller/push/instructions/string_spec.clj index 1f29a4f..6c2b571 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -163,4 +163,19 @@ (defspec from-boolean-spec 10 (prop/for-all [bool gen/boolean] - (check-from-boolean bool))) \ No newline at end of file + (check-from-boolean bool))) + + +;; string/from-char + +(defn check-from-char + [value] + (let [start-state (state/push-to-stack state/empty-state :char value) + end-state ((:string_from_char @core/instruction-table) start-state) + expected-result (str value)] + (= expected-result + (state/peek-stack end-state :string)))) + +(defspec from-char-spec 10 + (prop/for-all [char gen/char] + (check-from-char char))) \ No newline at end of file