www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

test-optional.rkt (2124B)


      1 #lang racket
      2 (require subtemplate/private/ddd-forms
      3          stxparse-info/case
      4          stxparse-info/parse
      5          rackunit
      6          syntax/macro-testing
      7          phc-toolkit/untyped)
      8 
      9 (check-equal? (list ;; unwrap the splice
     10                (syntax-parse #'(1 #:kw 3)
     11                  [({~and {~or x:nat #:kw}} …)
     12                   (?? x 'missing) …]))
     13               '(1 missing 3))
     14 
     15 (check-equal? (syntax-parse #'(1 #:kw 3)
     16                 [({~and {~or x:nat #:kw}} …)
     17                  (list (?@ 1 2 3))])
     18               '(1 2 3))
     19 
     20 (check-equal? (syntax-parse #'(1 2 3)
     21                 [(x …)
     22                  (list (x ...) 4 5)])
     23               '((1 2 3) 4 5))
     24 
     25 (check-equal? (syntax-parse #'(1 2 3)
     26                 [(x …)
     27                  (list (?@ x ...) 4 5)])
     28               '(1 2 3 4 5))
     29 
     30 (check-equal? (syntax-parse #'(1 #:kw 3)
     31                 [({~and {~or x:nat #:kw}} …)
     32                  (list (?@ x) ... 4 5)])
     33               '(1 #f 3 4 5))
     34 
     35 (check-equal? (syntax-parse #'(1 #:kw 3)
     36                 [({~and {~or x:nat #:kw}} …)
     37                  (list ((?@ x) ...) 4 5)])
     38               '((1 #f 3) 4 5))
     39 
     40 (check-equal? (syntax-parse #'(1 #:kw 3)
     41                 [({~and {~or x:nat #:kw}} …)
     42                  (list (?@ 'x 'is x) ... 4 5)])
     43               '(x is 1 x is #f x is 3 4 5))
     44 
     45 (check-equal? (syntax-parse #'(1 #:kw 3)
     46                 [({~and {~or x:nat #:kw}} …)
     47                  (list ((?@ 'x 'is x) ...) 4 5)])
     48               '((x is 1 x is #f x is 3) 4 5))
     49 
     50 (check-equal? (syntax-parse #'(1 #:kw 3)
     51                 [({~and {~or x:nat #:kw}} …)
     52                  (list (?? (?@ 'x 'is x) 'nothing-here) ... 4 5)])
     53               '(x is 1 nothing-here x is 3 4 5))
     54 
     55 (check-equal? (syntax-parse #'(1 #:kw 3)
     56                 [({~and {~or x:nat #:kw}} …)
     57                  (list (?? (?@ 'x 'is x) (?@ 'nothing 'here)) ... 4 5)])
     58               '(x is 1 nothing here x is 3 4 5))
     59 
     60 (check-equal? (syntax-parse #'(1 #:kw 3)
     61                 [({~and {~or x:nat #:kw}} …)
     62                  (list (?? (?@ 'x 'is x) (list 'nothing 'here)) ... 4 5)])
     63               '(x is 1 (nothing here) x is 3 4 5))