title: Function precondition not accepting a verification whether map contains key
body: <p>I'm trying to define a function that receives a pair of x-y coordinates and a direction which a robot is facing (<em>:north</em>, <em>:east</em>, <em>:south</em> and <em>:west</em>).</p>
  
  <p>I defined a map called <em>directions</em> which holds the valid values (and which will be used later for movement).</p>
  
  <pre><code>(def directions {:north {:x 0 :y 1} :east {:x 1 :y 0} :south {:x 0 :y -1} :west {:x -1 :y 0}})
  </code></pre>
  
  <p>And for validation purposes, I created a <em>:pre</em> clause to prevent invalid values for such parameters:</p>
  
  <pre><code>(defn create-robot 
    "Creates a Robot representation, containing its position (x,y) and directions which it is facing"
    [x y direction]
    {:pre [(int? x) (&gt;= x 0)
           (int? y) (&gt;= y 0)
           (contains? directions direction)]}
    (Robot. x y direction))
  </code></pre>
  
  <p>Now, here's the problem: when I run my test, it fails because of this <em>contains?</em> validation. The thing is, I'm using a valid value for my test, still, it is failing.</p>
  
  <pre><code>(let [robot (create-robot 1 2 :north)]
    (expect 1 (:x robot))
    (expect 2 (:y robot))
    (expect :north (:direction robot)))
  </code></pre>
  
  <p>It gives me the following error:</p>
  
  <pre><code>Error refreshing environment: java.lang.AssertionError: Assert failed: (contains? directions direction)
  </code></pre>
  
  <p>Would someone be able to tell me what is wrong? Am I expecting too much from preconditions?</p>
  
  <p>Thanks and Cheers.</p>
  
  <h3>Update</h3>
  
  <p>As required by @Alan Thompson, I added a <em>println</em></p>
  
  <pre><code>(defn create-robot 
    "Creates a Robot representation, containing its position (x,y) and directions which it is facing"
    [x y direction]
    {:pre [(int? x) (&gt;= x 0)
           (int? y) (&gt;= y 0) 
           (or (println direction) true)
           (or (println (directions direction)) true)
           (or (println (str "Contains? " (contains? directions direction))) true)
           (contains? directions direction)]}
    (Robot. x y direction))
  </code></pre>
  
  <p>And the result shows as expected (except that this time the test passes):</p>
  
  <pre><code>*************** Running tests ***************
  :reloading (jaegers.domain jaegers.core jaegers.core-test)
  :north
  {:x 0, :y 1}
  Contains? true
  :north
  {:x 0, :y 1}
  Contains? true
  
  Ran 18 tests containing 18 assertions in 5 msecs
  0 failures, 0 errors.
  Tests completed at 19:17:38.593
  </code></pre>
  
  <p>I don't understand how it works now.</p>