move expect macro nearer its first use
This commit is contained in:
parent
64c9fd7b88
commit
8b638fcc18
28
rover.fnl
28
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")
|
||||
|
Loading…
Reference in New Issue
Block a user