nendo 0.6.8 → 0.7.0
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/Rakefile +10 -14
- data/VERSION.yml +2 -2
- data/lib/nendo/init.nnd +1 -1
- data/lib/nendo/init.nndc +2 -2
- data/lib/nendo/ruby/builtin_functions.rb +5 -5
- data/lib/nendo/ruby/core.rb +1 -1
- data/lib/nendo/ruby/types.rb +5 -1
- metadata +7 -22
- data/test/json-test.nnd +0 -178
- data/test/match-test.nnd +0 -186
- data/test/nendo-util-test.nnd +0 -496
- data/test/nendo_spec.rb +0 -551
- data/test/nendo_spec_2.rb +0 -2135
- data/test/nendo_spec_3.rb +0 -105
- data/test/rspec_formatter_for_emacs.rb +0 -26
- data/test/srfi-1-test.nnd +0 -684
- data/test/srfi-2-test.nnd +0 -63
- data/test/srfi-26-test.nnd +0 -89
- data/test/syntax_spec.rb +0 -1059
- data/test/testframework_spec.rb +0 -153
- data/test/textlib-test.nnd +0 -24
- data/test/util-combinations-test.nnd +0 -383
- data/test/util-list-test.nnd +0 -178
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e43ea541a6bbdca2625d687abf0dae79d296a5
|
4
|
+
data.tar.gz: 01ae070b1e0f5feb02d5630967458b6f884f8a8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 956fceccaefa4f7095a93e60940940bacfb7a131d02a952f4e6ac9ea0151e613abfc9e56a3dc0398e4e28263290241d71e2dc14b7d82d7f70183227a3a0c83e9
|
7
|
+
data.tar.gz: b5ae4669f881a267931485675063379a270b15731935bfa18847654fe59928240f5085393fbbf5ade76add5e2111cd522814acb6b93eb57055a21f798fa56c4f
|
data/Rakefile
CHANGED
@@ -54,23 +54,19 @@ task :test => [:test1, :test2] do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
task :test1 do
|
57
|
-
sh "
|
58
|
-
sh "ruby -I ./lib
|
59
|
-
sh "ruby -I ./lib `which rspec` -b ./test/nendo_spec_3.rb "
|
60
|
-
sh "ruby -I ./lib `which rspec` -b ./test/syntax_spec.rb "
|
61
|
-
sh "ruby -I ./lib `which rspec` -b ./test/testframework_spec.rb "
|
62
|
-
sh "ruby -I ./lib ./bin/nendo ./test/srfi-1-test.nnd"
|
57
|
+
sh "rspec -I ./lib -b "
|
58
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/srfi-1-test.nnd"
|
63
59
|
end
|
64
60
|
|
65
61
|
task :test2 do
|
66
62
|
sh "/bin/rm -f test.record"
|
67
63
|
sh "echo "" > test.log"
|
68
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
69
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
70
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
71
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
72
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
73
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
64
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/textlib-test.nnd >> test.log"
|
65
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/nendo-util-test.nnd >> test.log"
|
66
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/json-test.nnd >> test.log"
|
67
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/srfi-2-test.nnd >> test.log"
|
68
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/srfi-26-test.nnd >> test.log"
|
69
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/util-list-test.nnd >> test.log"
|
74
70
|
sh "cat test.record"
|
75
71
|
sh "grep ' 0 failed, ' test.record > /dev/null"
|
76
72
|
end
|
@@ -78,8 +74,8 @@ end
|
|
78
74
|
task :test3 do
|
79
75
|
sh "/bin/rm -f test.record"
|
80
76
|
sh "echo "" > test3.log"
|
81
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
82
|
-
sh "ruby -I ./lib ./bin/nendo ./
|
77
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/match-test.nnd | tee -a test3.log"
|
78
|
+
sh "ruby -I ./lib ./bin/nendo ./spec/util-combinations-test.nnd | tee -a test3.log"
|
83
79
|
sh "cat test.record"
|
84
80
|
sh "grep ' 0 failed, ' test.record > /dev/null"
|
85
81
|
end
|
data/VERSION.yml
CHANGED
data/lib/nendo/init.nnd
CHANGED
data/lib/nendo/init.nndc
CHANGED
@@ -2204,9 +2204,9 @@ trampCall(
|
|
2204
2204
|
trampCall(
|
2205
2205
|
Proc.new { |_a,_b|
|
2206
2206
|
begin
|
2207
|
-
delayCall( '
|
2207
|
+
delayCall( '_equal_QUMARK', 'equal?',
|
2208
2208
|
begin
|
2209
|
-
trampCall(@
|
2209
|
+
trampCall(@_equal_QUMARK)
|
2210
2210
|
end ,
|
2211
2211
|
[
|
2212
2212
|
begin
|
@@ -58,7 +58,7 @@ module Nendo
|
|
58
58
|
a = a.intern if a.class == ParsedSymbol
|
59
59
|
b = b.intern if b.class == ParsedSymbol
|
60
60
|
if a.is_a? String and b.is_a? String
|
61
|
-
a
|
61
|
+
a == b
|
62
62
|
elsif a.class != b.class
|
63
63
|
false
|
64
64
|
elsif a.is_a? Cell
|
@@ -68,7 +68,7 @@ module Nendo
|
|
68
68
|
elsif a.is_a? Proc
|
69
69
|
a == b
|
70
70
|
else
|
71
|
-
(a
|
71
|
+
(a == b)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -276,7 +276,7 @@ module Nendo
|
|
276
276
|
(0..num-1).to_a.to_list
|
277
277
|
end
|
278
278
|
end
|
279
|
-
def __EQMARK( a,b )
|
279
|
+
def __EQMARK( a,b ) _equal_QUMARK( a, b ) end
|
280
280
|
def __GTMARK( a,b ) a > b end
|
281
281
|
def __GTMARK_EQMARK( a,b ) a >= b end
|
282
282
|
def __LTMARK( a,b ) a < b end
|
@@ -284,7 +284,7 @@ module Nendo
|
|
284
284
|
def _eq_QUMARK( a,b )
|
285
285
|
a = a.intern if a.class == ParsedSymbol
|
286
286
|
b = b.intern if b.class == ParsedSymbol
|
287
|
-
a
|
287
|
+
a.equal?( b )
|
288
288
|
end
|
289
289
|
def _gt_QUMARK( a,b ) a > b end
|
290
290
|
def _ge_QUMARK( a,b ) a >= b end
|
@@ -293,7 +293,7 @@ module Nendo
|
|
293
293
|
def _eqv_QUMARK( a,b )
|
294
294
|
a = a.intern if a.class == ParsedSymbol
|
295
295
|
b = b.intern if b.class == ParsedSymbol
|
296
|
-
a
|
296
|
+
a == b
|
297
297
|
end
|
298
298
|
def _car( cell ) cell.car end
|
299
299
|
def _cdr( cell )
|
data/lib/nendo/ruby/core.rb
CHANGED
data/lib/nendo/ruby/types.rb
CHANGED
@@ -197,7 +197,7 @@ module Nendo
|
|
197
197
|
|
198
198
|
def ==(other)
|
199
199
|
if other.is_a? LispKeyword
|
200
|
-
self.key == other.key
|
200
|
+
self.key.intern == other.key.intern
|
201
201
|
else
|
202
202
|
false
|
203
203
|
end
|
@@ -207,6 +207,10 @@ module Nendo
|
|
207
207
|
self.==(other)
|
208
208
|
end
|
209
209
|
|
210
|
+
def equal?(other)
|
211
|
+
self.==(other)
|
212
|
+
end
|
213
|
+
|
210
214
|
def to_s
|
211
215
|
self.key.to_s
|
212
216
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nendo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kiyoka Nishiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Nendo is a programming language written in Ruby.
|
14
14
|
email: kiyoka@sumibi.org
|
@@ -18,7 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files:
|
19
19
|
- README.md
|
20
20
|
files:
|
21
|
-
-
|
21
|
+
- .gemtest
|
22
22
|
- COPYING
|
23
23
|
- History.txt
|
24
24
|
- README.md
|
@@ -82,44 +82,29 @@ files:
|
|
82
82
|
- lib/nendo/util/list.nndc
|
83
83
|
- lib/nendo/util/match.nnd
|
84
84
|
- lib/nendo/util/match.nndc
|
85
|
-
- test/json-test.nnd
|
86
|
-
- test/match-test.nnd
|
87
|
-
- test/nendo-util-test.nnd
|
88
|
-
- test/nendo_spec.rb
|
89
|
-
- test/nendo_spec_2.rb
|
90
|
-
- test/nendo_spec_3.rb
|
91
|
-
- test/rspec_formatter_for_emacs.rb
|
92
|
-
- test/srfi-1-test.nnd
|
93
|
-
- test/srfi-2-test.nnd
|
94
|
-
- test/srfi-26-test.nnd
|
95
|
-
- test/syntax_spec.rb
|
96
|
-
- test/testframework_spec.rb
|
97
|
-
- test/textlib-test.nnd
|
98
|
-
- test/util-combinations-test.nnd
|
99
|
-
- test/util-list-test.nnd
|
100
85
|
homepage: http://github.com/kiyoka/nendo
|
101
86
|
licenses:
|
102
87
|
- New BSD
|
103
88
|
metadata: {}
|
104
89
|
post_install_message:
|
105
90
|
rdoc_options:
|
106
|
-
-
|
91
|
+
- -x
|
107
92
|
- match.nndc
|
108
93
|
require_paths:
|
109
94
|
- lib
|
110
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
96
|
requirements:
|
112
|
-
- -
|
97
|
+
- - '>='
|
113
98
|
- !ruby/object:Gem::Version
|
114
99
|
version: '0'
|
115
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
101
|
requirements:
|
117
|
-
- -
|
102
|
+
- - '>='
|
118
103
|
- !ruby/object:Gem::Version
|
119
104
|
version: '0'
|
120
105
|
requirements: []
|
121
106
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.0.14
|
123
108
|
signing_key:
|
124
109
|
specification_version: 4
|
125
110
|
summary: Nendo is a dialect of Lisp.
|
data/test/json-test.nnd
DELETED
@@ -1,178 +0,0 @@
|
|
1
|
-
;;-*- mode: nendo; syntax: scheme -*-
|
2
|
-
;;;
|
3
|
-
;;; json-test.nnd - test of json.nnd
|
4
|
-
;;;
|
5
|
-
;;; Copyright (c) 2011 Kiyoka Nishiyama <kiyoka@sumibi.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
|
-
;;; $Id:
|
35
|
-
;;;
|
36
|
-
(use nendo.test)
|
37
|
-
(use rfc.json)
|
38
|
-
|
39
|
-
(test-start "json")
|
40
|
-
|
41
|
-
;;===================================================================
|
42
|
-
|
43
|
-
;;-------------------------------------------------------------------
|
44
|
-
(test-section "json parser")
|
45
|
-
|
46
|
-
(test* "string (1)"
|
47
|
-
'#( "str" )
|
48
|
-
(parse-json-string "[\"str\"]"))
|
49
|
-
|
50
|
-
(test* "string (2)"
|
51
|
-
'#( "Ã" )
|
52
|
-
(parse-json-string "[\"Ã\"]"))
|
53
|
-
|
54
|
-
(test* "string (3)"
|
55
|
-
'#( "Ã" "€" )
|
56
|
-
(parse-json-string "[ \"\\u00c3\", \"\\u20ac\" ]"))
|
57
|
-
|
58
|
-
(test* "string (4)"
|
59
|
-
'#(nil)
|
60
|
-
(parse-json-string "[null]"))
|
61
|
-
|
62
|
-
(test* "string (4)"
|
63
|
-
'#(nil)
|
64
|
-
(parse-json-string "[null]"))
|
65
|
-
|
66
|
-
(test* "string (5)"
|
67
|
-
'#(#t)
|
68
|
-
(parse-json-string "[true]"))
|
69
|
-
|
70
|
-
(test* "string (6)"
|
71
|
-
'#(#f)
|
72
|
-
(parse-json-string "[false]"))
|
73
|
-
|
74
|
-
|
75
|
-
(test* "simple object (1)"
|
76
|
-
'()
|
77
|
-
(parse-json-string "{}"))
|
78
|
-
(test* "simple object (2)"
|
79
|
-
'()
|
80
|
-
(parse-json-string " { } "))
|
81
|
-
(test* "simple object (3)"
|
82
|
-
'(("a" . 23))
|
83
|
-
(parse-json-string "{ \"a\": 23 } "))
|
84
|
-
(test* "simple object (4)"
|
85
|
-
'(("a" . 23) ("b" . 45))
|
86
|
-
(parse-json-string "{ \"a\": 23 , \"b\": 45 } "))
|
87
|
-
|
88
|
-
(test* "arrays (1)"
|
89
|
-
'#(1 2 3)
|
90
|
-
(parse-json-string "[1,2,3]"))
|
91
|
-
(test* "arrays (2)"
|
92
|
-
'#(#() #(#() #()))
|
93
|
-
(parse-json-string "[[],[[],[]]]"))
|
94
|
-
(test* "arrays (3)"
|
95
|
-
'#(#(4)
|
96
|
-
#(#(5) #(6)))
|
97
|
-
(parse-json-string "[[4],[[5],[6]]]"))
|
98
|
-
|
99
|
-
|
100
|
-
(define testdata-json-string
|
101
|
-
(string-join
|
102
|
-
'("["
|
103
|
-
" { \"a\": 1, "
|
104
|
-
" \"b\": 2, "
|
105
|
-
" \"c\": { \"c1\": 10,"
|
106
|
-
" \"c2\": 20 },"
|
107
|
-
" \"d\": [ \"vec1\", \"vec2\", \"vec3\" ]"
|
108
|
-
" },"
|
109
|
-
" { \"true\" : true , "
|
110
|
-
" \"false\" : false , "
|
111
|
-
" \"null\" : null "
|
112
|
-
" }"
|
113
|
-
"]")))
|
114
|
-
|
115
|
-
(define testdata-lisp-object
|
116
|
-
'#(
|
117
|
-
(("a" . 1)
|
118
|
-
("b" . 2)
|
119
|
-
("c" . (
|
120
|
-
("c1" . 10)
|
121
|
-
("c2" . 20)))
|
122
|
-
("d" . #("vec1" "vec2" "vec3")))
|
123
|
-
(("true" . true)
|
124
|
-
("false" . false)
|
125
|
-
("null" . nil))))
|
126
|
-
|
127
|
-
|
128
|
-
(test* "array and hash (1)"
|
129
|
-
(write-to-string testdata-lisp-object)
|
130
|
-
(write-to-string (parse-json-string testdata-json-string)))
|
131
|
-
|
132
|
-
|
133
|
-
(let1 sio (StringIO.new "{\"a\":23,\"b\":45}")
|
134
|
-
(test* "write to IO"
|
135
|
-
'(("a" . 23) ("b" . 45))
|
136
|
-
(parse-json sio)))
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
;;-------------------------------------------------------------------
|
141
|
-
(test-section "json constructor")
|
142
|
-
|
143
|
-
(test* "string (1)"
|
144
|
-
"[\"str\"]"
|
145
|
-
(construct-json-string '#( "str" )))
|
146
|
-
|
147
|
-
(test* "arrays (1)"
|
148
|
-
"[1,2,3]"
|
149
|
-
(construct-json-string '#(1 2 3)))
|
150
|
-
(test* "arrays (2)"
|
151
|
-
"[[],[[],[]]]"
|
152
|
-
(construct-json-string '#(#() #(#() #()))))
|
153
|
-
|
154
|
-
(test* "simple object (1)"
|
155
|
-
"{}"
|
156
|
-
(construct-json-string '()))
|
157
|
-
(test* "simple object (2)"
|
158
|
-
"{\"a\":23}"
|
159
|
-
(construct-json-string '(("a" . 23))))
|
160
|
-
(test* "simple object (3)"
|
161
|
-
"{\"a\":23,\"b\":45}"
|
162
|
-
(construct-json-string '(("a" . 23) ("b" . 45))))
|
163
|
-
|
164
|
-
(test* "array and hash (1)"
|
165
|
-
(testdata-json-string.gsub #/[ ]/ "")
|
166
|
-
(construct-json-string testdata-lisp-object))
|
167
|
-
|
168
|
-
(let1 sio (StringIO.new)
|
169
|
-
(test* "write to IO"
|
170
|
-
"{\"a\":23,\"b\":45}"
|
171
|
-
(begin
|
172
|
-
(construct-json '(("a" . 23) ("b" . 45)) sio)
|
173
|
-
(sio.rewind)
|
174
|
-
(sio.read))))
|
175
|
-
|
176
|
-
|
177
|
-
;;===================================================================
|
178
|
-
(test-end)
|
data/test/match-test.nnd
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
;;-*- mode: nendo; syntax: scheme -*-;;
|
2
|
-
;;
|
3
|
-
;; match-test.nnd - test suite for util.match
|
4
|
-
;;
|
5
|
-
;; This file ported from chibi-scheme 0.3 by Alex Shinn.
|
6
|
-
;;
|
7
|
-
|
8
|
-
(use nendo.test)
|
9
|
-
(use util.match)
|
10
|
-
;;(use util.match-expanded)
|
11
|
-
|
12
|
-
(test-start "match")
|
13
|
-
(test-section "match")
|
14
|
-
|
15
|
-
(define-syntax match-test*
|
16
|
-
(syntax-rules ()
|
17
|
-
((_ title code result)
|
18
|
-
(test* title result code))))
|
19
|
-
|
20
|
-
(define-syntax pending*
|
21
|
-
(syntax-rules ()
|
22
|
-
((_ title code result)
|
23
|
-
(printf "(pending) [%s]\n" title))))
|
24
|
-
|
25
|
-
|
26
|
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
27
|
-
;; run tests
|
28
|
-
(match-test* "any" (match 'any (_ 'ok)) 'ok)
|
29
|
-
(match-test* "symbol" (match 'ok (x x)) 'ok)
|
30
|
-
(match-test* "number" (match 28 (28 'ok)) 'ok)
|
31
|
-
(match-test* "string" (match "good" ("bad" 'fail) ("good" 'ok)) 'ok)
|
32
|
-
(match-test* "literal symbol" (match 'good ('bad 'fail) ('good 'ok)) 'ok)
|
33
|
-
(match-test* "null" (match '() (() 'ok)) 'ok)
|
34
|
-
(match-test* "pair" (match '(ok) ((x) x)) 'ok)
|
35
|
-
(match-test* "vector" (match '#(ok) (#(x) x)) 'ok)
|
36
|
-
(match-test* "any doubled" (match '(1 2) ((_ _) 'ok)) 'ok)
|
37
|
-
(match-test* "and empty" (match '(o k) ((and) 'ok)) 'ok)
|
38
|
-
(match-test* "and single" (match 'ok ((and x) x)) 'ok)
|
39
|
-
(match-test* "and double" (match 'ok ((and (? symbol?) y) 'ok)) 'ok)
|
40
|
-
(match-test* "or empty" (match '(o k) ((or) 'fail) (else 'ok)) 'ok)
|
41
|
-
(match-test* "or single" (match 'ok ((or x) 'ok)) 'ok)
|
42
|
-
(match-test* "or double" (match 'ok ((or (? symbol? y) y) y)) 'ok)
|
43
|
-
(match-test* "not" (match 28 ((not (a . b)) 'ok)) 'ok)
|
44
|
-
(match-test* "pred" (match 28 ((? number?) 'ok)) 'ok)
|
45
|
-
(match-test* "named pred" (match 28 ((? number? x) (+ x 1))) 29)
|
46
|
-
(match-test* "duplicate symbols pass" (match '(ok . ok) ((x . x) x)) 'ok)
|
47
|
-
(match-test* "duplicate symbols fail" (match '(ok . bad) ((x . x) 'bad) (else 'ok)) 'ok)
|
48
|
-
(match-test* "duplicate symbols samth" (match '(ok . ok) ((x . 'bad) x) (('ok . x) x)) 'ok)
|
49
|
-
|
50
|
-
(match-test* "ellipses"
|
51
|
-
(match '((a . 1) (b . 2) (c . 3))
|
52
|
-
(((x . y) ___) (list x y)))
|
53
|
-
'((a b c) (1 2 3)))
|
54
|
-
|
55
|
-
(match-test* "real ellipses"
|
56
|
-
(match '((a . 1) (b . 2) (c . 3))
|
57
|
-
(((x . y) ...) (list x y)))
|
58
|
-
'((a b c) (1 2 3)))
|
59
|
-
|
60
|
-
(match-test* "vector ellipses"
|
61
|
-
(match '#(1 2 3 (a . 1) (b . 2) (c . 3))
|
62
|
-
(#(a b c (hd . tl) ...) (list a b c hd tl)))
|
63
|
-
'(1 2 3 (a b c) (1 2 3)))
|
64
|
-
|
65
|
-
(match-test* "pred ellipses"
|
66
|
-
(match '(1 2 3)
|
67
|
-
(((? odd? n) ___) n)
|
68
|
-
(((? number? n) ___) n))
|
69
|
-
'(1 2 3))
|
70
|
-
|
71
|
-
(match-test* "failure continuation"
|
72
|
-
(match '(1 2)
|
73
|
-
((a . b) (=> next) (if (even? a) 'fail (next)))
|
74
|
-
((a . b) 'ok))
|
75
|
-
'ok)
|
76
|
-
|
77
|
-
(match-test* "let"
|
78
|
-
(match-let ((x 'ok) (y '(o k)))
|
79
|
-
y)
|
80
|
-
'(o k))
|
81
|
-
|
82
|
-
(match-test* "let*"
|
83
|
-
(match-let* ((x 'f) (y 'o) ((z w) (list y x)))
|
84
|
-
(list x y z w))
|
85
|
-
'(f o o f))
|
86
|
-
|
87
|
-
(match-test* "getter car"
|
88
|
-
(match '(1 . 2) (((get! a) . b) (list (a) b)))
|
89
|
-
'(1 2))
|
90
|
-
|
91
|
-
(match-test* "getter cdr"
|
92
|
-
(match '(1 . 2) ((a . (get! b)) (list a (b))))
|
93
|
-
'(1 2))
|
94
|
-
|
95
|
-
(match-test* "getter vector"
|
96
|
-
(match '#(1 2 3) (#((get! a) b c) (list (a) b c)))
|
97
|
-
'(1 2 3))
|
98
|
-
|
99
|
-
(match-test* "setter car"
|
100
|
-
(let ((x (cons 1 2)))
|
101
|
-
(match x (((set! a) . b) (a 3)))
|
102
|
-
x)
|
103
|
-
'(3 . 2))
|
104
|
-
|
105
|
-
(match-test* "setter cdr"
|
106
|
-
(let ((x (cons 1 2)))
|
107
|
-
(match x ((a . (set! b)) (b 3)))
|
108
|
-
x)
|
109
|
-
'(1 . 3))
|
110
|
-
|
111
|
-
(match-test* "setter vector"
|
112
|
-
(let ((x (vector 1 2 3)))
|
113
|
-
(match x (#(a (set! b) c) (b 0)))
|
114
|
-
x)
|
115
|
-
'#(1 0 3))
|
116
|
-
|
117
|
-
(match-test* "single tail"
|
118
|
-
(match '((a . 1) (b . 2) (c . 3))
|
119
|
-
(((x . y) ... last) (list x y last)))
|
120
|
-
'((a b) (1 2) (c . 3)))
|
121
|
-
|
122
|
-
(match-test* "single tail 2"
|
123
|
-
(match '((a . 1) (b . 2) 3)
|
124
|
-
(((x . y) ... last) (list x y last)))
|
125
|
-
'((a b) (1 2) 3))
|
126
|
-
|
127
|
-
(match-test* "multiple tail"
|
128
|
-
(match '((a . 1) (b . 2) (c . 3) (d . 4) (e . 5))
|
129
|
-
(((x . y) ... u v w) (list x y u v w)))
|
130
|
-
'((a b) (1 2) (c . 3) (d . 4) (e . 5)))
|
131
|
-
|
132
|
-
(match-test* "Riastradh quasiquote"
|
133
|
-
(match '(1 2 3) (`(1 ,b ,c) (list b c)))
|
134
|
-
'(2 3))
|
135
|
-
|
136
|
-
(match-test* "trivial tree search"
|
137
|
-
(match '(1 2 3) ((_ *** (a b c)) (list a b c)))
|
138
|
-
'(1 2 3))
|
139
|
-
|
140
|
-
(match-test* "simple tree search"
|
141
|
-
(match '(x (1 2 3)) ((_ *** (a b c)) (list a b c)))
|
142
|
-
'(1 2 3))
|
143
|
-
|
144
|
-
(match-test* "deep tree search"
|
145
|
-
(match '(x (x (x (1 2 3)))) ((_ *** (a b c)) (list a b c)))
|
146
|
-
'(1 2 3))
|
147
|
-
|
148
|
-
(match-test* "non-tail tree search"
|
149
|
-
(match '(x (x (x a b c (1 2 3) d e f))) ((_ *** (a b c)) (list a b c)))
|
150
|
-
'(1 2 3))
|
151
|
-
|
152
|
-
(match-test* "restricted tree search"
|
153
|
-
(match '(x (x (x a b c (1 2 3) d e f))) (('x *** (a b c)) (list a b c)))
|
154
|
-
'(1 2 3))
|
155
|
-
|
156
|
-
(match-test* "fail restricted tree search"
|
157
|
-
(match '(x (y (x a b c (1 2 3) d e f)))
|
158
|
-
(('x *** (a b c)) (list a b c))
|
159
|
-
(else #f))
|
160
|
-
#f)
|
161
|
-
|
162
|
-
;; /home2/home/kiyoka/work/github/nendo/lib/nendo.rb:2317: stack level too deep (SystemStackError)
|
163
|
-
(match-test* "sxml tree search"
|
164
|
-
(match '(p (ul (li a (b c) (a (^ (href . "http://synthcode.com/")) "synthcode") d e f)))
|
165
|
-
(((or 'p 'ul 'li 'b) *** ('a ('^ attrs ...) text ...))
|
166
|
-
(list attrs text))
|
167
|
-
(else #f))
|
168
|
-
'(((href . "http://synthcode.com/")) ("synthcode")))
|
169
|
-
|
170
|
-
;; /home2/home/kiyoka/work/github/nendo/lib/nendo.rb:2317: stack level too deep (SystemStackError)
|
171
|
-
(match-test* "failed sxml tree search"
|
172
|
-
(match '(p (ol (li a (b c) (a (^ (href . "http://synthcode.com/")) "synthcode") d e f)))
|
173
|
-
(((or 'p 'ul 'li 'b) *** ('a ('^ attrs ...) text ...))
|
174
|
-
(list attrs text))
|
175
|
-
(else #f))
|
176
|
-
#f)
|
177
|
-
|
178
|
-
;; ./test/match-test.nnd:192: Error: undefined variable _tag (NameError)
|
179
|
-
(match-test* "collect tree search"
|
180
|
-
(match '(p (ul (li a (b c) (a (^ (href . "http://synthcode.com/")) "synthcode") d e f)))
|
181
|
-
(((and tag (or 'p 'ul 'li 'b)) *** ('a ('^ attrs ...) text ...))
|
182
|
-
(list tag attrs text))
|
183
|
-
(else #f))
|
184
|
-
'((p ul li) ((href . "http://synthcode.com/")) ("synthcode")))
|
185
|
-
|
186
|
-
(test-end)
|