nendo 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/test/nendo_spec.rb
DELETED
@@ -1,551 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- encoding: utf-8 -*-
|
3
|
-
#
|
4
|
-
# nendo_spec.rb - "RSpec file for nendo language"
|
5
|
-
#
|
6
|
-
# Copyright (c) 2009-2011 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
|
-
describe Nendo, "Ruby version " do
|
39
|
-
it "should" do
|
40
|
-
RUBY_VERSION.match( /^1[.]8/ ).should_not be_true
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe Cell, "when initialized as '()" do
|
45
|
-
before do
|
46
|
-
@cell = Cell.new
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should" do
|
50
|
-
@cell.isNull.should be_true
|
51
|
-
@cell.length.should == 0
|
52
|
-
@cell.size.should == 0
|
53
|
-
@cell.to_arr.should == []
|
54
|
-
@cell.class.should == Cell
|
55
|
-
@cell.map{ |x| x }.should == []
|
56
|
-
@cell.lastAtom.should be_false
|
57
|
-
@cell.getLastAtom.class.should == Nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe Cell, "when initialized as '(100)" do
|
62
|
-
before do
|
63
|
-
@cell = Cell.new( 100 )
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should" do
|
67
|
-
@cell.isNull.should_not be_true
|
68
|
-
@cell.length.should == 1
|
69
|
-
@cell.size.should == 1
|
70
|
-
@cell.car.should == 100
|
71
|
-
@cell.cdr.class.should == Nil
|
72
|
-
@cell.to_arr.should == [ 100 ]
|
73
|
-
@cell.lastCell.car.should == 100
|
74
|
-
@cell.lastCell.cdr.class.should == Nil
|
75
|
-
@cell.lastAtom.should be_false
|
76
|
-
@cell.getLastAtom.class.should == Nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe Cell, "when initialized as '(100 . 200)" do
|
81
|
-
before do
|
82
|
-
@cell = Cell.new( 100, 200 )
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should" do
|
86
|
-
@cell.isNull.should_not be_true
|
87
|
-
@cell.isDotted.should be_true
|
88
|
-
@cell.length.should == 1
|
89
|
-
@cell.size.should == 1
|
90
|
-
@cell.car.should == 100
|
91
|
-
@cell.cdr.should == 200
|
92
|
-
@cell.to_arr.should == [ 100 ]
|
93
|
-
@cell.lastCell.car.should == 100
|
94
|
-
@cell.lastCell.cdr.should == 200
|
95
|
-
@cell.lastAtom.should be_true
|
96
|
-
@cell.getLastAtom.should == 200
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe Cell, "when initialized as '(cons 100 (cons 200 300)) " do
|
101
|
-
before do
|
102
|
-
@cell = Cell.new( 100, Cell.new( 200, 300 ))
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should" do
|
106
|
-
@cell.isNull.should_not be_true
|
107
|
-
@cell.isDotted.should_not be_true
|
108
|
-
@cell.length.should == 2
|
109
|
-
@cell.size.should == 2
|
110
|
-
@cell.car.should == 100
|
111
|
-
@cell.cdr.car.should == 200
|
112
|
-
@cell.cdr.cdr.should == 300
|
113
|
-
@cell.to_arr.should == [ 100, 200 ]
|
114
|
-
@cell.lastCell.car.should == 200
|
115
|
-
@cell.lastCell.cdr.should == 300
|
116
|
-
@cell.lastAtom.should be_true
|
117
|
-
@cell.getLastAtom.should == 300
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe Nendo, "Ruby's arity rules " do
|
122
|
-
it "should" do
|
123
|
-
Proc.new {}.arity.should <= 0
|
124
|
-
Proc.new {||}.arity.should == 0
|
125
|
-
Proc.new {|a|}.arity.should == 1
|
126
|
-
Proc.new {|a,b|}.arity.should == 2
|
127
|
-
Proc.new {|a,b,c|}.arity.should == 3
|
128
|
-
Proc.new {|*a|}.arity.should == -1
|
129
|
-
Proc.new {|a,*b|}.arity.should == -2
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe Nendo, "Ruby's lexical closure " do
|
134
|
-
it "should" do
|
135
|
-
lambda1 = lambda { |val|
|
136
|
-
val = 'a'
|
137
|
-
lambda2 = lambda { |val| val }
|
138
|
-
lambda2.call( 'X' )
|
139
|
-
val
|
140
|
-
}
|
141
|
-
lambda1.call( 'A' ).should == 'a'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe Nendo, "Japanese characters in regex " do
|
146
|
-
before do
|
147
|
-
@matchData = "ABC漢字あいうえお漢字ABC".match( /([あ-ん])([あ-ん])([あ-ん])([あ-ん])([あ-ん])/ )
|
148
|
-
end
|
149
|
-
it "should" do
|
150
|
-
@matchData.should be_true
|
151
|
-
@matchData[0].should == "あいうえお"
|
152
|
-
@matchData[1].should == "あ"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
describe Nendo, "Ruby's undefined instance variable " do
|
158
|
-
it "should" do
|
159
|
-
@undefined_variable.should be_nil
|
160
|
-
defined?( @undefined_variable ).should be_nil
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe Evaluator, "When use Evaluator's util methods" do
|
165
|
-
before do
|
166
|
-
@evaluator = Evaluator.new(Nendo::Core.new())
|
167
|
-
end
|
168
|
-
it "should" do
|
169
|
-
@evaluator.toRubySymbol( "a" ).should == "_a"
|
170
|
-
@evaluator.toRubySymbol( "a_b_c" ).should == "_a_b_c"
|
171
|
-
@evaluator.toRubySymbol( "_a_b_c_" ).should == "__a_b_c_"
|
172
|
-
@evaluator.toRubySymbol( '!' ).should == '__EXMARK'
|
173
|
-
@evaluator.toRubySymbol( '$' ).should == '__DOMARK'
|
174
|
-
@evaluator.toRubySymbol( '%' ).should == '__PAMARK'
|
175
|
-
@evaluator.toRubySymbol( '&' ).should == '__ANMARK'
|
176
|
-
@evaluator.toRubySymbol( '*' ).should == '__ASMARK'
|
177
|
-
@evaluator.toRubySymbol( '+' ).should == '__PLMARK'
|
178
|
-
@evaluator.toRubySymbol( '-' ).should == '__MIMARK'
|
179
|
-
@evaluator.toRubySymbol( '/' ).should == '__SLMARK'
|
180
|
-
@evaluator.toRubySymbol( ':' ).should == '__COMARK'
|
181
|
-
@evaluator.toRubySymbol( '::' ).should == '_::'
|
182
|
-
@evaluator.toRubySymbol( '<' ).should == '__LTMARK'
|
183
|
-
@evaluator.toRubySymbol( '=' ).should == '__EQMARK'
|
184
|
-
@evaluator.toRubySymbol( '>' ).should == '__GTMARK'
|
185
|
-
@evaluator.toRubySymbol( '?' ).should == '__QUMARK'
|
186
|
-
@evaluator.toRubySymbol( '@' ).should == '__ATMARK'
|
187
|
-
@evaluator.toRubySymbol( '^' ).should == '__NKMARK'
|
188
|
-
@evaluator.toRubySymbol( "_" ).should == "__"
|
189
|
-
@evaluator.toRubySymbol( '~' ).should == '__CHMARK'
|
190
|
-
@evaluator.toRubySymbol( '...' ).should == '__DOTDOTDOT'
|
191
|
-
@evaluator.toRubySymbol( '<...>' ).should == '__LTMARK_DOTDOTDOT_GTMARK'
|
192
|
-
@evaluator.toRubySymbol( "a?" ).should == "_a_QUMARK"
|
193
|
-
@evaluator.toRubySymbol( "a?" ).should == "_a_QUMARK"
|
194
|
-
@evaluator.toRubySymbol( "a!" ).should == "_a_EXMARK"
|
195
|
-
@evaluator.toRubySymbol( "a?b" ).should == "_a_QUMARKb"
|
196
|
-
@evaluator.toRubySymbol( "a!b" ).should == "_a_EXMARKb"
|
197
|
-
@evaluator.toRubySymbol( "a-b" ).should == "_a_MIMARKb"
|
198
|
-
@evaluator.toRubySymbol( "a-b-c" ).should == "_a_MIMARKb_MIMARKc"
|
199
|
-
@evaluator.toRubySymbol( "-a-b-c" ).should == "__MIMARKa_MIMARKb_MIMARKc"
|
200
|
-
@evaluator.toRubySymbol( "-a-!-b" ).should == "__MIMARKa_MIMARK_EXMARK_MIMARKb"
|
201
|
-
@evaluator.toRubySymbol( "-a-!-?b" ).should == "__MIMARKa_MIMARK_EXMARK_MIMARK_QUMARKb"
|
202
|
-
@evaluator.toRubySymbol( "a.b" ).should == "_a.b"
|
203
|
-
@evaluator.toRubySymbol( "aa.bb" ).should == "_aa.bb"
|
204
|
-
@evaluator.toRubySymbol( "aa.bb.cc" ).should == "_aa.bb.cc"
|
205
|
-
@evaluator.toLispSymbol( "_a_QUMARK" ).should == "a?"
|
206
|
-
@evaluator.toLispSymbol( "_a_EXMARK" ).should == "a!"
|
207
|
-
@evaluator.toLispSymbol( "_a_b" ).should == "a_b"
|
208
|
-
@evaluator.toLispSymbol( "_a_b_c" ).should == "a_b_c"
|
209
|
-
@evaluator.toLispSymbol( "_A_B_C" ).should == "A_B_C"
|
210
|
-
@evaluator.toLispSymbol( "__DOTDOTDOT" ).should == "..."
|
211
|
-
@evaluator.toLispSymbol( "__LTMARK_DOTDOTDOT_GTMARK" ).should == "<...>"
|
212
|
-
@evaluator.toRubyValue( "a" ).should == "a"
|
213
|
-
@evaluator.toRubyValue( "b" ).should == "b"
|
214
|
-
@evaluator.toRubyValue( "true" ).should == "true"
|
215
|
-
@evaluator.toRubyValue( "nil" ).should == "nil"
|
216
|
-
@evaluator.toRubyValue( "false" ).should == "false"
|
217
|
-
@evaluator.toRubyValue( :a ).should == "a"
|
218
|
-
@evaluator.toRubyValue( :b ).should == "b"
|
219
|
-
@evaluator.toRubyValue( true ).should == "true"
|
220
|
-
@evaluator.toRubyValue( nil ).should == "nil"
|
221
|
-
@evaluator.toRubyValue( false ).should == "false"
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
describe Nendo, "when call evalStr() with literals" do
|
226
|
-
before do
|
227
|
-
@nendo = Nendo::Core.new()
|
228
|
-
end
|
229
|
-
it "should" do
|
230
|
-
@nendo.evalStr( " 1 " ).should == "1"
|
231
|
-
@nendo.evalStr( " 100000 " ).should == "100000"
|
232
|
-
@nendo.evalStr( " 1.1 " ).should == "1.1"
|
233
|
-
@nendo.evalStr( " 1.0 " ).should == "1.0"
|
234
|
-
@nendo.evalStr( ' "a" ' ).should == '"a"'
|
235
|
-
@nendo.evalStr( ' "\n" ' ).should == "\"\n\""
|
236
|
-
@nendo.evalStr( ' "\r" ' ).should == "\"\\r\""
|
237
|
-
@nendo.evalStr( ' "\t" ' ).should == "\"\\t\""
|
238
|
-
@nendo.evalStr( ' "a" ' ).should == '"a"'
|
239
|
-
@nendo.evalStr( ' "a\"b" ' ).should == '"a\"b"'
|
240
|
-
@nendo.evalStr( " true " ).should == "#t"
|
241
|
-
@nendo.evalStr( " false " ).should == "#f"
|
242
|
-
@nendo.evalStr( " nil " ).should == "nil"
|
243
|
-
@nendo.evalStr( " #t " ).should == "#t"
|
244
|
-
@nendo.evalStr( " #f " ).should == "#f"
|
245
|
-
pending( "JRuby can't compute correctly" ) if defined? JRUBY_VERSION
|
246
|
-
@nendo.evalStr( ' "日本語" ' ).should == '"日本語"'
|
247
|
-
@nendo.evalStr( ' "日\"本\"語" ' ).should == '"日\"本\"語"'
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
describe Nendo, "when call evalStr() with comparative operators" do
|
252
|
-
before do
|
253
|
-
@nendo = Nendo::Core.new()
|
254
|
-
end
|
255
|
-
it "should" do
|
256
|
-
@nendo.evalStr( " (= 1 1) " ).should == "#t"
|
257
|
-
@nendo.evalStr( " (= 1 2) " ).should == "#f"
|
258
|
-
@nendo.evalStr( " (= #t #t) " ).should == "#t"
|
259
|
-
@nendo.evalStr( " (= #f #f) " ).should == "#t"
|
260
|
-
@nendo.evalStr( " (= true true) " ).should == "#t"
|
261
|
-
@nendo.evalStr( " (= false false) " ).should == "#t"
|
262
|
-
@nendo.evalStr( " (= #t true) " ).should == "#t"
|
263
|
-
@nendo.evalStr( " (= #f false) " ).should == "#t"
|
264
|
-
@nendo.evalStr( " (= #t #f) " ).should == "#f"
|
265
|
-
@nendo.evalStr( " (= true false) " ).should == "#f"
|
266
|
-
@nendo.evalStr( " (eq? 1 1) " ).should == "#t"
|
267
|
-
@nendo.evalStr( " (eq? 1 2) " ).should == "#f"
|
268
|
-
@nendo.evalStr( " (eq? 'a 'a) " ).should == "#t"
|
269
|
-
@nendo.evalStr( " (eq? 'b 'b) " ).should == "#t"
|
270
|
-
@nendo.evalStr( " (eq? 'a-b 'a-b) " ).should == "#t"
|
271
|
-
@nendo.evalStr( " (eq? 'a_b 'a-b) " ).should == "#f"
|
272
|
-
@nendo.evalStr( " (eq? 'a-b 'a_b) " ).should == "#f"
|
273
|
-
@nendo.evalStr( " (eq? 'a-b (intern \"a-b\")) " ).should == "#t"
|
274
|
-
@nendo.evalStr( " (eq? 'a_b (intern \"a-b\")) " ).should == "#f"
|
275
|
-
@nendo.evalStr( " (eq? 'a-b (intern \"a_b\")) " ).should == "#f"
|
276
|
-
@nendo.evalStr( " (= 1 1) " ).should == "#t"
|
277
|
-
@nendo.evalStr( " (= 1 2) " ).should == "#f"
|
278
|
-
@nendo.evalStr( " (= 'a 'a) " ).should == "#t"
|
279
|
-
@nendo.evalStr( " (= 'b 'b) " ).should == "#t"
|
280
|
-
@nendo.evalStr( " (= 'a-b 'a-b) " ).should == "#t"
|
281
|
-
@nendo.evalStr( " (= 'a_b 'a-b) " ).should == "#f"
|
282
|
-
@nendo.evalStr( " (= 'a-b 'a_b) " ).should == "#f"
|
283
|
-
@nendo.evalStr( " (= 'a-b (intern \"a-b\")) " ).should == "#t"
|
284
|
-
@nendo.evalStr( " (= 'a_b (intern \"a-b\")) " ).should == "#f"
|
285
|
-
@nendo.evalStr( " (= 'a-b (intern \"a_b\")) " ).should == "#f"
|
286
|
-
@nendo.evalStr( " (< 1 1) " ).should == "#f"
|
287
|
-
@nendo.evalStr( " (< 1 2) " ).should == "#t"
|
288
|
-
@nendo.evalStr( " (> 1 1) " ).should == "#f"
|
289
|
-
@nendo.evalStr( " (> 2 1) " ).should == "#t"
|
290
|
-
@nendo.evalStr( " (<= 1 0) " ).should == "#f"
|
291
|
-
@nendo.evalStr( " (<= 1 1) " ).should == "#t"
|
292
|
-
@nendo.evalStr( " (<= 1 2) " ).should == "#t"
|
293
|
-
@nendo.evalStr( " (>= 0 1) " ).should == "#f"
|
294
|
-
@nendo.evalStr( " (>= 1 1) " ).should == "#t"
|
295
|
-
@nendo.evalStr( " (equal? 1 1) " ).should == "#t"
|
296
|
-
@nendo.evalStr( " (equal? 1 2) " ).should == "#f"
|
297
|
-
@nendo.evalStr( " (equal? 2 2) " ).should == "#t"
|
298
|
-
@nendo.evalStr( " (equal? '() '()) " ).should == "#t"
|
299
|
-
@nendo.evalStr( " (equal? '(1) '(1)) " ).should == "#t"
|
300
|
-
@nendo.evalStr( " (equal? '(1) '(2)) " ).should == "#f"
|
301
|
-
@nendo.evalStr( " (equal? '(1 2 3) '(1 2 3)) " ).should == "#t"
|
302
|
-
@nendo.evalStr( " (equal? '(1 2 . 3) '(1 2 . 3)) " ).should == "#t"
|
303
|
-
@nendo.evalStr( " (equal? '(1 2 (3)) '(1 2 (3))) " ).should == "#t"
|
304
|
-
@nendo.evalStr( " (equal? '(1 2 (3)) '(1 2 (4))) " ).should == "#f"
|
305
|
-
@nendo.evalStr( " (equal? '(1 2 (3 (4))) '(1 2 (3 (4)))) " ).should == "#t"
|
306
|
-
@nendo.evalStr( " (equal? '((1) 2 3 4) '((2) 2 3 4)) " ).should == "#f"
|
307
|
-
@nendo.evalStr( " (equal? \"aaa\" \"aaa\") " ).should == "#t"
|
308
|
-
@nendo.evalStr( " (equal? \"aaa\" \"aax\") " ).should == "#f"
|
309
|
-
@nendo.evalStr( " (equal? '(\"aaa\") '(\"aaa\")) " ).should == "#t"
|
310
|
-
@nendo.evalStr( " (equal? '(\"aaa\" (1)) '(\"aaa\" (1))) " ).should == "#t"
|
311
|
-
@nendo.evalStr( " (equal? '(\"aaa\" (1)) '(\"aaa\" (2))) " ).should == "#f"
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
describe Nendo, "when reference global-variables." do
|
316
|
-
before do
|
317
|
-
@nendo = Nendo::Core.new()
|
318
|
-
end
|
319
|
-
it "should" do
|
320
|
-
@nendo.evalStr( " (pair? *load-path*) " ).should == "#t"
|
321
|
-
@nendo.evalStr( " (string? (car *load-path*)) " ).should == "#t"
|
322
|
-
# @nendo.evalStr( " (to-arr *load-path*) " ).should include( "./spec")
|
323
|
-
@nendo.evalStr( " (to-arr *load-path*) " ).should include( "./lib")
|
324
|
-
@nendo.evalStr( " (string? (*FILE*)) " ).should == "#t"
|
325
|
-
@nendo.evalStr( " (number? (*LINE*)) " ).should == "#t"
|
326
|
-
@nendo.evalStr( " *nendo-version* " ).should == '"' + Nendo::Core.version + '"'
|
327
|
-
@nendo.evalStr( " (string? *nendo-version*) " ).should == "#t"
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
describe Nendo, "when call evalStr() with boolean operators" do
|
332
|
-
before do
|
333
|
-
@nendo = Nendo::Core.new()
|
334
|
-
end
|
335
|
-
it "should" do
|
336
|
-
@nendo.evalStr( " true " ).should == "#t"
|
337
|
-
@nendo.evalStr( " false " ).should == "#f"
|
338
|
-
@nendo.evalStr( " #t " ).should == "#t"
|
339
|
-
@nendo.evalStr( " #f " ).should == "#f"
|
340
|
-
@nendo.evalStr( " (not true) " ).should == "#f"
|
341
|
-
@nendo.evalStr( " (not #t) " ).should == "#f"
|
342
|
-
@nendo.evalStr( " (not 1) " ).should == "#f"
|
343
|
-
@nendo.evalStr( " (not false) " ).should == "#t"
|
344
|
-
@nendo.evalStr( " (not #f) " ).should == "#t"
|
345
|
-
@nendo.evalStr( " (not \"str\") " ).should == "#f"
|
346
|
-
@nendo.evalStr( " (not not) " ).should == "#f"
|
347
|
-
@nendo.evalStr( " (not (not true)) " ).should == "#t"
|
348
|
-
@nendo.evalStr( " (not (not #t)) " ).should == "#t"
|
349
|
-
@nendo.evalStr( " (not '()) " ).should == "#f"
|
350
|
-
@nendo.evalStr( " (not '(1)) " ).should == "#f"
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
describe Nendo, "when call evalStr() with `+' function" do
|
355
|
-
before do
|
356
|
-
@nendo = Nendo::Core.new()
|
357
|
-
@nendo.setDisplayErrors( false )
|
358
|
-
end
|
359
|
-
it "should" do
|
360
|
-
@nendo.evalStr( " (+ 1) " ).should == "1"
|
361
|
-
@nendo.evalStr( " (+ 1 1) " ).should == "2"
|
362
|
-
@nendo.evalStr( " (+ 1 1 1 1 1 1 1 1 1 1) " ).should == "10"
|
363
|
-
@nendo.evalStr( " (+ 1 2 3 4 5) " ).should == "15"
|
364
|
-
@nendo.evalStr( " (+ 1 (+ 2 (+ 3 (+ 4 (+ 5))))) " ).should == "15"
|
365
|
-
@nendo.evalStr( " (+ 1 1.1) " ).should == "2.1"
|
366
|
-
@nendo.evalStr( " (+ 1.1 1.2) " ).should == "2.3"
|
367
|
-
@nendo.evalStr( " (+ \"a\" ) " ).should == '"a"'
|
368
|
-
@nendo.evalStr( " (+ \"a\" \"B\" \"c\" ) " ).should == '"aBc"'
|
369
|
-
@nendo.evalStr( " (+) " ).should == "0"
|
370
|
-
lambda { @nendo.evalStr( " (+ 1 '() ) " ) }.should raise_error(TypeError)
|
371
|
-
lambda { @nendo.evalStr( " (+ 1.1 '() ) " ) }.should raise_error(TypeError)
|
372
|
-
lambda { @nendo.evalStr( " (+ 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
373
|
-
lambda { @nendo.evalStr( " (+ \"a\" 1) " ) }.should raise_error(TypeError)
|
374
|
-
lambda { @nendo.evalStr( " (+ \"a\" 1.1) " ) }.should raise_error(TypeError)
|
375
|
-
# pending( "Optimized `+' function does not raise TypeError" )
|
376
|
-
# lambda { @nendo.evalStr( " (+ '() ) " ) }.should raise_error(TypeError)
|
377
|
-
# lambda { @nendo.evalStr( " (+ '(1) ) " ) }.should raise_error(TypeError)
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
|
-
describe Nendo, "when call evalStr() with `-' function" do
|
382
|
-
before do
|
383
|
-
@nendo = Nendo::Core.new()
|
384
|
-
@nendo.setDisplayErrors( false )
|
385
|
-
end
|
386
|
-
it "should" do
|
387
|
-
@nendo.evalStr( " (- 1) " ).should == "-1"
|
388
|
-
@nendo.evalStr( " (- 2 1) " ).should == "1"
|
389
|
-
@nendo.evalStr( " (- 2 5) " ).should == "-3"
|
390
|
-
@nendo.evalStr( " (- 100 1 1 1 1 1 1 1 1 1 1) " ).should == "90"
|
391
|
-
@nendo.evalStr( " (- 100 (- 10 3)) " ).should == "93"
|
392
|
-
@nendo.evalStr( " (- 1.1 1) " ).should == (1.1-1).to_s
|
393
|
-
@nendo.evalStr( " (- 1.3 1.1) " ).should == (1.3-1.1).to_s
|
394
|
-
@nendo.evalStr( " (-) " ).should == "0"
|
395
|
-
lambda { @nendo.evalStr( " (- 1 '() ) " ) }.should raise_error(TypeError)
|
396
|
-
lambda { @nendo.evalStr( " (- 1.1 '() ) " ) }.should raise_error(TypeError)
|
397
|
-
lambda { @nendo.evalStr( " (- 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
398
|
-
# pending( "Optimized `-' function does not raise TypeError" )
|
399
|
-
# lambda { @nendo.evalStr( " (- '(1) ) " ) }.should raise_error(TypeError)
|
400
|
-
# lambda { @nendo.evalStr( " (- '() ) " ) }.should raise_error(TypeError)
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
describe Nendo, "when call evalStr() with `*' function" do
|
405
|
-
before do
|
406
|
-
@nendo = Nendo::Core.new()
|
407
|
-
@nendo.setDisplayErrors( false )
|
408
|
-
end
|
409
|
-
it "should" do
|
410
|
-
@nendo.evalStr( " (* 1) " ).should == "1"
|
411
|
-
@nendo.evalStr( " (* 2 1) " ).should == "2"
|
412
|
-
@nendo.evalStr( " (* 2 5) " ).should == "10"
|
413
|
-
@nendo.evalStr( " (* 1 2 3 4 5 6 7 8 9 10) " ).should == "3628800"
|
414
|
-
@nendo.evalStr( " (* 100 (* 10 10 10)) " ).should == "100000"
|
415
|
-
@nendo.evalStr( " (* 1.1 1) " ).should == "1.1"
|
416
|
-
@nendo.evalStr( " (* 1.3 1.1) " ).should == (1.3*1.1).to_s
|
417
|
-
@nendo.evalStr( " (*) " ).should == "1"
|
418
|
-
# pending( "Optimized `*' function does not raise TypeError" )
|
419
|
-
# lambda { @nendo.evalStr( " (* \"a\" 1) " ) }.should raise_error(TypeError)
|
420
|
-
# lambda { @nendo.evalStr( " (* \"a\" 1.1) " ) }.should raise_error(TypeError)
|
421
|
-
# lambda { @nendo.evalStr( " (* 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
422
|
-
# lambda { @nendo.evalStr( " (* '() ) " ) }.should raise_error(TypeError)
|
423
|
-
# lambda { @nendo.evalStr( " (* '(1) ) " ) }.should raise_error(TypeError)
|
424
|
-
# lambda { @nendo.evalStr( " (* 1 '() ) " ) }.should raise_error(TypeError)
|
425
|
-
# lambda { @nendo.evalStr( " (* 1.1 '() ) " ) }.should raise_error(TypeError)
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
describe Nendo, "when call evalStr() with `/' function" do
|
430
|
-
before do
|
431
|
-
@nendo = Nendo::Core.new()
|
432
|
-
@nendo.setDisplayErrors( false )
|
433
|
-
end
|
434
|
-
it "should" do
|
435
|
-
@nendo.evalStr( " (/ 1) " ).should == "1"
|
436
|
-
@nendo.evalStr( " (/ 1.1) " ).should ==
|
437
|
-
(1/1.1).to_s
|
438
|
-
@nendo.evalStr( " (/ 2 1) " ).should == "2"
|
439
|
-
@nendo.evalStr( " (/ 2 2) " ).should == "1"
|
440
|
-
@nendo.evalStr( " (/ 2 2.0) " ).should == "1.0"
|
441
|
-
@nendo.evalStr( " (/ 2 5.0) " ).should == "0.4"
|
442
|
-
@nendo.evalStr( " (/ 10.0 2 2 2 2 2 2 2 2 2 2) " ).should == "0.009765625"
|
443
|
-
@nendo.evalStr( " (/ 100 (/ 100 10) 10) " ).should == "1"
|
444
|
-
@nendo.evalStr( " (/ 1 1.11) " ).should ==
|
445
|
-
(1/1.11).to_s
|
446
|
-
@nendo.evalStr( " (/ 1.3 1.1) " ).should ==
|
447
|
-
(1.3/1.1).to_s
|
448
|
-
lambda { @nendo.evalStr( " (/ 1 '() ) " ) }.should raise_error(TypeError)
|
449
|
-
lambda { @nendo.evalStr( " (/ 1.1 '() ) " ) }.should raise_error(TypeError)
|
450
|
-
lambda { @nendo.evalStr( " (/) " ) }.should raise_error(ArgumentError)
|
451
|
-
lambda { @nendo.evalStr( " (/ '() ) " ) }.should raise_error(TypeError)
|
452
|
-
lambda { @nendo.evalStr( " (/ 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
describe Nendo, "when call evalStr() with `%' function" do
|
457
|
-
before do
|
458
|
-
@nendo = Nendo::Core.new()
|
459
|
-
@nendo.setDisplayErrors( false )
|
460
|
-
end
|
461
|
-
it "should" do
|
462
|
-
@nendo.evalStr( " (% 1) " ).should == "0"
|
463
|
-
@nendo.evalStr( " (% 1.1) " ).should == "1.0"
|
464
|
-
@nendo.evalStr( " (% 2 1) " ).should == "0"
|
465
|
-
@nendo.evalStr( " (% 2 2) " ).should == "0"
|
466
|
-
@nendo.evalStr( " (% 2 2.0) " ).should == "0.0"
|
467
|
-
@nendo.evalStr( " (% 2 5.0) " ).should == "2.0"
|
468
|
-
@nendo.evalStr( " (% 100 (% 103 10)) " ).should == "1"
|
469
|
-
@nendo.evalStr( " (% 1 1.11) " ).should == "1.0"
|
470
|
-
@nendo.evalStr( " (% 1.3 1.1) " ).should == (1.3%1.1).to_s
|
471
|
-
lambda { @nendo.evalStr( " (% 1 '() ) " ) }.should raise_error(TypeError)
|
472
|
-
lambda { @nendo.evalStr( " (% 1.1 '() ) " ) }.should raise_error(TypeError)
|
473
|
-
lambda { @nendo.evalStr( " (\%) " ) }.should raise_error(ArgumentError)
|
474
|
-
lambda { @nendo.evalStr( " (\% '() ) " ) }.should raise_error(TypeError)
|
475
|
-
lambda { @nendo.evalStr( " (\% 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
describe Nendo, "when call evalStr() with `quotient' function" do
|
480
|
-
before do
|
481
|
-
@nendo = Nendo::Core.new()
|
482
|
-
@nendo.setDisplayErrors( false )
|
483
|
-
end
|
484
|
-
it "should" do
|
485
|
-
@nendo.evalStr( " (quotient 2 1) " ).should == "2"
|
486
|
-
@nendo.evalStr( " (quotient 2 2) " ).should == "1"
|
487
|
-
@nendo.evalStr( " (quotient 2 2.0) " ).should == "1"
|
488
|
-
@nendo.evalStr( " (quotient 2 5.0) " ).should == "0"
|
489
|
-
@nendo.evalStr( " (quotient 1 1.11) " ).should == "0"
|
490
|
-
@nendo.evalStr( " (quotient 10 3) " ).should == "3"
|
491
|
-
@nendo.evalStr( " (quotient -10 3) " ).should == "-3"
|
492
|
-
@nendo.evalStr( " (quotient 10 -3) " ).should == "-3"
|
493
|
-
@nendo.evalStr( " (quotient 10 -2) " ).should == "-5"
|
494
|
-
lambda { @nendo.evalStr( " (quotient 1 ) " ) }.should raise_error(ArgumentError)
|
495
|
-
lambda { @nendo.evalStr( " (quotient 1.1 ) " ) }.should raise_error(ArgumentError)
|
496
|
-
lambda { @nendo.evalStr( " (quotient) " ) }.should raise_error(ArgumentError)
|
497
|
-
lambda { @nendo.evalStr( " (quotient '() ) " ) }.should raise_error(ArgumentError)
|
498
|
-
lambda { @nendo.evalStr( " (quotient 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
499
|
-
lambda { @nendo.evalStr( " (quotient \"a\" 1.1 ) " ) }.should raise_error(TypeError)
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
describe Nendo, "when call evalStr() with `remainder' function" do
|
504
|
-
before do
|
505
|
-
@nendo = Nendo::Core.new()
|
506
|
-
@nendo.setDisplayErrors( false )
|
507
|
-
end
|
508
|
-
it "should" do
|
509
|
-
@nendo.evalStr( " (remainder 2 1) " ).should == "0"
|
510
|
-
@nendo.evalStr( " (remainder 2 2) " ).should == "0"
|
511
|
-
@nendo.evalStr( " (remainder 2 2.0) " ).should == "0.0"
|
512
|
-
@nendo.evalStr( " (remainder 2 5.0) " ).should == "2.0"
|
513
|
-
@nendo.evalStr( " (remainder 1 1.11) " ).should == "1.0"
|
514
|
-
@nendo.evalStr( " (remainder 10 3) " ).should == "1"
|
515
|
-
@nendo.evalStr( " (remainder -10 3) " ).should == "-1"
|
516
|
-
@nendo.evalStr( " (remainder 10 -3) " ).should == "1"
|
517
|
-
@nendo.evalStr( " (remainder -10 -3) " ).should == "-1"
|
518
|
-
@nendo.evalStr( " (remainder 10 -2) " ).should == "0"
|
519
|
-
lambda { @nendo.evalStr( " (remainder 1 '() ) " ) }.should raise_error(TypeError)
|
520
|
-
lambda { @nendo.evalStr( " (remainder 1.1 '() ) " ) }.should raise_error(TypeError)
|
521
|
-
lambda { @nendo.evalStr( " (remainder) " ) }.should raise_error(ArgumentError)
|
522
|
-
lambda { @nendo.evalStr( " (remainder '() ) " ) }.should raise_error(ArgumentError)
|
523
|
-
lambda { @nendo.evalStr( " (remainder 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
524
|
-
end
|
525
|
-
end
|
526
|
-
|
527
|
-
describe Nendo, "when call evalStr() with `modulo' function" do
|
528
|
-
before do
|
529
|
-
@nendo = Nendo::Core.new()
|
530
|
-
@nendo.setDisplayErrors( false )
|
531
|
-
end
|
532
|
-
it "should" do
|
533
|
-
@nendo.evalStr( " (modulo 2 1) " ).should == "0"
|
534
|
-
@nendo.evalStr( " (modulo 2 2) " ).should == "0"
|
535
|
-
@nendo.evalStr( " (modulo 2 2.0) " ).should == "0.0"
|
536
|
-
@nendo.evalStr( " (modulo 2 5.0) " ).should == "2.0"
|
537
|
-
@nendo.evalStr( " (modulo 100 (modulo 103 10)) " ).should == "1"
|
538
|
-
@nendo.evalStr( " (modulo 1 1.11) " ).should == "1.0"
|
539
|
-
@nendo.evalStr( " (modulo 10 3) " ).should == "1"
|
540
|
-
@nendo.evalStr( " (modulo -10 3) " ).should == "2"
|
541
|
-
@nendo.evalStr( " (modulo 10 -3) " ).should == "-2"
|
542
|
-
@nendo.evalStr( " (modulo -10 -3) " ).should == "-1"
|
543
|
-
@nendo.evalStr( " (modulo 10 -2) " ).should == "0"
|
544
|
-
lambda { @nendo.evalStr( " (modulo 1 '() ) " ) }.should raise_error(TypeError)
|
545
|
-
lambda { @nendo.evalStr( " (modulo 1.1 '() ) " ) }.should raise_error(TypeError)
|
546
|
-
lambda { @nendo.evalStr( " (modulo) " ) }.should raise_error(ArgumentError)
|
547
|
-
lambda { @nendo.evalStr( " (modulo '() ) " ) }.should raise_error(TypeError)
|
548
|
-
lambda { @nendo.evalStr( " (modulo 1.1 \"a\" ) " ) }.should raise_error(TypeError)
|
549
|
-
end
|
550
|
-
end
|
551
|
-
|