added str and some boolean tests
This commit is contained in:
parent
348a770a3d
commit
38aa695bad
32
test/propeller/push/instructions/bool_spec.clj
Normal file
32
test/propeller/push/instructions/bool_spec.clj
Normal 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))))
|
10
test/propeller/push/instructions/numeric_spec.clj
Normal file
10
test/propeller/push/instructions/numeric_spec.clj
Normal 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
22
test/propeller/tools/metrics_test.cljc
Normal file
22
test/propeller/tools/metrics_test.cljc
Normal 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)))
|
Loading…
x
Reference in New Issue
Block a user