     (t/is (= {:x {:y {:z "b"}}}
              (p/clause->lhs {} (p/path-matches-without-binding-clause [:x :y :z] (p/match-const "b")))))))
 
+;; FIXME: Why is this 'with-binding' - may we need to add a binding to make this a 'sensible' test?
 (t/deftest path-matches-with-binding-clause->rhs-match-test
   (t/is (= `[~(symbol "z") (get-in {:x {:y {:z "b"}}} [:x :y :z] "b")]
            (p/path-matches-with-binding-clause->rhs-match {:x {:y {:z "b"}}}

(p/defpattern constant-pattern [(X x)])
(def p (p/parse-pattern '[(X x)]))

;; FIXME: Clean up
(t/deftest map-matcher-without-binding-test
  (let [k "my-value"]
    ((p/map-matcher [(:k 23)] (t/is (= "my-value" k))) {:k 23})))

(t/deftest closes-over-outer-variables-test
  (t/testing "with compare-fn"
    (let [evt {"X" "x"}]
      (t/is (= "x"
               ((p/map-matcher [(X (:compare-fn #(= % (get evt "X"))))] x)
                evt)))))
  (t/testing "as local constant"
    (let [x   "x"
          evt {"X" x}]
      (t/is (= x
               ((p/map-matcher [(X x)] x)
                evt)))))
  (t/testing "as global constant"
    (let [evt {"X" x}]
      (t/is (= x
               ((p/map-matcher [(X x)] x)
                evt)))))
  ;; FIXME: Docu below the same, tests different
  (t/testing "as constant with global defpattern"
    (let [x   "x"
          evt {"X" x}]
      (t/is (= x
               ((p/map-matcher constant-pattern x)
                evt)))))
  (t/testing "as constant with global parse-pattern"
    (let [evt {"X" x}]
      (t/is (= x
               ((p/map-matcher p x)
                evt)))))
  (t/testing "as constant with global defpattern"
    (let [x   "x"
          evt {"X" x}]
      (p/defpattern p [("X" x)])
      (t/is (= x
               ((p/map-matcher p x)
                evt)))))
  #_(t/testing "as constant with local parse-pattern"
    (let [x   "x"
          evt {"X" x}

  (t/testing "Very simple examples with binding."
    (t/is (= [] ((p/map-matcher [(:a :as a)] []) {:a "a"})))
    (t/is (= ["a"] ((p/map-matcher [(:a :as a)] [a]) {:a "a"}))))
  (t/testing "Example-matcher"
    (t/is (= ["x" "z"]
             (example-matcher one-data)))
    (t/is (= ["a" "c" {"Z" 42 "Y" 23 "X" 65 "W" {"foo" "bar"}} 42 23]
             (example-matcher two-data)))
    (t/is (= false (example-matcher {:kind "none"})))
    ;; FIXME: What is the difference between this and the test before?
    (t/testing "map-matcher-regex-key-not-found"
      (t/is (= false (example-matcher three-data))))))

(t/deftest map-matcher-optional-test
  (t/testing "Optional values"
    (t/is (= ["a" "c" "C" 42]
             ((p/map-matcher [(:kind #"two")
                              (? :a :as a)
                              (? :b)
                              (? :c "C" :as c)
                              (? :C "C" :as C)
                              (? [:d Z] :as Z)
                              (? [:d Y] "y")
                              (? [:d U])]
                             [a c C Z])
              two-data))))
  (t/testing "Fall back to given default value."
    (t/is (= ["a" "C" "C" 42]
             ((p/map-matcher [(:kind #"two")
                              (? :a :as a)
                              (? :b)
                              (? :c "C" :as c)
                              (? :C "C" :as C)
                              (? [:d Z] :as Z)
                              (? [:d Y] "y")
                              (? [:d U])]
                             [a c C Z])
              {:kind "two" :a "a" :b "b"
               :d {"Z" 42 "X" 65
                   "W" {"foo" "bar"}}})))))

(p/defpattern one-or
  [(:kind #"one")
