diff --git a/rover.fnl b/rover.fnl index f2335b3..822cc4c 100644 --- a/rover.fnl +++ b/rover.fnl @@ -1,18 +1,6 @@ (local { : view } (require :fennel)) (local { : merge } (require :lume)) -;; who needs a test framework when you have lisp macros? -(macro expect [text actual expected] - `(let [actual# ,actual] - (or (match actual# - ,expected true) - (assert false (view { - :text ,text - :expected ,(view expected) - :actual actual# - }))))) - - (fn wrap-longitude [x] (if (<= x -180) (wrap-longitude (+ x 360)) (< 180 x) (wrap-longitude (- x 360)) @@ -80,6 +68,19 @@ : direction }) +;;;; TESTS + +;; who needs a test framework when you have lisp macros? +(macro expect [text actual expected] + `(let [actual# ,actual] + (or (match actual# + ,expected true) + (assert false (view { + :text ,text + :expected ,(view expected) + :actual actual# + }))))) + (let [r (rover 7 15 :n)] (expect "rover knows (x,y) and the direction (N,S,E,W) it is facing" @@ -182,4 +183,7 @@ (execute (rover 0 89 :n) [:f :r :f]) {:x 90 :y 89 :direction :s}) + +;; "TODO: deal with the south pole special casing" + (print "OK")