Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 59 lines (50 sloc) 2.212 kB
db7a26f @zitterbewegung Imported hager master
zitterbewegung authored
1 #lang scheme
9ebdbfb @vegashacker got rid of dependency on digest planet lib (to address http://planet.…
authored
2
9a26549 @vegashacker starting a unit test system for leftparen code itself
authored
3 (require (planet "main.ss" ("schematics" "schemeunit.plt" 3 (= 3)))
9ebdbfb @vegashacker got rid of dependency on digest planet lib (to address http://planet.…
authored
4 (planet "text-ui.ss" ("schematics" "schemeunit.plt" 3 (= 3)))
811ac6b @vegashacker closures now automatically clean up themselves when executed
authored
5 "util.scm"
6 "closures.scm")
9a26549 @vegashacker starting a unit test system for leftparen code itself
authored
7
8 (define basic-tests
811ac6b @vegashacker closures now automatically clean up themselves when executed
authored
9 (let ((clos-key 'dummy))
10 (test-suite
11 "LeftParen basic test suite"
12 ;; actual: expected:
13 (test-equal? "numeric equality" 1 1 )
14 (test-equal? "md5 hashing" (md5-string "hello") "5d41402abc4b2a76b9719d911017c592")
15 (test-equal? "num closures in memory at start" (num-closures-in-memory) 0)
2a332f6 @vegashacker allow for optional sticky closures to be made; and added appropriate …
authored
16
17 ;; closure testing
811ac6b @vegashacker closures now automatically clean up themselves when executed
authored
18 (test-equal? "after a closure made"
19 (begin (set! clos-key (body-as-closure-key (req) "hi"))
20 (num-closures-in-memory))
21 1)
22 (test-equal? "call a closure--check it's value"
23 (call-closure clos-key 'dummy-req)
24 "hi")
25
26 (test-equal? "closures are usable only once"
27 (num-closures-in-memory)
28 0)
9559b2d @vegashacker found bug where we were ignoring manually given closure keys...fixed …
authored
29
30 ;; now test manual closure keys
31 (test-equal? "just made a manual key'd closure"
32 (begin (set! clos-key "some-key-i-made-up")
33 (body-as-closure-key (req clos-key) "cool")
34 (num-closures-in-memory))
35 1)
36 (test-equal? "call the manual closure"
37 (call-closure clos-key 'dummy-req)
38 "cool")
39 (test-equal? "make sure manual closures clean up too"
40 (num-closures-in-memory)
41 0)
2a332f6 @vegashacker allow for optional sticky closures to be made; and added appropriate …
authored
42
43 ;; test sticky closures
44 (test-equal? "make a sticky closure"
45 (begin (set! clos-key (body-as-closure-key (req clos-key #:sticky)
46 "sticky!"))
47 (num-closures-in-memory))
48 1)
49 (test-equal? "call the sticky closure"
50 (call-closure clos-key 'dummy-req)
51 "sticky!")
52 (test-equal? "make sure the sticky closure sticks"
53 (num-closures-in-memory)
54 1)
811ac6b @vegashacker closures now automatically clean up themselves when executed
authored
55
56 )))
9a26549 @vegashacker starting a unit test system for leftparen code itself
authored
57
58 (run-tests basic-tests)
Something went wrong with that request. Please try again.