From 3ef9b8f888bf2dda7ce690a84a60bbade0223933 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Mon, 26 Oct 2020 21:46:54 +0300 Subject: feature(testing): group tests, update coverage script --- test.fnl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'test.fnl') diff --git a/test.fnl b/test.fnl index da25c26..0e797bd 100644 --- a/test.fnl +++ b/test.fnl @@ -29,12 +29,17 @@ ([expr msg] `(assert ,expr (.. "assertion failed for " (or ,msg ,(tostring expr)))))) -(fn* test +(fn* deftest [name docstring & tests] + "Simple way of grouping tests" + `(do + ,docstring + ,((or table.unpack _G.unpack) tests))) + +(fn* testing "Define test function, print its name and run it." - [name docstring & body] + [name & body] (let [test-name (sym (.. (tostring name) "-test"))] `(do (fn ,test-name [] - ,(or docstring nil) ,((or table.unpack _G.unpack) body)) (io.stderr:write (.. "running: " ,(tostring test-name) "\n")) (,test-name)))) @@ -42,4 +47,5 @@ {: assert-eq : assert-ne : assert* - : test} + : deftest + : testing} -- cgit v1.2.3