core: Bugfix append with one argument.

* mes.c (append): Handle one argument.
* tests/base.test ("append", "append 0" ... "append 5"): New tests.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-22 14:22:40 +01:00
parent 681a541774
commit 6854627391
2 changed files with 8 additions and 0 deletions

1
mes.c
View File

@ -665,6 +665,7 @@ SCM
append (SCM x) ///((arity . n))
{
if (x == cell_nil) return cell_nil;
if (cdr (x) == cell_nil) return car (x);
return append2 (car (x), append (cdr (x)));
}

View File

@ -44,6 +44,13 @@ exit $?
(pass-if "if 3" (seq? (if (seq? 0 '0) 'true 'false) 'true))
(pass-if "if 4" (seq? (if (= 1 2) 'true 'false) 'false))
(pass-if-equal "append" '(0 1) (append '(0) '(1)))
(pass-if-equal "append 1" '0 (append '() 0))
(pass-if-equal "append 2" '(0) (append '(0) '()))
(pass-if-equal "append 3" 0 (append 0))
(pass-if-equal "append 4" 'cons (append (cdr '(c)) (car '(cons))))
(pass-if-equal "append 5" '(0 1 2) (append '(0) '(1) '(2)))
;;(pass-if ">=" (seq? (>= 3 2 1) #t))
(if (defined? 'cond)