为什么这两个序列不相等?

时间:2012-10-31 13:26:13

标签: clojure leiningen

我的问题是为什么我的预期和生成的序列不同?我无法通过视觉检查看出原因。

在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))

违背预期的顺序。这是测试的核心序列.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.

1 个答案:

答案 0 :(得分:1)

显然:parcelid2不是:parcel_id2