Commit 3a72c730 authored by Alf Kristian Støyle's avatar Alf Kristian Støyle

One more assertion, and some spaces.

parent 5a43b12a
......@@ -8,14 +8,17 @@
(defmacro infix-s [form]
`(~(second form) ~(first form) ~(nth form 2)))
(fact "Should handle simple infix"
(infix-s (1 + 2)) => 3)
(infix-s (1 + 2)) => 3
(macroexpand '(infix-s (1 + 2))) => '(+ 1 2))
(defmacro infix-v
([& forms]
`(~(second forms) ~(first forms) ~(nth forms 2))))
(fact "Should handle variable arity infix"
(infix-v 1 + 2) => 3)
......@@ -25,6 +28,7 @@
(let [s (if (seq? (first forms)) (first forms) forms)]
`(~(second s) ~(first s) ~(nth s 2)))))
(fact "Should both variable and fixed arity"
(infix-g 1 + 2) => 3
(infix-g (1 + 2)) => 3)
......@@ -41,6 +45,7 @@
(infix-r ~first-arg)
(infix-r ~others)))))
(fact "Should handle recurisve infix"
(infix-r (1 + 2 + 3)) => 6)
......@@ -48,11 +53,13 @@
(defmacro infix-rg [& form]
`(infix-r ~form))
(fact "Should handle virable arity recurisve infix"
(infix-rg 1 + 2 + 3) => 6
(infix-rg (1 + 2 + 3)) => 6
(infix-rg (10 + (2 * 3) + (4 * 5))) => 36)
(defmacro infix-full [form]
form)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment