preprocessor tests
svn: r11787
This commit is contained in:
parent
639ba223cc
commit
ffde7e7b42
|
@ -1,6 +1,8 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
|
|
||||||
(require tests/eli-tester scribble/text/syntax-utils)
|
(require tests/eli-tester scribble/text/syntax-utils scheme/runtime-path)
|
||||||
|
|
||||||
|
(define-runtime-path text-dir "text")
|
||||||
|
|
||||||
(test
|
(test
|
||||||
|
|
||||||
|
@ -76,4 +78,17 @@
|
||||||
(f 3 #:> "]" #:< "["))
|
(f 3 #:> "]" #:< "["))
|
||||||
=> '(1 ("<" 1 ">") ("[" 2 ">") ("[" 3 "]"))
|
=> '(1 ("<" 1 ">") ("[" 2 ">") ("[" 3 "]"))
|
||||||
|
|
||||||
|
;; preprocessor functionality
|
||||||
|
(parameterize ([current-directory text-dir])
|
||||||
|
(for ([ifile (map path->string (directory-list))]
|
||||||
|
#:when (and (file-exists? ifile)
|
||||||
|
(regexp-match? #rx"^i[0-9]+$" ifile)))
|
||||||
|
(define ofile (regexp-replace #rx"^i" ifile "o"))
|
||||||
|
(define expected (call-with-input-file ofile
|
||||||
|
(lambda (i) (read-bytes (file-size ofile) i))))
|
||||||
|
(define o (open-output-bytes))
|
||||||
|
(parameterize ([current-output-port o])
|
||||||
|
(dynamic-require (path->complete-path ifile) #f))
|
||||||
|
(test (get-output-bytes o) => expected)))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
3
collects/tests/scribble/text/i1
Normal file
3
collects/tests/scribble/text/i1
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#lang scribble/text
|
||||||
|
|
||||||
|
foo
|
25
collects/tests/scribble/text/i2
Normal file
25
collects/tests/scribble/text/i2
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#lang scribble/text
|
||||||
|
|
||||||
|
@define[name]{PLT Scheme}
|
||||||
|
|
||||||
|
Suggested price list for "@name"
|
||||||
|
|
||||||
|
@; test mutual recursion, throwing away inter-definition spaces
|
||||||
|
@; <-- this is needed to get one line of space only
|
||||||
|
@(define (items-num)
|
||||||
|
(length items))
|
||||||
|
|
||||||
|
@(define average
|
||||||
|
(delay (/ (apply + (map car items)) (length items))))
|
||||||
|
|
||||||
|
@(define items
|
||||||
|
(list @list[99]{Home}
|
||||||
|
@list[149]{Professional}
|
||||||
|
@list[349]{Enterprize}))
|
||||||
|
|
||||||
|
@(for/list ([i items] [n (in-naturals)])
|
||||||
|
@list{@|n|. @name @cadr[i] edition: $@car[i].99
|
||||||
|
@||})@; <-- also needed
|
||||||
|
|
||||||
|
Total: @items-num items
|
||||||
|
Average price: $@|average|.99
|
18
collects/tests/scribble/text/i3
Normal file
18
collects/tests/scribble/text/i3
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#lang scribble/text
|
||||||
|
|
||||||
|
---***---
|
||||||
|
@(define (angled . body) (list "<" body ">"))
|
||||||
|
@(define (shout . body) @angled[(map string-upcase body)])
|
||||||
|
@define[z]{blah}
|
||||||
|
|
||||||
|
blah @angled{blah @shout{@z} blah} blah
|
||||||
|
|
||||||
|
@(define-syntax-rule @twice[x]
|
||||||
|
(list x ", " x))
|
||||||
|
|
||||||
|
@twice{@twice{blah}}
|
||||||
|
|
||||||
|
@include{i3a}
|
||||||
|
|
||||||
|
@(let ([name "Eli"]) (let ([foo (include "i3b")]) (list foo "\n" foo)))
|
||||||
|
Repeating yourself much?
|
1
collects/tests/scribble/text/i3a
Normal file
1
collects/tests/scribble/text/i3a
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Warning: blah overdose might be fatal
|
12
collects/tests/scribble/text/i3b
Normal file
12
collects/tests/scribble/text/i3b
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
@(define (foo . xs) (bar xs))
|
||||||
|
@(begin (define (isname) @list{is @foo{@name}})
|
||||||
|
(define-syntax-rule (DEF x y) (define x y)))
|
||||||
|
@(DEF (bar x) (list z " " x))
|
||||||
|
@(define-syntax-rule (BEG x ...) (begin x ...))
|
||||||
|
@(BEG (define z "zee"))
|
||||||
|
|
||||||
|
My name @isname
|
||||||
|
@DEF[x]{Foo!}
|
||||||
|
|
||||||
|
... and to that I say "@x", I think.
|
||||||
|
|
1
collects/tests/scribble/text/o1
Normal file
1
collects/tests/scribble/text/o1
Normal file
|
@ -0,0 +1 @@
|
||||||
|
foo
|
8
collects/tests/scribble/text/o2
Normal file
8
collects/tests/scribble/text/o2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Suggested price list for "PLT Scheme"
|
||||||
|
|
||||||
|
0. PLT Scheme Home edition: $99.99
|
||||||
|
1. PLT Scheme Professional edition: $149.99
|
||||||
|
2. PLT Scheme Enterprize edition: $349.99
|
||||||
|
|
||||||
|
Total: 3 items
|
||||||
|
Average price: $199.99
|
14
collects/tests/scribble/text/o3
Normal file
14
collects/tests/scribble/text/o3
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
---***---
|
||||||
|
blah <blah <BLAH> blah> blah
|
||||||
|
|
||||||
|
blah, blah, blah, blah
|
||||||
|
|
||||||
|
Warning: blah overdose might be fatal
|
||||||
|
|
||||||
|
My name is zee Eli
|
||||||
|
... and to that I say "Foo!", I think.
|
||||||
|
|
||||||
|
My name is zee Eli
|
||||||
|
... and to that I say "Foo!", I think.
|
||||||
|
|
||||||
|
Repeating yourself much?
|
Loading…
Reference in New Issue
Block a user