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