added str and some boolean tests

This commit is contained in:
Julia Schor 2022-01-14 13:40:31 -05:00
parent 348a770a3d
commit 38aa695bad
4 changed files with 574 additions and 510 deletions

View File

@ -0,0 +1,32 @@
(ns propeller.push.instructions.bool-spec
(:require
;[clojure.boolean :as bool]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test.check.clojure-test :as ct :refer [defspec]]
[propeller.push.state :as state]
[propeller.push.instructions :as instructions]
[propeller.push.instructions.string :as string-instructions]
[propeller.push.interpreter :as interpreter]))
;;boolean/and
(defn check-and
[value1 value2]
(let [start-state (-> state/empty-state
(state/push-to-stack :boolean value1)
(state/push-to-stack :boolean value2))
end-state ((:boolean_and @instructions/instruction-table) start-state)
expected-result (and value1 value2)]
(= expected-result
(state/peek-stack end-state :boolean))))
;; boolean/or
(defn check-or
[value1 value2]
(let [start-state (-> state/empty-state
(state/push-to-stack :boolean value1)
(state/push-to-stack :boolean value2))
end-state ((:boolean_or @instructions/instruction-table) start-state)
expected-result (or value1 value2)]
(= expected-result
(state/peek-stack end-state :boolean))))

View File

@ -0,0 +1,10 @@
(ns propeller.push.instructions.numeric-spec
(:require
; [clojure.numer :as string]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test.check.clojure-test :as ct :refer [defspec]]
[propeller.push.state :as state]
[propeller.push.instructions :as instructions]
[propeller.push.instructions.bool :as boolean-instructions]
[propeller.push.interpreter :as interpreter]))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
(ns propeller.tools.metrics-test
(:require [clojure.test :as t]
[propeller.tools.metrics :as m]
[propeller.tools.math :as a]))
(t/deftest mean-test
(t/is (= (m/mean '(1 2 3 4)) 2.5))
(t/is (= (m/mean '()) 0)))
(t/deftest median-test
(t/is (= (m/median '(1 2 3 4 5)) 3))
(t/is (= (m/median '(1 2 3 4)) 2.5))
;(t/is (= (m/median '()) 0.0))
)
(t/deftest levenshtein-distance-test
(t/is (= (m/levenshtein-distance "kitten" "sipping") 5))
(t/is (= (m/levenshtein-distance "" "hello")) 5))
(t/deftest sequence-similarity-test
(t/is (a/approx= (m/sequence-similarity "kitten" "sipping") 0.2857 0.001))
(t/is (= (m/sequence-similarity "" "") 1)))