www

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

test.hl.rkt (2449B)


      1 #lang hyper-literate typed/racket/base
      2 
      3 @(require (for-label typed/racket/base
      4                      rackunit))
      5 
      6 @title{Title}
      7 
      8 @section{if-preexpanding}
      9 
     10 Hello world.
     11 
     12 @(if-preexpanding
     13   (void)
     14   (require (submod "..")))
     15 
     16 @(unless-preexpanding
     17   (symbol->string ee))
     18 
     19 @section{Submodules}
     20 
     21 Submodules work:
     22 
     23 @chunk[<submod>
     24        (module ms typed/racket/base
     25          (define x 1)
     26          (provide x))
     27 
     28        (module ms2 typed/racket/base
     29          (define y -1)
     30          (provide y))]
     31 
     32 And can be required:
     33 
     34 @chunk[<submod>
     35        (require 'ms)
     36        (require (submod "." ms2))]
     37 
     38 Submodules with @racket[module*] work too:
     39 
     40 @chunk[<submod*>
     41        (module* ms* racket/base
     42          (require typed/rackunit)
     43          <req-dotdot>
     44          (check-equal? ee 'e123)
     45          (check-equal? y -1))]
     46 
     47 And so does @racket[(require (submod ".." …))]:
     48 
     49 @chunk[<req-dotdot>
     50        (require (submod ".."))
     51        (require (submod ".." ms2))]
     52 
     53 Test with multiple subforms inside require, and coverage for
     54 @racket[for-syntax]:
     55 
     56 @chunk[<req-multi>
     57        (require (for-syntax syntax/stx
     58                             racket/syntax)
     59                 racket/bool)]
     60 
     61 @section{Avoiding for-label}
     62 
     63 Wrap the @racket[(require (for-syntax racket/base))] in a 
     64 @racket[(begin …)] so that it gets ignored, otherwise
     65 scribble complains some identifiers are loaded twice
     66 for-label, since some identifiers have already been introduced
     67 at meta-level 0 by @racketmodname[typed/racket].
     68 
     69 @chunk[<require-not-label>
     70        (begin (require (for-syntax racket/base))
     71               (require typed/rackunit))]
     72 
     73 @CHUNK[<with-unsyntax>
     74        (let* ([b 1234]
     75               [e (syntax-e #`#,b)])
     76          (check-equal? e 1234))]
     77 
     78 @section{Main chunk}
     79 
     80 @chunk[<*>
     81        <require-not-label>
     82        <submod>
     83        <req-multi>
     84        <submod*>
     85        (check-true (false? #f));; Should be hyperlinked to the main docs
     86        (begin-for-syntax
     87          (define/with-syntax ;; Should be hyperlinked to the main docs
     88            x
     89            (stx-car ;; Should be hyperlinked to the main docs
     90             #'(a . b))))
     91        (check-equal? (+ x x) 2)
     92        (check-equal? (+ x y) 0)
     93        <with-unsyntax>
     94        ;; Gives an error because typed/racket/base is used on the #lang line:
     95        ;curry
     96        (check-equal? ((make-predicate One) 1) #t)
     97        (check-equal? (ann 'sym Symbol) 'sym)
     98        (define (f [x : 'e123]) x)
     99        (define ee (ann (f 'e123) 'e123))
    100        (provide ee)]