commit 8b638fcc187f9d3bf9d026ea9f339b6a62bbf3a1
parent 64c9fd7b88b8465ce1a84c4f8fead01b467739ff
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 22 Jan 2023 22:09:34 +0000
move expect macro nearer its first use
Diffstat:
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git 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")