move expect macro nearer its first use

main
Daniel Barlow 2023-01-22 22:09:34 +00:00
parent 64c9fd7b88
commit 8b638fcc18
1 changed files with 16 additions and 12 deletions

View File

@ -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")