nydp 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -13
- data/lib/lisp/core-015-documentation.nydp +11 -2
- data/lib/lisp/core-030-syntax.nydp +52 -8
- data/lib/lisp/core-040-utils.nydp +35 -47
- data/lib/lisp/core-045-dox-utils.nydp +85 -0
- data/lib/lisp/core-050-test-runner.nydp +20 -2
- data/lib/lisp/core-080-pretty-print.nydp +5 -1
- data/lib/lisp/tests/boot-tests.nydp +125 -255
- data/lib/lisp/tests/car-examples.nydp +16 -0
- data/lib/lisp/tests/collect-tests.nydp +28 -0
- data/lib/lisp/tests/cons-examples.nydp +8 -0
- data/lib/lisp/tests/curry-tests.nydp +17 -18
- data/lib/lisp/tests/detect-examples.nydp +24 -0
- data/lib/lisp/tests/dot-syntax-examples.nydp +40 -0
- data/lib/lisp/tests/dox-tests.nydp +116 -100
- data/lib/lisp/tests/dynamic-scope-test.nydp +10 -10
- data/lib/lisp/tests/each-tests.nydp +4 -5
- data/lib/lisp/tests/error-tests.nydp +17 -16
- data/lib/lisp/tests/explain-mac-examples.nydp +24 -0
- data/lib/lisp/tests/foundation-test.nydp +57 -223
- data/lib/lisp/tests/hash-examples.nydp +41 -0
- data/lib/lisp/tests/isa-examples.nydp +7 -0
- data/lib/lisp/tests/len-examples.nydp +11 -0
- data/lib/lisp/tests/list-tests.nydp +110 -75
- data/lib/lisp/tests/parser-tests.nydp +67 -109
- data/lib/lisp/tests/pretty-print-tests.nydp +19 -20
- data/lib/lisp/tests/quasiquote-examples.nydp +10 -0
- data/lib/lisp/tests/rfnwith-tests.nydp +7 -0
- data/lib/lisp/tests/string-tests.nydp +60 -31
- data/lib/lisp/tests/syntax-tests.nydp +22 -24
- data/lib/lisp/tests/type-of-examples.nydp +48 -0
- data/lib/lisp/tests/unparse-tests.nydp +2 -3
- data/lib/nydp.rb +2 -1
- data/lib/nydp/version.rb +1 -1
- metadata +14 -1
@@ -0,0 +1,28 @@
|
|
1
|
+
(examples-for collect
|
2
|
+
("returns all matching items in a list"
|
3
|
+
(collect (fn (x) (eq? (len x) 2))
|
4
|
+
(list "foo" "bar" "xx" "pp"))
|
5
|
+
("xx" "pp"))
|
6
|
+
|
7
|
+
("returns nil when nothing matches"
|
8
|
+
(collect (fn (x) (eq? (len x) 20))
|
9
|
+
(list "foo" "bar" "xx" "pp"))
|
10
|
+
nil)
|
11
|
+
|
12
|
+
;; kind of pointless
|
13
|
+
("returns list of nils if nil is the matching item"
|
14
|
+
(collect no (list "foo" "bar" nil "pp" nil))
|
15
|
+
(nil nil))
|
16
|
+
|
17
|
+
("returns item if it's an atom and matches"
|
18
|
+
(collect (fn (x) (eq? (len x) 2)) "zz")
|
19
|
+
"zz")
|
20
|
+
|
21
|
+
("preserves structure of improper list"
|
22
|
+
(collect (fn (x) (eq? (len x) 2)) '("aa" "bbb" "cc" "ddd" . "ee"))
|
23
|
+
("aa" "cc" . "ee"))
|
24
|
+
|
25
|
+
("returns nil if it's an atom and doesn't match"
|
26
|
+
(collect (fn (x) (eq? (len x) 20))
|
27
|
+
"zz")
|
28
|
+
nil))
|
@@ -1,24 +1,23 @@
|
|
1
1
|
(def chicken-korma (a b c d e)
|
2
2
|
(list a b c d e))
|
3
3
|
|
4
|
-
(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
(1 2 3 4 5))
|
4
|
+
(examples-for curry
|
5
|
+
("zero-params"
|
6
|
+
(let ck0 (curry chicken-korma)
|
7
|
+
(ck0 1 2 3 4 5))
|
8
|
+
(1 2 3 4 5))
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
("one param"
|
11
|
+
(let ck0 (curry chicken-korma 'x)
|
12
|
+
(ck0 1 2 3 4))
|
13
|
+
(x 1 2 3 4))
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
("two params"
|
16
|
+
(let ck0 (curry chicken-korma 'x 'y)
|
17
|
+
(ck0 1 2 3))
|
18
|
+
(x y 1 2 3))
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
("three params"
|
21
|
+
(let ck0 (curry chicken-korma 'x 'y 'z)
|
22
|
+
(ck0 1 2))
|
23
|
+
(x y z 1 2)))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
(examples-for detect
|
2
|
+
("returns first matching item in a list"
|
3
|
+
(detect (fn (x) (eq? (len x) 2))
|
4
|
+
(list "foo" "bar" "xx" "pp"))
|
5
|
+
"xx")
|
6
|
+
|
7
|
+
("returns nil when nothing matches"
|
8
|
+
(detect (fn (x) (eq? (len x) 20))
|
9
|
+
(list "foo" "bar" "xx" "pp"))
|
10
|
+
nil)
|
11
|
+
|
12
|
+
;; kind of pointless
|
13
|
+
("returns nil if nil is the matching item"
|
14
|
+
(detect no (list "foo" "bar" nil "pp"))
|
15
|
+
nil)
|
16
|
+
|
17
|
+
("returns item if it's an atom and matches"
|
18
|
+
(detect (fn (x) (eq? (len x) 2)) "zz")
|
19
|
+
"zz")
|
20
|
+
|
21
|
+
("returns nil if it's an atom and doesn't match"
|
22
|
+
(detect (fn (x) (eq? (len x) 20))
|
23
|
+
"zz")
|
24
|
+
nil))
|
@@ -0,0 +1,40 @@
|
|
1
|
+
(examples-for dox-syntax
|
2
|
+
("hash-lookup"
|
3
|
+
(pre-compile 'a.b.c)
|
4
|
+
(hash-get (hash-get a 'b) 'c))
|
5
|
+
|
6
|
+
("hash-lookup with dollar-syntax for function call"
|
7
|
+
(pre-compile '$a.b.c)
|
8
|
+
(hash-get (hash-get (a) 'b) 'c))
|
9
|
+
|
10
|
+
("hash-lookup with embedded dollar-syntax for function call"
|
11
|
+
(pre-compile 'a.$b.c)
|
12
|
+
(hash-get (hash-get a (b)) 'c))
|
13
|
+
|
14
|
+
("hash-lookup with embedded unquote"
|
15
|
+
(pre-compile 'a.,b.c)
|
16
|
+
(hash-get (hash-get a b) 'c))
|
17
|
+
|
18
|
+
("hash assignment"
|
19
|
+
(pre-compile '(= a.b 42))
|
20
|
+
(hash-set a 'b 42))
|
21
|
+
|
22
|
+
("hash assignment with unquote"
|
23
|
+
(pre-compile '(= a.,b 42))
|
24
|
+
(hash-set a b 42))
|
25
|
+
|
26
|
+
("recursive hash assignment"
|
27
|
+
(pre-compile '(= a.b.c.d 42))
|
28
|
+
(hash-set (hash-get (hash-get a 'b) 'c) 'd 42))
|
29
|
+
|
30
|
+
("recursive hash assignment with embedded unquote"
|
31
|
+
(pre-compile '(= a.b.,c.d 42))
|
32
|
+
(hash-set (hash-get (hash-get a 'b) c) 'd 42))
|
33
|
+
|
34
|
+
("recursive hash assignment with prefix dollar-syntax"
|
35
|
+
(pre-compile '(= $a.b.,c.d 42))
|
36
|
+
(hash-set (hash-get (hash-get (a) 'b) c) 'd 42))
|
37
|
+
|
38
|
+
("recursive hash assignment with embedded dollar-syntax"
|
39
|
+
(pre-compile '(= a.$b.,c.d 42))
|
40
|
+
(hash-set (hash-get (hash-get a (b)) c) 'd 42)))
|
@@ -1,53 +1,51 @@
|
|
1
1
|
(mac this-is-a-well-documented-macro (a b c)
|
2
|
-
|
2
|
+
; documentation for me!
|
3
3
|
`(foo ,a ,b ,c))
|
4
4
|
|
5
5
|
(mac this-is-an-undocumented-macro (a b c)
|
6
6
|
`(baz ,a ,b ,c))
|
7
7
|
|
8
8
|
(def this-is-a-well-documented-def (a b c)
|
9
|
-
|
9
|
+
; documentation for me!
|
10
10
|
(foo a b c))
|
11
11
|
|
12
12
|
(def this-is-an-undocumented-def (a b c)
|
13
13
|
(baz a b c))
|
14
14
|
|
15
|
-
(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
'(def bingo (count) (times count (bark))))
|
50
|
-
"Function : bingo
|
15
|
+
(examples-for isa-comment?
|
16
|
+
("identifies a comment"
|
17
|
+
(isa-comment? '(comment "yes, it is"))
|
18
|
+
t)
|
19
|
+
|
20
|
+
("identifies a non-comment"
|
21
|
+
(isa-comment? "not this time")
|
22
|
+
nil))
|
23
|
+
|
24
|
+
(examples-for dox-gather-comments
|
25
|
+
("find no comments"
|
26
|
+
(dox-gather-comments '((this) (that)))
|
27
|
+
(nil ((this) (that))))
|
28
|
+
|
29
|
+
("finds one comment"
|
30
|
+
(dox-gather-comments '((comment "hello") (this) (that)))
|
31
|
+
(("hello") ((this) (that))))
|
32
|
+
|
33
|
+
("finds more comments"
|
34
|
+
(dox-gather-comments '((comment "hello")
|
35
|
+
(comment "more details")
|
36
|
+
(comment "very rigourous")
|
37
|
+
(this)
|
38
|
+
(that)))
|
39
|
+
(("hello" "more details" "very rigourous") ((this) (that)))))
|
40
|
+
|
41
|
+
(examples-for dox-show-info
|
42
|
+
("shows each item"
|
43
|
+
(dox-show-info "bingo"
|
44
|
+
'def
|
45
|
+
'("there was a farmer had a dog" "and Bingo was his name-o")
|
46
|
+
'(count)
|
47
|
+
'(def bingo (count) (times count (bark))))
|
48
|
+
"Function : bingo
|
51
49
|
|
52
50
|
args : (count)
|
53
51
|
|
@@ -56,68 +54,86 @@ and Bingo was his name-o
|
|
56
54
|
|
57
55
|
source
|
58
56
|
======
|
59
|
-
(def bingo (count)
|
57
|
+
\(def bingo (count)
|
60
58
|
(times count (bark)))
|
61
59
|
"))
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
61
|
+
(examples-for dox-lookup
|
62
|
+
("finds info for a documented macro"
|
63
|
+
(dox-lookup 'this-is-a-well-documented-macro)
|
64
|
+
((this-is-a-well-documented-macro
|
65
|
+
mac
|
66
|
+
("documentation for me!")
|
67
|
+
(a b c)
|
68
|
+
(mac this-is-a-well-documented-macro (a b c)
|
69
|
+
`(foo ,a ,b ,c)))))
|
70
|
+
|
71
|
+
("finds info for an undocumented macro"
|
72
|
+
(dox-lookup 'this-is-an-undocumented-macro)
|
73
|
+
((this-is-an-undocumented-macro
|
74
|
+
mac
|
75
|
+
nil
|
76
|
+
(a b c)
|
77
|
+
(mac this-is-an-undocumented-macro (a b c)
|
78
|
+
`(baz ,a ,b ,c)))))
|
79
|
+
|
80
|
+
("finds info for a documented def"
|
81
|
+
(dox-lookup 'this-is-a-well-documented-def)
|
82
|
+
((this-is-a-well-documented-def
|
83
|
+
def
|
84
|
+
("documentation for me!")
|
85
|
+
(a b c)
|
86
|
+
(def this-is-a-well-documented-def (a b c)
|
87
|
+
(foo a b c)))))
|
88
|
+
|
89
|
+
("finds info for an undocumented def"
|
90
|
+
(dox-lookup 'this-is-an-undocumented-def)
|
91
|
+
((this-is-an-undocumented-def
|
92
|
+
def
|
93
|
+
nil
|
94
|
+
(a b c)
|
95
|
+
(def this-is-an-undocumented-def (a b c)
|
96
|
+
(baz a b c))))))
|
97
|
+
|
98
|
+
(examples-for dox-arg-names
|
99
|
+
("macro"
|
100
|
+
(dox-arg-names 'this-is-a-well-documented-macro)
|
101
|
+
(a b c))
|
102
|
+
|
103
|
+
("function def"
|
104
|
+
(dox-arg-names 'this-is-a-well-documented-def)
|
105
|
+
(a b c)))
|
106
|
+
|
107
|
+
(examples-for dox-src
|
108
|
+
("mac src"
|
109
|
+
(dox-src 'this-is-a-well-documented-macro)
|
110
|
+
(mac this-is-a-well-documented-macro (a b c) (quasiquote (foo (unquote a) (unquote b) (unquote c)))))
|
111
|
+
|
112
|
+
("def src"
|
113
|
+
(dox-src 'this-is-a-well-documented-def)
|
114
|
+
(def this-is-a-well-documented-def (a b c) (foo a b c))))
|
115
|
+
|
116
|
+
|
117
|
+
(examples-for dox-what-is?
|
118
|
+
("for mac"
|
119
|
+
(dox-what-is? 'this-is-a-well-documented-macro)
|
120
|
+
mac)
|
121
|
+
|
122
|
+
("is a def"
|
123
|
+
(dox-what-is? 'this-is-a-well-documented-def)
|
124
|
+
def))
|
125
|
+
|
126
|
+
(examples-for dox-show-one-example
|
127
|
+
("produces a string representation of a given example"
|
128
|
+
(dox-show-one-example 'foo '("this is an example of an example"
|
129
|
+
(foo bar yadda 1 2 3)
|
130
|
+
720))
|
131
|
+
"foo this is an example of an example
|
132
|
+
|
133
|
+
running :
|
134
|
+
(foo bar yadda 1 2 3)
|
135
|
+
|
136
|
+
produces : 720
|
137
|
+
|
138
|
+
--------------------------------
|
139
|
+
"))
|
@@ -1,14 +1,14 @@
|
|
1
1
|
(dynamic foodynamic)
|
2
2
|
|
3
3
|
(def listfoody ()
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
(list (foodynamic)
|
5
|
+
(+ 6 (foodynamic))
|
6
|
+
(+ 10 (foodynamic))))
|
7
7
|
|
8
|
-
(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
(examples-for dynamic
|
9
|
+
("relies on thread-locals"
|
10
|
+
(list
|
11
|
+
(w/foodynamic 101 (listfoody))
|
12
|
+
(w/foodynamic 0 (listfoody))
|
13
|
+
(w/foodynamic 666 (listfoody)))
|
14
|
+
((101 107 111) (0 6 10) (666 672 676))))
|
@@ -1,5 +1,4 @@
|
|
1
|
-
(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
10)))
|
1
|
+
(examples-for each
|
2
|
+
("iterates over each item in list"
|
3
|
+
(let acc 0 (each x '(1 2 3 4) (assign acc (+ x acc))) acc)
|
4
|
+
10))
|
@@ -1,22 +1,23 @@
|
|
1
|
-
(
|
2
|
-
("
|
1
|
+
(examples-for ensure
|
2
|
+
("always gets called on the way out"
|
3
3
|
(let x 10
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
43)
|
4
|
+
(ensure (assign x (+ x 11))
|
5
|
+
(assign x (+ x 22)))
|
6
|
+
x)
|
7
|
+
43))
|
8
8
|
|
9
|
-
|
9
|
+
(examples-for on-err
|
10
|
+
("'handles errors"
|
10
11
|
(let x nil
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
(on-err (= x "impossible")
|
13
|
+
(= x (nil nil nil)))
|
14
|
+
x)
|
14
15
|
"impossible")
|
15
16
|
|
16
|
-
("
|
17
|
+
("handles errors but any ensuring clause gets called first"
|
17
18
|
(with (x nil y nil)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
(impossible ensure-clause)))
|
19
|
+
(on-err (= x 'impossible)
|
20
|
+
(ensure (assign y 'ensure-clause)
|
21
|
+
(nil nil nil)))
|
22
|
+
(list x y))
|
23
|
+
(impossible ensure-clause)))
|