]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/scaffold/scaffold-tests.factor
stomp.cli: simplify
[factor.git] / basis / tools / scaffold / scaffold-tests.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3
4 USING: help.markup io.streams.string kernel math sequences
5 tools.scaffold tools.scaffold.private tools.test unicode ;
6
7 IN: tools.scaffold.tests
8
9
10 : undocumented-word ( obj1 obj2 -- obj3 obj4 )
11     [ >lower ] [ >upper ] bi* ;
12
13 {
14 "HELP: undocumented-word
15 { $values
16     { \"obj1\" object } { \"obj2\" object }
17     { \"obj3\" object } { \"obj4\" object }
18 }
19 { $description \"\" } ;
20 "
21 }
22 [
23     [ \ undocumented-word scaffold-word-docs ] with-string-writer
24 ] unit-test
25
26 {
27 "HELP: iota
28 { $class-description \"\" } ;
29 "
30 }
31 [
32     [ \ iota scaffold-word-docs ] with-string-writer
33 ] unit-test
34
35 { sequence t } [ "seq" lookup-type ] unit-test
36 { sequence t } [ "seq'" lookup-type ] unit-test
37 { sequence t } [ "newseq" lookup-type ] unit-test
38 { { $maybe sequence } t } [ "seq/f" lookup-type ] unit-test
39 { f f } [ "foo" lookup-type ] unit-test
40
41
42 : test-maybe ( obj -- obj/f ) ;
43
44 {
45 "HELP: test-maybe
46 { $values
47     { \"obj\" object }
48     { \"obj/f\" { $maybe object } }
49 }
50 { $description \"\" } ;
51 "
52 }
53 [ [ \ test-maybe scaffold-word-docs ] with-string-writer ]
54 unit-test
55
56 { "{ \"foofoo\" } [\n    USING: kernel sequences ; \"foo\" dup append\n] unit-test\n" } [
57     "USING: kernel sequences ; \"foo\" dup append" [ read-unit-test ] with-string-reader
58 ] unit-test
59
60 {
61     "{\n    \"foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbaz\"\n} [\n    USING: kernel math sequences ; \"foobarbaz\" 3 [ dup append ] times\n] unit-test\n"
62 } [
63     "USING: kernel math sequences ; \"foobarbaz\" 3 [ dup append ] times"
64     [ read-unit-test ] with-string-reader
65 ] unit-test
66
67 { "foobar [\n    baz\n] unit-test\n" } [
68     "foobar" "baz" make-unit-test
69 ] unit-test
70
71
72 { "foobar [\n    foz\n    baz\n] unit-test\n" } [
73     "foobar" "foz\nbaz" make-unit-test
74 ] unit-test
75
76 { { 2 } } [
77     "USING: math ; 2 1 + 3 * 7 -" run-string
78 ] unit-test