Add plan to each test
This commit is contained in:
parent
0cbc43927d
commit
ba0915f384
21 changed files with 47 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
|||
(plan 7)
|
||||
|
||||
(let ((a 'ok))
|
||||
(and nil (set a 'fail))
|
||||
(expect "and - Short circuit" (equal a 'ok)))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 5)
|
||||
|
||||
(expect "block - return last value"
|
||||
(equal 'top (block nil 'top)))
|
||||
|
||||
|
|
2
t/bool.t
2
t/bool.t
|
@ -1,3 +1,5 @@
|
|||
(plan 12)
|
||||
|
||||
;; Constants
|
||||
|
||||
(expect "True is true" (eq 1 (if t 1 0)))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
(plan 3)
|
||||
;; This is a comment
|
||||
(expect "Comment does not influence code" t)
|
||||
;; Another comment
|
||||
|
|
2
t/cond.t
2
t/cond.t
|
@ -1,3 +1,5 @@
|
|||
(plan 1)
|
||||
|
||||
(expect "cond"
|
||||
(equal 'ok
|
||||
(cond ((> 1 2) 'fail)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 3)
|
||||
|
||||
(let ((a 2))
|
||||
(let ((a 10))
|
||||
(expect "Inner variable shadows outer" (= a 10)))
|
||||
|
|
2
t/do.t
2
t/do.t
|
@ -1,3 +1,5 @@
|
|||
(plan 3)
|
||||
|
||||
(expect "do - simple example"
|
||||
(equal (do ((n 1)) (t n)) 1))
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 1)
|
||||
|
||||
(defun range (start end)
|
||||
(do ((lst (list) (cons i lst)) (i start (+ 1 i))) ((= i end) lst)))
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 1)
|
||||
|
||||
(let ((result
|
||||
(do ((a 1 b) (b 2 (+ a b)) (sum 0)) ((> b 4000000) sum)
|
||||
(when (evenp b)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 5)
|
||||
|
||||
(defun inc (a) (+ a 1))
|
||||
|
||||
(expect "inc 5 == 6" (eq (inc 5) 6))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 3)
|
||||
|
||||
(let ((a 'a)
|
||||
(b 'b))
|
||||
(expect "equal to itself" (equal a a))
|
||||
|
|
2
t/let.t
2
t/let.t
|
@ -1,3 +1,5 @@
|
|||
(plan 4)
|
||||
|
||||
(let ((a 5) (b 6))
|
||||
(expect "a is 5" (= a 5))
|
||||
(expect "b is 6" (= b 6))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 18)
|
||||
|
||||
(let ((lst (list 1 2 3)))
|
||||
(write "# lst = ") (write-line lst)
|
||||
(expect "Length of list is 3" (= (length lst) 3))
|
||||
|
|
2
t/loop.t
2
t/loop.t
|
@ -1,3 +1,5 @@
|
|||
(plan 1)
|
||||
|
||||
(expect "loop"
|
||||
(equal (let ((i 0))
|
||||
(loop (set i (+ i 1))
|
||||
|
|
2
t/math.t
2
t/math.t
|
@ -1,3 +1,5 @@
|
|||
(plan 16)
|
||||
|
||||
(expect "+ - 3 parameters" (= (+ 2 4 2) 8))
|
||||
(expect "- - 3 parameters" (= (- 8 2 3) 3))
|
||||
(expect "* - 2 parameters" (= (* 5 6) 30))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 2)
|
||||
|
||||
;; Factorial
|
||||
|
||||
(defun factorial (n)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 4)
|
||||
|
||||
(expect "length of string" (= (length "hello") 5))
|
||||
|
||||
(expect "string-upcase" (string= (string-upcase "helLo") "HELLO"))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 5)
|
||||
|
||||
(expect "catch - without throw"
|
||||
(equal 'ok
|
||||
(catch 'exc1
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
(plan 5)
|
||||
|
||||
(expect "unless - true condition"
|
||||
(null (unless t 'fail)))
|
||||
|
||||
|
|
2
t/when.t
2
t/when.t
|
@ -1,3 +1,5 @@
|
|||
(plan 5)
|
||||
|
||||
(expect "when - true condition"
|
||||
(equal 'ok (when t 'ok)))
|
||||
|
||||
|
|
|
@ -15,25 +15,29 @@ die "No script file provided." unless defined $scriptfile && -f $scriptfile;
|
|||
|
||||
my $parsed = Minilisp::compile_file($scriptfile);
|
||||
|
||||
my $plan = 0;
|
||||
my $expected_plan;
|
||||
|
||||
my $ctx = {
|
||||
'expect' => sub {
|
||||
my ($desc, $success) = @_;
|
||||
print "not " unless $success;
|
||||
print "ok - $desc\n";
|
||||
$plan++;
|
||||
},
|
||||
comment => sub {
|
||||
my ($v) = @_;
|
||||
print "# " . Minilisp::lisp_format($v) . "\n";
|
||||
},
|
||||
plan => sub {
|
||||
die "Multiple plans" if defined $expected_plan;
|
||||
$expected_plan = shift;
|
||||
}
|
||||
};
|
||||
|
||||
print "TAP Version 13\n";
|
||||
$parsed->($ctx);
|
||||
|
||||
die "No tests" unless $plan > 0;
|
||||
print "1..$plan\n";
|
||||
die "No plan" unless defined $expected_plan;
|
||||
|
||||
print "1..$expected_plan\n";
|
||||
|
||||
exit 0;
|
||||
|
|
Loading…
Reference in a new issue