summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eval.c2
-rw-r--r--tests/012/case.tl32
2 files changed, 33 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 4e640923..066a8f2a 100644
--- a/eval.c
+++ b/eval.c
@@ -4166,7 +4166,7 @@ static val me_case(val form, val menv)
hash_keys = keys = expand_eval(cons(list_s, keys), nil, menv);
}
- if (consp(keys) && !cdr(keys))
+ if (consp(keys) && atom(car(keys)) && !cdr(keys))
keys = car(keys);
if (atom(keys)) {
diff --git a/tests/012/case.tl b/tests/012/case.tl
new file mode 100644
index 00000000..856ac56c
--- /dev/null
+++ b/tests/012/case.tl
@@ -0,0 +1,32 @@
+(load "../common")
+
+(mtest
+ (caseq 0 (1 :match)) nil
+ (caseq 0 ((1) :match)) nil
+ (caseq 1 (1 :match)) :match
+ (caseq 1 ((1) :match)) :match
+ (caseq 1 ((0 1) :match)) :match
+ (caseq 1 ((0 2) :match)) nil
+ (caseq 1 (t :match)) :match
+ (caseq 1 ((t) :match)) nil
+ (caseq t ((t) :match)) :match)
+
+(defvar o 1)
+(defvar y t)
+
+(mtest
+ (caseq* 0 (o :match)) nil
+ (caseq* 0 ((o) :match)) nil
+ (caseq* 1 (o :match)) :match
+ (caseq* 1 ((o) :match)) :match
+ (caseq* 1 ((0 o) :match)) :match
+ (caseq* 1 ((0 2) :match)) nil
+ (caseq* 1 (t :match)) :match
+ (caseq* 1 (y :match)) nil
+ (caseq* 1 ((t) :match)) nil
+ (caseq* t ((t) :match)) :match
+ (caseq* t ((y) :match)) :match)
+
+(test (casequal '(a b c d)
+ (((a b c d)) :match))
+ :match)