From 41fe73946394094242c64567a17f423fa796c238 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 29 Apr 2018 18:14:01 +0200 Subject: [PATCH] core: reverse!: Handle empty list. * src/mes.c (reverse_x_): Handle empty list. * tests/scm.test ("reverse! ()"): Test it. --- src/mes.c | 2 +- tests/scm.test | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mes.c b/src/mes.c index 6f3c4a51..e66f6b00 100644 --- a/src/mes.c +++ b/src/mes.c @@ -661,7 +661,7 @@ append_reverse (SCM x, SCM y) SCM reverse_x_ (SCM x, SCM t) { - if (TYPE (x) != TPAIR) + if (x != cell_nil && TYPE (x) != TPAIR) error (cell_symbol_not_a_pair, cons (x, cell_reverse_x_)); SCM r = t; while (x != cell_nil) diff --git a/tests/scm.test b/tests/scm.test index bb4c2cc4..a01465e8 100755 --- a/tests/scm.test +++ b/tests/scm.test @@ -137,6 +137,9 @@ exit $? (reverse! list) list)) +(pass-if-equal "reverse! ()" '() + (reverse! '())) + (pass-if "cond-expand" (sequal? (cond-expand (foobar #f) (mes (display ": pass: *YAY*") 'mes) (guile (display ": pass: *GUILE*") 'mes)) 'mes)) (pass-if "apply identity" (seq? (apply identity '(0)) 0))