0

我的问题是为什么我的预期和生成的序列不同?目视检查时我不明白为什么。

在 lein 测试中,我正在比较函数 gen-map-keys 返回的序列

(defn gen-map-keys
  "Takes a sequence, and turns it into viable keys for a map.
   We opt to change spaces ' ' to dashes '-'."

  [in-seq]
  (map #(-> % cstr/trim (cstr/replace " " "-") keyword) in-seq))

针对预期的序列。这是测试的 core.clj 中的序列

(deftest test-kind-stat
  (let [existing-fnam "project.clj"
   existing-dir "test"
   non-existing-fnam "file-does-not-exist.not-exist"
   test-key-spaces1 '("COVERAGE DESCRIPTION" "BIL MO")
   test-key-spaces2 '("rectype" "parcel_id1" "parcel_id2" "parcel_id3" "house_num" alt_house_num")

   test-keys       '("key1" "key2" "key3")]

   (is (= '(:key1 :key2 :key3) (gen-map-keys test-keys)))
   (is (= '(:COVERAGE-DESCRIPTION :BILL-MO) (gen-map-keys test-key-spaces1)))
   (is (= '(:rectype :parcel_id1 :parcel_id2 :parcel_id3 :house_num :alt_house_num)            (gen-map-keys test-key-spaces2)))

这是 lein 测试的输出:

FAIL in (test-kind-stat) (core.clj:33)
expected: (= (quote (:COVERAGE-DESCRIPTION :BILL-MO)) (gen-map-keys test-key-spaces1))
  actual: (not (= (:COVERAGE-DESCRIPTION :BILL-MO) (:COVERAGE-DESCRIPTION :BIL-MO)))

Ran 10 tests containing 41 assertions.
1 failures, 0 errors.
4

1 回答 1

1

显然:parcelid2不是:parcel_id2

于 2012-10-31T13:30:38.743 回答