nendo 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/example/scratch.nnd +107 -49
- data/lib/init.nnd +429 -78
- data/lib/init.nndc +16939 -9197
- data/lib/nendo.rb +163 -53
- data/lib/rfc/json.nnd +1 -1
- data/lib/rfc/json.nndc +21 -6
- data/lib/srfi-1.nnd +9 -5
- data/lib/srfi-1.nndc +684 -626
- data/lib/srfi-2.nnd +42 -0
- data/lib/srfi-2.nndc +1350 -0
- data/lib/srfi-26.nnd +50 -0
- data/lib/srfi-26.nndc +4124 -0
- data/lib/text/html-lite.nndc +7 -1
- data/lib/util/list.nnd +184 -0
- data/lib/util/list.nndc +5453 -0
- data/test/{util-test.nnd → nendo-util-test.nnd} +4 -4
- data/test/nendo_spec.rb +136 -81
- data/test/srfi-1-test.nnd +8 -4
- data/test/srfi-2-test.nnd +63 -0
- data/test/srfi-26-test.nnd +89 -0
- data/test/syntax_spec.rb +200 -0
- data/test/util-list-test.nnd +178 -0
- metadata +16 -5
data/test/syntax_spec.rb
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# syntax_spec.rb - "RSpec file for nendo language (syntax part)"
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2010 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
#
|
15
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer in the
|
17
|
+
# documentation and/or other materials provided with the distribution.
|
18
|
+
#
|
19
|
+
# 3. Neither the name of the authors nor the names of its contributors
|
20
|
+
# may be used to endorse or promote products derived from this
|
21
|
+
# software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
27
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
28
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
29
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
#
|
35
|
+
require 'nendo'
|
36
|
+
include Nendo
|
37
|
+
|
38
|
+
|
39
|
+
describe Nendo, "when read the core syntax keyword " do
|
40
|
+
before do
|
41
|
+
@nendo = Nendo::Core.new()
|
42
|
+
end
|
43
|
+
it "should" do
|
44
|
+
@nendo.evalStr( "(define a 1)" ).should == '1'
|
45
|
+
@nendo.evalStr( "(define a if)" ).should match( /Nendo::LispCoreSyntax/ )
|
46
|
+
@nendo.evalStr( "(eq? a if)" ).should == '#t'
|
47
|
+
@nendo.evalStr( "(define a begin)" ).should match( /Nendo::LispCoreSyntax/ )
|
48
|
+
@nendo.evalStr( "(eq? a begin)" ).should == '#t'
|
49
|
+
@nendo.evalStr( "(define a lambda)" ).should match( /Nendo::LispCoreSyntax/ )
|
50
|
+
@nendo.evalStr( "(eq? a lambda)" ).should == '#t'
|
51
|
+
@nendo.evalStr( "(define a macro)" ).should match( /Nendo::LispCoreSyntax/ )
|
52
|
+
@nendo.evalStr( "(eq? a macro)" ).should == '#t'
|
53
|
+
@nendo.evalStr( "(define a &block)" ).should match( /Nendo::LispCoreSyntax/ )
|
54
|
+
@nendo.evalStr( "(eq? a &block)" ).should == '#t'
|
55
|
+
@nendo.evalStr( "(define a let)" ).should match( /Nendo::LispCoreSyntax/ )
|
56
|
+
@nendo.evalStr( "(eq? a let)" ).should == '#t'
|
57
|
+
@nendo.evalStr( "(define a letrec)" ).should match( /Nendo::LispCoreSyntax/ )
|
58
|
+
@nendo.evalStr( "(eq? a letrec)" ).should == '#t'
|
59
|
+
@nendo.evalStr( "(define a set!)" ).should match( /Nendo::LispCoreSyntax/ )
|
60
|
+
@nendo.evalStr( "(eq? a set!)" ).should == '#t'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
describe Nendo, "when use identifier checker " do
|
66
|
+
before do
|
67
|
+
@nendo = Nendo::Core.new()
|
68
|
+
@nendo.loadInitFile
|
69
|
+
end
|
70
|
+
it "should" do
|
71
|
+
@nendo.evalStr( "(symbol? 'a)" ).should == '#t'
|
72
|
+
@nendo.evalStr( "(identifier? 'a)" ).should == '#t'
|
73
|
+
@nendo.evalStr( "(identifier? 'identifier)" ).should == '#t'
|
74
|
+
@nendo.evalStr( "(identifier? 'lambda)" ).should == '#t'
|
75
|
+
@nendo.evalStr( "(identifier? 10)" ).should == '#f'
|
76
|
+
@nendo.evalStr( "(identifier? \"str\")" ).should == '#f'
|
77
|
+
@nendo.evalStr( "(identifier=? '() 'lambda '() 'lambda)" ).should == '#t'
|
78
|
+
@nendo.evalStr( "(identifier=? '() 'define '() 'lambda)" ).should == '#f'
|
79
|
+
@nendo.evalStr( "(identifier=? '() 'if '() '/nendo/macroenv/if)" ).should == '#f'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
describe Nendo, "when call make-syntactic-closure " do
|
85
|
+
before do
|
86
|
+
@nendo = Nendo::Core.new()
|
87
|
+
@nendo.loadInitFile
|
88
|
+
end
|
89
|
+
it "should" do
|
90
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'print )" ).should == 'print'
|
91
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'if )" ).should == 'if'
|
92
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'lambda )" ).should == 'lambda'
|
93
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'aaaa )" ).should match( /_gensym_/ )
|
94
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'tmp )" ).should match( /_gensym_/ )
|
95
|
+
@nendo.evalStr( "(define name (make-syntactic-closure (global-variables) '() 'tmp ))" ).should match( /_gensym_/ )
|
96
|
+
@nendo.evalStr( "name" ).should match( /_gensym_/ )
|
97
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'new_global_var)" ).should match( /_gensym_/ )
|
98
|
+
@nendo.evalStr( "(define new_global_var 10)" ).should == '10'
|
99
|
+
@nendo.evalStr( "(make-syntactic-closure (global-variables) '() 'new_global_var)" ).should == 'new_global_var'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
describe Nendo, "when use core syntax " do
|
105
|
+
before do
|
106
|
+
@nendo = Nendo::Core.new()
|
107
|
+
@nendo.loadInitFile
|
108
|
+
end
|
109
|
+
it "should" do
|
110
|
+
@nendo.evalStr( "(if #t 1 2)" ).should == '1'
|
111
|
+
@nendo.evalStr( "(if #f 1 2)" ).should == '2'
|
112
|
+
@nendo.evalStr( "(/nendo/core/if #t 1 2)" ).should == '1'
|
113
|
+
@nendo.evalStr( "(/nendo/core/if #f 1 2)" ).should == '2'
|
114
|
+
@nendo.evalStr( "(begin 1 2 3)" ).should == '3'
|
115
|
+
@nendo.evalStr( "(/nendo/core/begin 1 2 3)" ).should == '3'
|
116
|
+
@nendo.evalStr( "(car (memq '/nendo/core/begin (global-variables)))" ).should == '/nendo/core/begin'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
describe Nendo, "when use er-macro-transformer " do
|
122
|
+
before do
|
123
|
+
@nendo = Nendo::Core.new()
|
124
|
+
@nendo.loadInitFile
|
125
|
+
end
|
126
|
+
it "should" do
|
127
|
+
@nendo.evalStr( " " +
|
128
|
+
"(define-syntax my-or" +
|
129
|
+
" (er-macro-transformer" +
|
130
|
+
" (lambda (expr rename compare)" +
|
131
|
+
" (cond ((null? (cdr expr)) #f)" +
|
132
|
+
" ((null? (cddr expr)) (cadr expr))" +
|
133
|
+
" (else" +
|
134
|
+
" (list (rename 'let) (list (list (rename 'tmp) (cadr expr)))" +
|
135
|
+
" (list (rename 'if) (rename 'tmp)" +
|
136
|
+
" (rename 'tmp)" +
|
137
|
+
" (cons (rename 'my-or) (cddr expr)))))))))" +
|
138
|
+
"my-or" ).should match( /Nendo::LispSyntax/ )
|
139
|
+
@nendo.evalStr( "(my-or 1 2)" ).should == '1'
|
140
|
+
@nendo.evalStr( "(my-or #f 100 200)" ).should == '100'
|
141
|
+
@nendo.evalStr( "(my-or #f #f #f #f 500)" ).should == '500'
|
142
|
+
@nendo.evalStr( "(my-or #f #f #f #f #f)" ).should == '#f'
|
143
|
+
|
144
|
+
@nendo.evalStr( " " +
|
145
|
+
"(define-syntax my-and" +
|
146
|
+
" (er-macro-transformer" +
|
147
|
+
" (lambda (expr rename compare)" +
|
148
|
+
" (cond ((null? (cdr expr)))" +
|
149
|
+
" ((null? (cddr expr)) (cadr expr))" +
|
150
|
+
" (else (list (rename 'if) (cadr expr)" +
|
151
|
+
" (cons (rename 'my-and) (cddr expr))" +
|
152
|
+
" #f))))))" +
|
153
|
+
"my-and" ).should match( /Nendo::LispSyntax/ )
|
154
|
+
@nendo.evalStr( "(my-and 1 2)" ).should == '2'
|
155
|
+
@nendo.evalStr( "(my-and 1 2 3 4)" ).should == '4'
|
156
|
+
@nendo.evalStr( "(my-and #t #t #t #t 500)" ).should == '500'
|
157
|
+
@nendo.evalStr( "(my-and 1 2 3 4 #f)" ).should == '#f'
|
158
|
+
@nendo.evalStr( "(my-and 1 2 #f 4 5)" ).should == '#f'
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
describe Nendo, "when use syntax-rules " do
|
164
|
+
before do
|
165
|
+
@nendo = Nendo::Core.new()
|
166
|
+
@nendo.loadInitFile
|
167
|
+
end
|
168
|
+
it "should" do
|
169
|
+
@nendo.evalStr( " " +
|
170
|
+
"(define-syntax nil!" +
|
171
|
+
" (syntax-rules ()" +
|
172
|
+
" ((_ x)" +
|
173
|
+
" (set! x '()))))" +
|
174
|
+
"nil!" ).should match( /Nendo::LispSyntax/ )
|
175
|
+
@nendo.evalStr( "(define a 1) a" ).should == '1'
|
176
|
+
@nendo.evalStr( "(nil! a) a" ).should == '()'
|
177
|
+
@nendo.evalStr( "(set! a 2) a" ).should == '2'
|
178
|
+
@nendo.evalStr( "(nil! a) a" ).should == '()'
|
179
|
+
@nendo.evalStr( " " +
|
180
|
+
"(define-syntax test-syntax" +
|
181
|
+
" (syntax-rules ()" +
|
182
|
+
" ((_ a)" +
|
183
|
+
" (list a))" +
|
184
|
+
" ((_ a b)" +
|
185
|
+
" (list a (list b)))" +
|
186
|
+
" ((_ a b c ...)" +
|
187
|
+
" (list a (list b (list c ...))))))" +
|
188
|
+
"test-syntax" ).should match( /Nendo::LispSyntax/ )
|
189
|
+
@nendo.evalStr( "(test-syntax 1)" ).should == '(1)'
|
190
|
+
@nendo.evalStr( "(test-syntax 1 2)" ).should == '(1 (2))'
|
191
|
+
@nendo.evalStr( "(test-syntax 1 2 3)" ).should == '(1 (2 (3)))'
|
192
|
+
@nendo.evalStr( "(test-syntax 1 2 3 4)" ).should == '(1 (2 (3 4)))'
|
193
|
+
@nendo.evalStr( "(test-syntax 1 2 3 4 5)" ).should == '(1 (2 (3 4 5)))'
|
194
|
+
@nendo.evalStr( "(test-syntax 1 2 3 4 5 6)" ).should == '(1 (2 (3 4 5 6)))'
|
195
|
+
@nendo.evalStr( "(test-syntax 'a)" ).should == '(a)'
|
196
|
+
@nendo.evalStr( "(test-syntax 'a \"B\")" ).should == '(a ("B"))'
|
197
|
+
@nendo.evalStr( "(test-syntax 'a \"B\" 'C)" ).should == '(a ("B" (C)))'
|
198
|
+
@nendo.evalStr( "(test-syntax 'a \"B\" 'C \"d\")" ).should == '(a ("B" (C "d")))'
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
;;-*- mode: nendo; syntax: scheme -*-;;
|
2
|
+
;;
|
3
|
+
;; util-list-test.nnd - test suite for util.list
|
4
|
+
;;
|
5
|
+
;; Copyright (c) 2000-2010 Shiro Kawai <shiro@acm.org>
|
6
|
+
;;
|
7
|
+
;; Redistribution and use in source and binary forms, with or without
|
8
|
+
;; modification, are permitted provided that the following conditions
|
9
|
+
;; are met:
|
10
|
+
;;
|
11
|
+
;; 1. Redistributions of source code must retain the above copyright
|
12
|
+
;; notice, this list of conditions and the following disclaimer.
|
13
|
+
;;
|
14
|
+
;; 2. Redistributions in binary form must reproduce the above copyright
|
15
|
+
;; notice, this list of conditions and the following disclaimer in the
|
16
|
+
;; documentation and/or other materials provided with the distribution.
|
17
|
+
;;
|
18
|
+
;; 3. Neither the name of the authors nor the names of its contributors
|
19
|
+
;; may be used to endorse or promote products derived from this
|
20
|
+
;; software without specific prior written permission.
|
21
|
+
;;
|
22
|
+
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
23
|
+
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
24
|
+
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
25
|
+
;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
26
|
+
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
27
|
+
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
28
|
+
;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
29
|
+
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
30
|
+
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
31
|
+
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
32
|
+
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
|
34
|
+
|
35
|
+
(use nendo.test)
|
36
|
+
(test-start "util")
|
37
|
+
|
38
|
+
;;===================================================================
|
39
|
+
;;-------------------------------------------------------------------
|
40
|
+
|
41
|
+
(test-section "util.list")
|
42
|
+
(use util.list)
|
43
|
+
(test-module 'util.list)
|
44
|
+
|
45
|
+
(test* "split-at* (normal)" '((a b c) (d))
|
46
|
+
(receive r (split-at* '(a b c d) 3) r))
|
47
|
+
(test* "split-at* (boundary)" '(() (a b c d))
|
48
|
+
(receive r (split-at* '(a b c d) 0) r))
|
49
|
+
(test* "split-at* (boundary)" '((a b c d) ())
|
50
|
+
(receive r (split-at* '(a b c d) 4) r))
|
51
|
+
;;(test* "split-at* (error)" (test-error)
|
52
|
+
;; (receive r (split-at* '(a b c d) -1) r))
|
53
|
+
(test* "split-at* (shorten)" '((a b c d) ())
|
54
|
+
(receive r (split-at* '(a b c d) 5) r))
|
55
|
+
(test* "split-at* (fill)" '((a b c d #f #f) ())
|
56
|
+
(receive r (split-at* '(a b c d) 6 #t) r))
|
57
|
+
(test* "split-at* (fill)" '((a b c d z z) ())
|
58
|
+
(receive r (split-at* '(a b c d) 6 #t 'z) r))
|
59
|
+
|
60
|
+
(test* "take* (normal)" '(a b c) (take* '(a b c d) 3))
|
61
|
+
(test* "take* (boundary)" '() (take* '(a b c d) 0))
|
62
|
+
(test* "take* (boundary)" '(a b c d) (take* '(a b c d) 4))
|
63
|
+
;;(test* "take* (error)" (test-error) (take* '(a b c d) -1))
|
64
|
+
(test* "take* (shorten)" '(a b c d) (take* '(a b c d) 5))
|
65
|
+
(test* "take* (fill)" '(a b c d #f #f) (take* '(a b c d) 6 #t))
|
66
|
+
(test* "take* (fill)" '(a b c d z z) (take* '(a b c d) 6 #t 'z))
|
67
|
+
|
68
|
+
(test* "drop* (normal)" '(c d) (drop* '(a b c d) 2))
|
69
|
+
(test* "drop* (boundary)" '(a b c d) (drop* '(a b c d) 0))
|
70
|
+
(test* "drop* (boundary)" '() (drop* '(a b c d) 4))
|
71
|
+
;;(test* "drop* (error)" (test-error) (drop* '(a b c d) -3))
|
72
|
+
(test* "drop* (past)" '() (drop* '(a b c d) 5))
|
73
|
+
|
74
|
+
(test* "take-right* (normal)" '(b c d) (take-right* '(a b c d) 3))
|
75
|
+
(test* "take-right* (boundary)" '() (take-right* '(a b c d) 0))
|
76
|
+
(test* "take-right* (boundary)" '(a b c d) (take-right* '(a b c d) 4))
|
77
|
+
;;(test* "take-right* (error)" (test-error) (take-right* '(a b c d) -1))
|
78
|
+
(test* "take-right* (shorten)" '(a b c d) (take-right* '(a b c d) 6))
|
79
|
+
(test* "take-right* (fill)" '(z z a b c d) (take-right* '(a b c d) 6 #t 'z))
|
80
|
+
|
81
|
+
(test* "drop-right* (normal)" '(a b c) (drop-right* '(a b c d) 1))
|
82
|
+
(test* "drop-right* (boundary)" '() (drop-right* '(a b c d) 4))
|
83
|
+
(test* "drop-right* (boundary)" '(a b c d) (drop-right* '(a b c d) 0))
|
84
|
+
;;(test* "drop-right* (error)" (test-error) (drop-right* '(a b c d) -1))
|
85
|
+
(test* "drop-right* (past)" '() (drop-right* '(a b c d) 7))
|
86
|
+
|
87
|
+
(test* "slices (normal)" '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12 13 14 15))
|
88
|
+
(slices (iota 16) 4))
|
89
|
+
(test* "slices (boundary)" '()
|
90
|
+
(slices '() 4))
|
91
|
+
(test* "slices (short)" '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12))
|
92
|
+
(slices (iota 13) 4))
|
93
|
+
(test* "slices (short)" '((0 1))
|
94
|
+
(slices (iota 2) 4))
|
95
|
+
(test* "slices (fill)" '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12 #f #f #f))
|
96
|
+
(slices (iota 13) 4 #t))
|
97
|
+
(test* "slices (fill)" '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12 -1 -1 -1))
|
98
|
+
(slices (iota 13) 4 #t -1))
|
99
|
+
|
100
|
+
(test* "intersperse" '(1 + 2 + 3) (intersperse '+ '(1 2 3)))
|
101
|
+
(test* "intersperse" '(1 + 2) (intersperse '+ '(1 2)))
|
102
|
+
(test* "intersperse" '(1) (intersperse '+ '(1)))
|
103
|
+
(test* "intersperse" '() (intersperse '+ '()))
|
104
|
+
|
105
|
+
(test* "cond-list" '() (cond-list))
|
106
|
+
(test* "cond-list" '(a) (cond-list ('a)))
|
107
|
+
(test* "cond-list" '(a) (cond-list (#t 'a) (#f 'b)))
|
108
|
+
(test* "cond-list" '(b) (cond-list (#f 'a) (#t 'b)))
|
109
|
+
(test* "cond-list" '(a b d) (cond-list (#t 'a) (#t 'b) (#f 'c) (#t 'd)))
|
110
|
+
(test* "cond-list" '((b)) (cond-list (#f 'a) ('b => list)))
|
111
|
+
(test* "cond-list" '(a b c d x)
|
112
|
+
(cond-list (#t @ '(a b)) (#t @ '(c d)) (#f @ '(e f))
|
113
|
+
('x => @ list)))
|
114
|
+
|
115
|
+
(test* "alist->hash-table" '(a b)
|
116
|
+
(let ((ht (alist->hash-table '((5 . b) (3 . a)) 'eqv?)))
|
117
|
+
(list (hash-table-get ht 3)
|
118
|
+
(hash-table-get ht 5))))
|
119
|
+
(when #f
|
120
|
+
;; Nendo does not support equal? for hash-table key compare
|
121
|
+
(test* "hash-table->alist" '(("a" . 3) ("b" . 5))
|
122
|
+
(let ((a (hash-table->alist
|
123
|
+
(hash-table 'equal? '("a" . 3) '("b" . 5)))))
|
124
|
+
(list (assoc "a" a)
|
125
|
+
(assoc "b" a)))))
|
126
|
+
|
127
|
+
(test* "rassoc" '(5 . "b")
|
128
|
+
(rassoc "b" '((3 . "a") (5 . "b"))))
|
129
|
+
(test* "rassq" '(5 . b)
|
130
|
+
(rassq 'b '((3 . a) (5 . b))))
|
131
|
+
(test* "rassv" '("b" . 5)
|
132
|
+
(rassoc 5 '(("a" . 3) ("b" . 5))))
|
133
|
+
|
134
|
+
(when #f
|
135
|
+
;; Nendo does not support (XassX alist obj) argument sequences.
|
136
|
+
(test* "assoc-ref" 5
|
137
|
+
(assoc-ref '(("a" . 3) ("b" . 5)) "b"))
|
138
|
+
(test* "assoc-ref" 7
|
139
|
+
(assoc-ref '(("a" . 3) ("b" . 5)) "c" 7))
|
140
|
+
(test* "assq-ref" 5
|
141
|
+
(assq-ref '((a . 3) (b . 5)) 'b))
|
142
|
+
(test* "assq-ref" 7
|
143
|
+
(assq-ref '((a . 3) (b . 5)) 'c 7))
|
144
|
+
(test* "assv-ref" 'b
|
145
|
+
(assv-ref '((3 . a) (5 . b)) 5))
|
146
|
+
(test* "assv-ref" 'c
|
147
|
+
(assv-ref '((3 . a) (5 . b)) 7 'c))
|
148
|
+
|
149
|
+
(test* "rassoc-ref" 5
|
150
|
+
(rassoc-ref '((3 . "a") (5 . "b")) "b"))
|
151
|
+
(test* "rassoc-ref" 7
|
152
|
+
(rassoc-ref '((3 . "a") (5 . "b")) "c" 7))
|
153
|
+
(test* "rassq-ref" 5
|
154
|
+
(rassq-ref '((3 . a) (5 . b)) 'b))
|
155
|
+
(test* "rassq-ref" #f
|
156
|
+
(rassq-ref '((3 . a) (5 . b)) 'c))
|
157
|
+
(test* "rassv-ref" 'b
|
158
|
+
(rassv-ref '((a . 3) (b . 5)) 5))
|
159
|
+
(test* "rassv-ref" #f
|
160
|
+
(rassv-ref '((a . 3) (b . 5)) 7))
|
161
|
+
|
162
|
+
(test* "assoc-set!" '(("a" . 3) ("b" . 9))
|
163
|
+
(assoc-set! (list (cons "a" 3) (cons "b" 5)) "b" 9))
|
164
|
+
(test* "assoc-set!" '(("c" . 9) ("a" . 3) ("b" . 5))
|
165
|
+
(assoc-set! (list (cons "a" 3) (cons "b" 5)) "c" 9))
|
166
|
+
(test* "assq-set!" '((a . 3) (b . 9))
|
167
|
+
(assq-set! (list (cons 'a 3) (cons 'b 5)) 'b 9))
|
168
|
+
(test* "assq-set!" '((c . 9) (a . 3) (b . 5))
|
169
|
+
(assq-set! (list (cons 'a 3) (cons 'b 5)) 'c 9))
|
170
|
+
(test* "assv-set!" '((3 . a) (5 . c))
|
171
|
+
(assv-set! (list (cons 3 'a) (cons 5 'b)) 5 'c))
|
172
|
+
(test* "assv-set!" '((9 . c) (3 . a) (5 . b))
|
173
|
+
(assv-set! (list (cons 3 'a) (cons 5 'b)) 9 'c)))
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
;;===================================================================
|
178
|
+
(test-end)
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kiyoka Nishiyama
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-04-25 00:00:00 +09:00
|
18
18
|
default_executable: nendo
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -73,15 +73,25 @@ files:
|
|
73
73
|
- lib/rfc/json.nndc
|
74
74
|
- lib/srfi-1.nnd
|
75
75
|
- lib/srfi-1.nndc
|
76
|
+
- lib/srfi-2.nnd
|
77
|
+
- lib/srfi-2.nndc
|
78
|
+
- lib/srfi-26.nnd
|
79
|
+
- lib/srfi-26.nndc
|
76
80
|
- lib/text/html-lite.nnd
|
77
81
|
- lib/text/html-lite.nndc
|
78
82
|
- lib/text/tree.nnd
|
79
83
|
- lib/text/tree.nndc
|
84
|
+
- lib/util/list.nnd
|
85
|
+
- lib/util/list.nndc
|
80
86
|
- test/json-test.nnd
|
87
|
+
- test/nendo-util-test.nnd
|
81
88
|
- test/nendo_spec.rb
|
82
89
|
- test/srfi-1-test.nnd
|
90
|
+
- test/srfi-2-test.nnd
|
91
|
+
- test/srfi-26-test.nnd
|
92
|
+
- test/syntax_spec.rb
|
83
93
|
- test/textlib-test.nnd
|
84
|
-
- test/util-test.nnd
|
94
|
+
- test/util-list-test.nnd
|
85
95
|
- README
|
86
96
|
has_rdoc: true
|
87
97
|
homepage: http://github.com/kiyoka/nendo
|
@@ -117,3 +127,4 @@ specification_version: 3
|
|
117
127
|
summary: Nendo is a dialect of Lisp.
|
118
128
|
test_files:
|
119
129
|
- test/nendo_spec.rb
|
130
|
+
- test/syntax_spec.rb
|