Debian Codegraph @

test/errsyn.scm

raw
1 ;;;
2 ;;; erroneous syntax test
3 ;;;
4
5 ;; We test if invalid syntax is correctly detected. This is run after
6 ;; error.scm and macro.scm.
7
8
9 (use gauche.test)
10
11 (test-start "erroneous syntax test")
12
13 (define-syntax test-syn
14 (syntax-rules ()
15 ([_ msg expect form]
16 (test* msg expect (eval 'form (current-module))))))
17
18 (test-section "Internal defines")
19
20 (test-syn "duplicate internal definitions (var-var)"
21 (test-error <error> #/Duplicate internal definitions of a/)
22 (let ()
23 (define a 3)
24 (define b 5)
25 (define a 4)
26 (list a b)))
27
28 (test-syn "duplicate internal definitions (syn-syn)"
29 (test-error <error> #/Duplicate internal definitions of p/)
30 (let ()
31 (define-syntax p (syntax-rules () [(_) 1]))
32 (define-syntax q (syntax-rules () [(_) 2]))
33 (define-syntax p (syntax-rules () [(_) 3]))
34 (list (p) (q))))
35
36 (test-syn "duplicate internal definitions (var-syn)"
37 (test-error <error> #/Duplicate internal definitions of v/)
38 (let ()
39 (define v 3)
40 (define-syntax w (syntax-rules () [(_) 2]))
41 (define-syntax v (syntax-rules () [(_) 3]))
42 (list (v) (w))))
43
44 (test-end)