2001-03-02 01:38:01 +00:00
|
|
|
;;;; syntax.test --- test suite for Guile's syntactic forms -*- scheme -*-
|
|
|
|
|
;;;;
|
2003-08-12 21:39:56 +00:00
|
|
|
;;;; Copyright (C) 2001, 2003 Free Software Foundation, Inc.
|
2001-03-02 01:38:01 +00:00
|
|
|
;;;;
|
|
|
|
|
;;;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;;;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;;;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
;;;; any later version.
|
|
|
|
|
;;;;
|
|
|
|
|
;;;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;;; GNU General Public License for more details.
|
|
|
|
|
;;;;
|
|
|
|
|
;;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;;; along with this software; see the file COPYING. If not, write to
|
|
|
|
|
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
|
;;;; Boston, MA 02111-1307 USA
|
|
|
|
|
|
2003-09-22 19:00:41 +00:00
|
|
|
(define-module (test-suite test-syntax)
|
|
|
|
|
:use-module (test-suite lib))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
|
|
|
|
|
(define exception:bad-expression
|
|
|
|
|
(cons 'syntax-error "Bad expression"))
|
2003-10-11 16:03:29 +00:00
|
|
|
|
2003-10-18 14:49:55 +00:00
|
|
|
(define exception:missing/extra-expr
|
2003-11-01 07:26:44 +00:00
|
|
|
(cons 'syntax-error "Missing or extra expression"))
|
2003-10-11 16:03:29 +00:00
|
|
|
(define exception:missing-expr
|
|
|
|
|
(cons 'syntax-error "Missing expression"))
|
2003-11-08 08:11:14 +00:00
|
|
|
(define exception:missing-body-expr
|
|
|
|
|
(cons 'syntax-error "Missing body expression"))
|
2003-10-11 16:03:29 +00:00
|
|
|
(define exception:extra-expr
|
|
|
|
|
(cons 'syntax-error "Extra expression"))
|
2003-11-01 07:26:44 +00:00
|
|
|
(define exception:illegal-empty-combination
|
|
|
|
|
(cons 'syntax-error "Illegal empty combination"))
|
2003-10-11 16:03:29 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(define exception:bad-bindings
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
(cons 'syntax-error "Bad bindings"))
|
|
|
|
|
(define exception:bad-binding
|
|
|
|
|
(cons 'syntax-error "Bad binding"))
|
|
|
|
|
(define exception:duplicate-binding
|
|
|
|
|
(cons 'syntax-error "Duplicate binding"))
|
2001-03-02 01:38:01 +00:00
|
|
|
(define exception:bad-body
|
|
|
|
|
(cons 'misc-error "^bad body"))
|
|
|
|
|
(define exception:bad-formals
|
2003-10-12 20:47:32 +00:00
|
|
|
(cons 'syntax-error "Bad formals"))
|
|
|
|
|
(define exception:bad-formal
|
|
|
|
|
(cons 'syntax-error "Bad formal"))
|
|
|
|
|
(define exception:duplicate-formal
|
|
|
|
|
(cons 'syntax-error "Duplicate formal"))
|
2003-10-11 16:03:29 +00:00
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:missing-clauses
|
|
|
|
|
(cons 'syntax-error "Missing clauses"))
|
2003-10-11 10:40:19 +00:00
|
|
|
(define exception:misplaced-else-clause
|
|
|
|
|
(cons 'syntax-error "Misplaced else clause"))
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(define exception:bad-case-clause
|
|
|
|
|
(cons 'syntax-error "Bad case clause"))
|
|
|
|
|
(define exception:bad-case-labels
|
|
|
|
|
(cons 'syntax-error "Bad case labels"))
|
2003-10-11 10:40:19 +00:00
|
|
|
(define exception:bad-cond-clause
|
|
|
|
|
(cons 'syntax-error "Bad cond clause"))
|
2003-10-11 16:03:29 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "expressions"
|
|
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(with-test-prefix "Bad argument list"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "improper argument list of length 1"
|
|
|
|
|
exception:wrong-num-args
|
|
|
|
|
(eval '(let ((foo (lambda (x y) #t)))
|
|
|
|
|
(foo . 1))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "improper argument list of length 2"
|
|
|
|
|
exception:wrong-num-args
|
|
|
|
|
(eval '(let ((foo (lambda (x y) #t)))
|
|
|
|
|
(foo 1 . 2))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "missing or extra expression"
|
|
|
|
|
|
|
|
|
|
;; R5RS says:
|
|
|
|
|
;; *Note:* In many dialects of Lisp, the empty combination, (),
|
|
|
|
|
;; is a legitimate expression. In Scheme, combinations must
|
|
|
|
|
;; have at least one subexpression, so () is not a syntactically
|
|
|
|
|
;; valid expression.
|
2001-03-03 17:29:09 +00:00
|
|
|
|
|
|
|
|
;; Fixed on 2001-3-3
|
|
|
|
|
(pass-if-exception "empty parentheses \"()\""
|
2003-11-01 07:26:44 +00:00
|
|
|
exception:illegal-empty-combination
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '()
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "quote"
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "quasiquote"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "unquote"
|
|
|
|
|
|
|
|
|
|
(pass-if "repeated execution"
|
|
|
|
|
(let ((foo (let ((i 0)) (lambda () (set! i (+ i 1)) `(,i)))))
|
|
|
|
|
(and (equal? (foo) '(1)) (equal? (foo) '(2))))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "unquote-splicing"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "extra arguments"
|
|
|
|
|
exception:missing/extra-expr
|
|
|
|
|
(quasiquote ((unquote-splicing (list 1 2) (list 3 4)))))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "begin"
|
|
|
|
|
|
|
|
|
|
(pass-if "legal (begin)"
|
|
|
|
|
(begin)
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(expect-fail-exception "illegal (begin)"
|
|
|
|
|
exception:bad-body
|
|
|
|
|
(if #t (begin))
|
|
|
|
|
#t))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "lambda"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad formals"
|
|
|
|
|
|
2001-10-13 23:59:27 +00:00
|
|
|
(pass-if-exception "(lambda)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda . \"foo\")"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:bad-expression
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda \"foo\")"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda \"foo\" #f)"
|
|
|
|
|
exception:bad-formals
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(lambda "foo" #f)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 23:59:27 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda (x 1) 2)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:bad-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x 1) 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda (1 x) 2)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:bad-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (1 x) 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda (x \"a\") 2)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:bad-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x "a") 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda (\"a\" x) 2)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:bad-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda ("a" x) 2)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 17:29:09 +00:00
|
|
|
(with-test-prefix "duplicate formals"
|
|
|
|
|
|
|
|
|
|
;; Fixed on 2001-3-3
|
|
|
|
|
(pass-if-exception "(lambda (x x) 1)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:duplicate-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 17:29:09 +00:00
|
|
|
;; Fixed on 2001-3-3
|
|
|
|
|
(pass-if-exception "(lambda (x x x) 1)"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:duplicate-formal
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda (x x x) 1)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(lambda ())"
|
2003-10-12 20:47:32 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(lambda ())
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "let"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "late binding"
|
|
|
|
|
exception:unbound-var
|
|
|
|
|
(let ((x 1) (y x)) y)))
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let (x))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(pass-if-exception "(let ((x)))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x)))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let (x) 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let ((x)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let ((x 1) y) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let ((1 2)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 23:54:42 +00:00
|
|
|
(with-test-prefix "duplicate bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(let ((x 1) (x 2)) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:duplicate-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1) (x 2)) x)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(let ())"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let ((x 1)))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "named let"
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "initializers"
|
|
|
|
|
|
|
|
|
|
(pass-if "evaluated in outer environment"
|
|
|
|
|
(let ((f -))
|
|
|
|
|
(eqv? (let f ((n (f 1))) n) -1))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(let x (y))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x (y))
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(let x ())"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let x ((y 1)))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let x ((y 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "let*"
|
|
|
|
|
|
2001-03-11 23:31:58 +00:00
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if "(let* ((x 1) (x 2)) ...)"
|
|
|
|
|
(let* ((x 1) (x 2))
|
|
|
|
|
(= x 2)))
|
|
|
|
|
|
|
|
|
|
(pass-if "(let* ((x 1) (x x)) ...)"
|
|
|
|
|
(let* ((x 1) (x x))
|
|
|
|
|
(= x 1))))
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let*)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let*)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* (x))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* (x) 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* ((x)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* ((x 1) y) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* x ())"
|
|
|
|
|
exception:bad-bindings
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* x (y))"
|
|
|
|
|
exception:bad-bindings
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* x (y))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* ((1 2)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(let* ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(let* ())"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(let* ((x 1)))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(let* ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "letrec"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "initial bindings are undefined"
|
|
|
|
|
exception:unbound-var
|
|
|
|
|
(let ((x 1))
|
|
|
|
|
(letrec ((x 1) (y x)) y))))
|
|
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "bad bindings"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec (x))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec (x))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec (x) 1)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec (x) 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ((x)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x)) 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ((x 1) y) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1) y) x)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec x ())"
|
|
|
|
|
exception:bad-bindings
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec x ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec x (y))"
|
|
|
|
|
exception:bad-bindings
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec x (y))
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ((1 2)) 3)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(letrec ((1 2)) 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-03-03 23:54:42 +00:00
|
|
|
(with-test-prefix "duplicate bindings"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ((x 1) (x 2)) x)"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:duplicate-binding
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1) (x 2)) x)
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad body"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ())"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ())
|
|
|
|
|
(interaction-environment)))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(letrec ((x 1)))"
|
* libguile/eval.c (scm_m_let, scm_m_letstar, scm_m_letrec,
scm_m_expand_body, check_bindings): Extracted syntax checking of
bindings to new static function check_bindings.
(scm_m_let, memoize_named_let): Extracted handling of named let to
new static function memoize_named_let.
(transform_bindings, scm_m_let, scm_m_letstar, scm_m_letrec): Use
ASSERT_SYNTAX to signal syntax errors. Be more specific about the
kind of error that was detected. Avoid use of SCM_CDRLOC. Avoid
unnecessary consing when creating the memoized code.
* test-suite/lib.scm (exception:bad-variable): New.
* test-suite/tests/syntax.test (exception:bad-binding,
exception:duplicate-binding): New.
(exception:duplicate-bindings): Removed.
Adapted tests for 'let', 'let*' and 'letrec' to the new way of
error reporting.
2003-10-18 12:07:39 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(letrec ((x 1)))
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "if"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(if)"
|
2003-10-18 14:49:55 +00:00
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(if)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(if 1 2 3 4)"
|
2003-10-18 14:49:55 +00:00
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(if 1 2 3 4)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "cond"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "bad or missing clauses"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(cond)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:missing-clauses
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond #t)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond 1)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond 1 2)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond 1 2 3)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2 3)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond 1 2 3 4)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond 1 2 3 4)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond ())"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond ())
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond () 1)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond () 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(cond (1) 1)"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:bad-cond-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(cond (1) 1)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "cond =>"
|
|
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(with-test-prefix "cond is hygienic"
|
|
|
|
|
|
2003-10-11 10:40:19 +00:00
|
|
|
(pass-if "bound 'else is handled correctly"
|
|
|
|
|
(eq? (let ((else 'ok)) (cond (else))) 'ok))
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
|
2003-10-11 10:40:19 +00:00
|
|
|
(pass-if "bound '=> is handled correctly"
|
|
|
|
|
(eq? (let ((=> #f)) (cond (#t => 'ok))) 'ok)))
|
2003-10-07 22:00:05 +00:00
|
|
|
|
2001-10-18 21:59:29 +00:00
|
|
|
(with-test-prefix "else is handled correctly"
|
|
|
|
|
|
|
|
|
|
(pass-if "else =>"
|
|
|
|
|
(let ((=> 'foo))
|
|
|
|
|
(eq? (cond (else =>)) 'foo)))
|
|
|
|
|
|
|
|
|
|
(pass-if "else => identity"
|
|
|
|
|
(let* ((=> 'foo))
|
|
|
|
|
(eq? (cond (else => identity)) identity))))
|
|
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(with-test-prefix "wrong number of arguments"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(pass-if-exception "=> (lambda (x y) #t)"
|
|
|
|
|
exception:wrong-num-args
|
|
|
|
|
(cond (1 => (lambda (x y) #t))))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-10-13 17:02:01 +00:00
|
|
|
(with-test-prefix "case"
|
|
|
|
|
|
2003-10-11 01:52:25 +00:00
|
|
|
(pass-if "clause with empty labels list"
|
|
|
|
|
(case 1 (() #f) (else #t)))
|
|
|
|
|
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
(with-test-prefix "case is hygienic"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "bound 'else is handled correctly"
|
|
|
|
|
exception:bad-case-labels
|
|
|
|
|
(eval '(let ((else #f)) (case 1 (else #f)))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2001-10-13 17:02:01 +00:00
|
|
|
(with-test-prefix "bad or missing clauses"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(case)"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:missing-clauses
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case . \"foo\")"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-expression
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1)"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:missing-clauses
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1)
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 . \"foo\")"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-expression
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 \"foo\")"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-case-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 ())"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-case-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ())
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 (\"foo\"))"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-case-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ("foo"))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 (\"foo\" \"bar\"))"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-case-labels
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ("foo" "bar"))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 ((2) \"bar\") . \"foo\")"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-expression
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ((2) "bar") . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2003-10-07 22:00:05 +00:00
|
|
|
(pass-if-exception "(case 1 ((2) \"bar\") (else))"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-case-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 ((2) "bar") (else))
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 (else #f) . \"foo\")"
|
* libguile/tags.h (SCM_IM_ELSE, SCM_IM_ARROW): New memoizer codes.
* libguile/print.c (scm_isymnames): Add names for the new memoizer
codes.
* libguile/eval.c (s_missing_clauses, s_bad_case_clause,
s_extra_case_clause, s_bad_case_labels, s_duplicate_case_label,
literal_p): New static identifiers.
(scm_m_case): Use ASSERT_SYNTAX to signal syntax errors. Be more
specific about the kind of error that was detected. Check for
duplicate case labels. Handle bound 'else. Avoid unnecessary
consing when creating the memoized code.
(scm_m_case, unmemocopy, SCM_CEVAL): Use SCM_IM_ELSE to memoize
the syntactic keyword 'else.
* test-suite/tests/syntax.test (exception:bad-expression,
exception:missing-clauses, exception:bad-case-clause,
exception:extra-case-clause, exception:bad-case-labels): New.
Added some tests and adapted tests for 'case' to the new way of
error reporting.
2003-10-11 00:57:25 +00:00
|
|
|
exception:bad-expression
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 (else #f) . "foo")
|
|
|
|
|
(interaction-environment)))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(case 1 (else #f) ((1) #t))"
|
2003-10-11 10:40:19 +00:00
|
|
|
exception:misplaced-else-clause
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(case 1 (else #f) ((1) #t))
|
|
|
|
|
(interaction-environment)))))
|
2001-10-13 17:02:01 +00:00
|
|
|
|
2003-11-08 08:11:14 +00:00
|
|
|
(with-test-prefix "top-level define"
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2001-11-17 11:44:06 +00:00
|
|
|
(with-test-prefix "currying"
|
|
|
|
|
|
|
|
|
|
(pass-if "(define ((foo)) #f)"
|
2003-11-08 08:11:14 +00:00
|
|
|
(eval '(begin
|
|
|
|
|
(define ((foo)) #t)
|
|
|
|
|
((foo)))
|
|
|
|
|
(interaction-environment))))
|
2001-11-17 11:44:06 +00:00
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(define)"
|
2003-10-11 16:03:29 +00:00
|
|
|
exception:missing-expr
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(define)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
2003-11-08 08:11:14 +00:00
|
|
|
(with-test-prefix "internal define"
|
|
|
|
|
|
|
|
|
|
(pass-if "internal defines become letrec"
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment)))
|
|
|
|
|
|
|
|
|
|
(expect-fail "internal defines with begin"
|
|
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(begin
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1)))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
|
|
|
|
(expect-fail "internal defines with empty begin"
|
|
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(begin)
|
|
|
|
|
(define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5))))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2003-11-15 11:51:17 +00:00
|
|
|
(pass-if "internal defines with macro application"
|
2003-11-09 19:07:41 +00:00
|
|
|
(false-if-exception
|
|
|
|
|
(eval '(begin
|
2003-11-15 11:51:17 +00:00
|
|
|
(defmacro my-define forms
|
2003-11-09 19:07:41 +00:00
|
|
|
(cons 'define forms))
|
2003-11-15 11:51:17 +00:00
|
|
|
(let ((a identity) (b identity) (c identity))
|
|
|
|
|
(define (a x) (if (= x 0) 'a (b (- x 1))))
|
|
|
|
|
(my-define (b x) (if (= x 0) 'b (c (- x 1))))
|
|
|
|
|
(define (c x) (if (= x 0) 'c (a (- x 1))))
|
|
|
|
|
(and (eq? 'a (a 0) (a 3))
|
|
|
|
|
(eq? 'b (a 1) (a 4))
|
|
|
|
|
(eq? 'c (a 2) (a 5)))))
|
2003-11-09 19:07:41 +00:00
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2003-11-08 08:11:14 +00:00
|
|
|
(pass-if-exception "missing body expression"
|
|
|
|
|
exception:missing-body-expr
|
|
|
|
|
(eval '(let () (define x #t))
|
|
|
|
|
(interaction-environment))))
|
|
|
|
|
|
2001-03-02 01:38:01 +00:00
|
|
|
(with-test-prefix "set!"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expressions"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(set!)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set!)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! 1)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! 1 2 3)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1 2 3)
|
|
|
|
|
(interaction-environment))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "bad variable"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(set! \"\" #t)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! "" #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! 1 #t)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! 1 #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! #t #f)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #t #f)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! #f #t)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #f #t)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(set! #\space #f)"
|
2003-10-18 18:26:43 +00:00
|
|
|
exception:bad-variable
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(set! #\space #f)
|
|
|
|
|
(interaction-environment)))))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "quote"
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "missing or extra expression"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "(quote)"
|
|
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(quote)
|
|
|
|
|
(interaction-environment)))
|
2001-03-02 01:38:01 +00:00
|
|
|
|
|
|
|
|
(pass-if-exception "(quote a b)"
|
|
|
|
|
exception:missing/extra-expr
|
2003-04-23 19:04:00 +00:00
|
|
|
(eval '(quote a b)
|
|
|
|
|
(interaction-environment)))))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "while"
|
|
|
|
|
|
|
|
|
|
(define (unreachable)
|
|
|
|
|
(error "unreachable code has been reached!"))
|
|
|
|
|
|
|
|
|
|
;; Return a new procedure COND which when called (COND) will return #t the
|
|
|
|
|
;; first N times, then #f, then any further call is an error. N=0 is
|
|
|
|
|
;; allowed, in which case #f is returned by the first call.
|
|
|
|
|
(define (make-iterations-cond n)
|
|
|
|
|
(lambda ()
|
|
|
|
|
(cond ((not n)
|
|
|
|
|
(error "oops, condition re-tested after giving false"))
|
|
|
|
|
((= 0 n)
|
|
|
|
|
(set! n #f)
|
|
|
|
|
#f)
|
|
|
|
|
(else
|
|
|
|
|
(set! n (1- n))
|
|
|
|
|
#t))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "too few args" exception:wrong-num-args
|
2003-10-07 22:00:05 +00:00
|
|
|
(eval '(while) (interaction-environment)))
|
2003-08-12 21:39:30 +00:00
|
|
|
|
|
|
|
|
(with-test-prefix "empty body"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n)))
|
|
|
|
|
(while (cond)))
|
|
|
|
|
#t)))
|
|
|
|
|
|
|
|
|
|
(pass-if "initially false"
|
|
|
|
|
(while #f
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "in empty environment"
|
2003-10-07 22:00:05 +00:00
|
|
|
|
|
|
|
|
;; an environment with no bindings at all
|
|
|
|
|
(define empty-environment
|
|
|
|
|
(make-module 1))
|
|
|
|
|
|
2003-08-12 21:39:30 +00:00
|
|
|
(pass-if "empty body"
|
|
|
|
|
(eval `(,while #f)
|
|
|
|
|
empty-environment)
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "initially false"
|
|
|
|
|
(eval `(,while #f
|
|
|
|
|
#f)
|
|
|
|
|
empty-environment)
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "iterating"
|
|
|
|
|
(let ((cond (make-iterations-cond 3)))
|
|
|
|
|
(eval `(,while (,cond)
|
|
|
|
|
123 456)
|
|
|
|
|
empty-environment))
|
|
|
|
|
#t))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "iterations"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "break"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "too many args" exception:wrong-num-args
|
|
|
|
|
(while #t
|
|
|
|
|
(break 1)))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from cond"
|
|
|
|
|
(pass-if "first"
|
|
|
|
|
(while (begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (if (cond)
|
|
|
|
|
#t
|
|
|
|
|
(begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from body"
|
|
|
|
|
(pass-if "first"
|
|
|
|
|
(while #t
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable))
|
|
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while #t
|
|
|
|
|
(if (not (cond))
|
|
|
|
|
(begin
|
|
|
|
|
(break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(set! i (1+ i)))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(pass-if "from nested"
|
|
|
|
|
(while #t
|
|
|
|
|
(let ((outer-break break))
|
|
|
|
|
(while #t
|
|
|
|
|
(outer-break)
|
|
|
|
|
(unreachable)))
|
|
|
|
|
(unreachable))
|
2003-08-17 00:40:33 +00:00
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "from recursive"
|
|
|
|
|
(let ((outer-break #f))
|
|
|
|
|
(define (r n)
|
|
|
|
|
(while #t
|
|
|
|
|
(if (eq? n 'outer)
|
|
|
|
|
(begin
|
|
|
|
|
(set! outer-break break)
|
|
|
|
|
(r 'inner))
|
|
|
|
|
(begin
|
|
|
|
|
(outer-break)
|
|
|
|
|
(unreachable))))
|
|
|
|
|
(if (eq? n 'inner)
|
|
|
|
|
(error "broke only from inner loop")))
|
|
|
|
|
(r 'outer))
|
2003-08-12 21:39:30 +00:00
|
|
|
#t))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "continue"
|
|
|
|
|
|
|
|
|
|
(pass-if-exception "too many args" exception:wrong-num-args
|
|
|
|
|
(while #t
|
|
|
|
|
(continue 1)))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from cond"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (if (cond)
|
|
|
|
|
(begin
|
|
|
|
|
(set! i (1+ i))
|
|
|
|
|
(continue)
|
|
|
|
|
(unreachable))
|
|
|
|
|
#f)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "from body"
|
|
|
|
|
(do ((n 0 (1+ n)))
|
|
|
|
|
((> n 5))
|
|
|
|
|
(pass-if n
|
|
|
|
|
(let ((cond (make-iterations-cond n))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(set! i (1+ i))
|
|
|
|
|
(continue)
|
|
|
|
|
(unreachable))
|
|
|
|
|
(= i n)))))
|
|
|
|
|
|
|
|
|
|
(pass-if "from nested"
|
|
|
|
|
(let ((cond (make-iterations-cond 3)))
|
|
|
|
|
(while (cond)
|
|
|
|
|
(let ((outer-continue continue))
|
|
|
|
|
(while #t
|
|
|
|
|
(outer-continue)
|
|
|
|
|
(unreachable)))))
|
2003-08-17 00:40:33 +00:00
|
|
|
#t)
|
|
|
|
|
|
|
|
|
|
(pass-if "from recursive"
|
|
|
|
|
(let ((outer-continue #f))
|
|
|
|
|
(define (r n)
|
|
|
|
|
(let ((cond (make-iterations-cond 3))
|
|
|
|
|
(first #t))
|
|
|
|
|
(while (begin
|
|
|
|
|
(if (and (not first)
|
|
|
|
|
(eq? n 'inner))
|
|
|
|
|
(error "continued only to inner loop"))
|
|
|
|
|
(cond))
|
|
|
|
|
(set! first #f)
|
|
|
|
|
(if (eq? n 'outer)
|
|
|
|
|
(begin
|
|
|
|
|
(set! outer-continue continue)
|
|
|
|
|
(r 'inner))
|
|
|
|
|
(begin
|
|
|
|
|
(outer-continue)
|
|
|
|
|
(unreachable))))))
|
|
|
|
|
(r 'outer))
|
2003-08-12 21:39:30 +00:00
|
|
|
#t)))
|