mes: make scm.mes compatible with guile
* mes/module/mes/scm.mes (iota): Throw exception when n < 0 * tests/scm.test: import (mes catch) * tests/scm.test ("iota -1"): Rewrite with exception handling
This commit is contained in:
parent
e0e560895d
commit
71934c9356
|
@ -164,8 +164,10 @@
|
||||||
(list-tail (cdr x) (- n 1))))
|
(list-tail (cdr x) (- n 1))))
|
||||||
|
|
||||||
(define (iota n)
|
(define (iota n)
|
||||||
(if (<= n 0) '()
|
(cond
|
||||||
(append2 (iota (- n 1)) (list (- n 1)))))
|
((< n 0) (throw 'wrong-type-arg n))
|
||||||
|
((= n 0) '())
|
||||||
|
(else (append2 (iota (- n 1)) (list (- n 1))))))
|
||||||
|
|
||||||
(define (reverse lst)
|
(define (reverse lst)
|
||||||
(let loop ((lst lst) (r '()))
|
(let loop ((lst lst) (r '()))
|
||||||
|
|
|
@ -30,6 +30,8 @@ exec ${MES-bin/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests
|
||||||
#:use-module (mes mes-0)
|
#:use-module (mes mes-0)
|
||||||
#:use-module (mes test))
|
#:use-module (mes test))
|
||||||
|
|
||||||
|
(mes-use-module (mes catch))
|
||||||
|
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(mes
|
(mes
|
||||||
(primitive-load "module/mes/test.scm"))
|
(primitive-load "module/mes/test.scm"))
|
||||||
|
@ -131,7 +133,12 @@ exec ${MES-bin/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests
|
||||||
'() (iota 0))
|
'() (iota 0))
|
||||||
|
|
||||||
(pass-if-equal "iota -1"
|
(pass-if-equal "iota -1"
|
||||||
'() (iota -1))
|
'iota-negative-length
|
||||||
|
(catch 'wrong-type-arg
|
||||||
|
(lambda ()
|
||||||
|
(iota -1))
|
||||||
|
(lambda (key . args)
|
||||||
|
'iota-negative-length)))
|
||||||
|
|
||||||
(pass-if "cond-expand" (sequal? (cond-expand (foobar #f) (mes (display ": pass: *YAY*") 'mes) (guile (display ": pass: *GUILE*") 'mes)) 'mes))
|
(pass-if "cond-expand" (sequal? (cond-expand (foobar #f) (mes (display ": pass: *YAY*") 'mes) (guile (display ": pass: *GUILE*") 'mes)) 'mes))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue