From 1628e669b6f9ef57e7af58285fe020b3abad6670 Mon Sep 17 00:00:00 2001 From: Erik Rauer Date: Thu, 15 Apr 2021 15:12:42 -0500 Subject: [PATCH] Add a test for `string/split` This adds a test for the `string/split` 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 f38aad8..d5e6e99 100644 --- a/test/propeller/push/instructions/string_spec.clj +++ b/test/propeller/push/instructions/string_spec.clj @@ -488,3 +488,23 @@ char gen/char int gen/small-integer] (check-set-char str char int))) + + +;; string/split + +(defn check-split + [value] + (let [start-state (state/push-to-stack state/empty-state :string value) + end-state ((:string_split @core/instruction-table) start-state) + our-split (string/split (string/trim value) #"\s+") + num-items (count our-split)] + (and + (= (state/stack-size end-state :string) num-items) + (every? identity + (map = + our-split + (state/peek-stack-many end-state :string num-items)))))) + +(defspec split-spec 100 + (prop/for-all [str gen/string] + (check-split str))) \ No newline at end of file