Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svetlyak40wt/fff6f40d1534608cda0c to your computer and use it in GitHub Desktop.
Save svetlyak40wt/fff6f40d1534608cda0c to your computer and use it in GitHub Desktop.
Фреймворк для юнит-тестирования на jisp
(= tests `())
(def pr line
(process.stdout.write line))
(def prn line
(pr (+ line "\n")))
(mac test name ...body
`(do (tests.push (list ,(JSON.stringify name) ,name))
(def ,name (do ,...body))))
(def eq left right
(if (!= left right)
(throw (Error (+ "Assertion error:" left " != " right)))))
(def run_tests
(for item tests
(do
(pr (+ "processing " item[0] "..."))
(try (do (item[1])
(prn "OK"))
(catch err (do (prn "ERROR")
(prn err)))))))
(test arithmetic
(eq 3 (+ 2 1))
(eq 4 (* 2 1)))
(run_tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment