nendo 0.3.4 → 0.3.5

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.
data/lib/text/tree.nndc CHANGED
@@ -4,16 +4,17 @@
4
4
  #
5
5
 
6
6
  trampCall(
7
- delayCall( 'require',
7
+ delayCall( '_require', 'require',
8
8
  begin
9
9
  if @global_lisp_binding.has_key?('_require') then
10
10
  trampCall(@_require)
11
11
  else raise NameError.new( "Error: undefined variable _require", "_require" ) end
12
12
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:10"] + __e.backtrace ) ; raise __e
13
13
  end ,
14
- Cell.new(
14
+ [
15
15
  "stringio"
16
- ))
16
+ ]
17
+ )
17
18
  )
18
19
  #--------------------
19
20
 
@@ -38,12 +39,13 @@ trampCall(
38
39
  else raise NameError.new( "Error: undefined variable _null_QUMARK", "_null_QUMARK" ) end
39
40
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:17"] + __e.backtrace ) ; raise __e
40
41
  end ,
41
- Cell.new(
42
+ [
42
43
  begin
43
44
  trampCall(_tree)
44
45
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:20"] + __e.backtrace ) ; raise __e
45
46
  end
46
- )))
47
+ ]
48
+ ))
47
49
  ) then
48
50
  begin
49
51
  true
@@ -57,12 +59,13 @@ trampCall(
57
59
  else raise NameError.new( "Error: undefined variable _pair_QUMARK", "_pair_QUMARK" ) end
58
60
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
59
61
  end ,
60
- Cell.new(
62
+ [
61
63
  begin
62
64
  trampCall(_tree)
63
65
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:20"] + __e.backtrace ) ; raise __e
64
66
  end
65
- )))
67
+ ]
68
+ ))
66
69
  ) then
67
70
  begin
68
71
  trampCall( self._write_MIMARKtree_METHOD( 'write-tree',
@@ -72,7 +75,7 @@ trampCall(
72
75
  else raise NameError.new( "Error: undefined variable _write_MIMARKtree", "_write_MIMARKtree" ) end
73
76
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
74
77
  end ,
75
- Cell.new(
78
+ [
76
79
  trampCall( self._car_METHOD( 'car',
77
80
  begin
78
81
  if @global_lisp_binding.has_key?('_car') then
@@ -80,23 +83,25 @@ trampCall(
80
83
  else raise NameError.new( "Error: undefined variable _car", "_car" ) end
81
84
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
82
85
  end ,
83
- Cell.new(
86
+ [
84
87
  begin
85
88
  trampCall(_tree)
86
89
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:20"] + __e.backtrace ) ; raise __e
87
90
  end
88
- ))) ,Cell.new(
91
+ ]
92
+ )) ,
89
93
  begin
90
94
  trampCall(_out)
91
95
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
92
96
  end
93
- ))))
94
- delayCall( 'loop',
97
+ ]
98
+ ))
99
+ delayCall( '_loop', 'loop',
95
100
  begin
96
101
  trampCall(_loop)
97
102
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
98
103
  end ,
99
- Cell.new(
104
+ [
100
105
  trampCall( self._cdr_METHOD( 'cdr',
101
106
  begin
102
107
  if @global_lisp_binding.has_key?('_cdr') then
@@ -104,13 +109,15 @@ trampCall(
104
109
  else raise NameError.new( "Error: undefined variable _cdr", "_cdr" ) end
105
110
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
106
111
  end ,
107
- Cell.new(
112
+ [
108
113
  begin
109
114
  trampCall(_tree)
110
115
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:20"] + __e.backtrace ) ; raise __e
111
116
  end
112
- )))
113
- ))
117
+ ]
118
+ ))
119
+ ]
120
+ )
114
121
  end
115
122
  else
116
123
  if (
@@ -133,17 +140,18 @@ trampCall(
133
140
  end
134
141
  end
135
142
  }
136
- delayCall( 'loop',
143
+ delayCall( '_loop', 'loop',
137
144
  begin
138
145
  trampCall(_loop)
139
146
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
140
147
  end ,
141
- Cell.new(
148
+ [
142
149
  begin
143
150
  trampCall(_tree)
144
151
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:20"] + __e.backtrace ) ; raise __e
145
152
  end
146
- ))
153
+ ]
154
+ )
147
155
  } ; ___lambda.call(
148
156
  nil
149
157
  )
@@ -157,31 +165,33 @@ trampCall(
157
165
  else raise NameError.new( "Error: undefined variable _null_QUMARK", "_null_QUMARK" ) end
158
166
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:17"] + __e.backtrace ) ; raise __e
159
167
  end ,
160
- Cell.new(
168
+ [
161
169
  begin
162
170
  trampCall(_out)
163
171
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
164
172
  end
165
- )))
173
+ ]
174
+ ))
166
175
  ) then
167
176
  begin
168
177
  trampCall(STDOUT)
169
178
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:14"] + __e.backtrace ) ; raise __e
170
179
  end
171
180
  else
172
- delayCall( 'car',
181
+ delayCall( '_car', 'car',
173
182
  begin
174
183
  if @global_lisp_binding.has_key?('_car') then
175
184
  trampCall(@_car)
176
185
  else raise NameError.new( "Error: undefined variable _car", "_car" ) end
177
186
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
178
187
  end ,
179
- Cell.new(
188
+ [
180
189
  begin
181
190
  trampCall(_out)
182
191
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:18"] + __e.backtrace ) ; raise __e
183
192
  end
184
- ))
193
+ ]
194
+ )
185
195
  end
186
196
  )
187
197
  end
@@ -207,16 +217,17 @@ trampCall(
207
217
  else raise NameError.new( "Error: undefined variable _write_MIMARKtree", "_write_MIMARKtree" ) end
208
218
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:24"] + __e.backtrace ) ; raise __e
209
219
  end ,
210
- Cell.new(
220
+ [
211
221
  begin
212
222
  trampCall(_tree)
213
223
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:24"] + __e.backtrace ) ; raise __e
214
- end ,Cell.new(
224
+ end ,
215
225
  begin
216
226
  trampCall(_sio)
217
227
  rescue => __e ; __e.set_backtrace( ["./lib/text/tree.nnd:24"] + __e.backtrace ) ; raise __e
218
228
  end
219
- ))))
229
+ ]
230
+ ))
220
231
  begin
221
232
  trampCall(_sio).string(
222
233
  )
data/test/nendo_spec.rb CHANGED
@@ -553,155 +553,6 @@ describe Nendo, "when read various list expressions" do
553
553
  end
554
554
 
555
555
 
556
- describe Nendo, "when use #xxxx syntax " do
557
- before do
558
- @nendo = Nendo::Core.new()
559
- @nendo.loadInitFile
560
- end
561
- it "should" do
562
- @nendo.evalStr( " #t " ).should == "#t"
563
- @nendo.evalStr( " #f " ).should == "#f"
564
- @nendo.evalStr( " '#( 1 ) " ).should == "#(1)"
565
- @nendo.evalStr( " '#() " ).should == "#()"
566
- @nendo.evalStr( " #! \n #t" ).should == "#t"
567
- @nendo.evalStr( " #! \n 100" ).should == "100"
568
- @nendo.evalStr( " #! 123 \n 100" ).should == "100"
569
- @nendo.evalStr( " '#?=1" ).should == "(debug-print 1 \"(string)\" 1 '1)"
570
- @nendo.evalStr( " #b0 " ).should == Integer("0b0").to_s
571
- @nendo.evalStr( " #b01 " ).should == Integer("0b01").to_s
572
- @nendo.evalStr( " #b10 " ).should == Integer("0b10").to_s
573
- @nendo.evalStr( " #b00000001 " ).should == Integer("0b00000001").to_s
574
- @nendo.evalStr( " #b1010101010101010 " ).should == Integer("0b1010101010101010").to_s
575
- lambda { @nendo.evalStr( " #b2 " ) }.should raise_error(RuntimeError)
576
- lambda { @nendo.evalStr( " #b02 " ) }.should raise_error(RuntimeError)
577
- lambda { @nendo.evalStr( " #bF " ) }.should raise_error(RuntimeError)
578
- @nendo.evalStr( " #o0 " ).should == Integer("0o0").to_s
579
- @nendo.evalStr( " #o7 " ).should == Integer("0o7").to_s
580
- @nendo.evalStr( " #o01 " ).should == Integer("0o01").to_s
581
- @nendo.evalStr( " #o10 " ).should == Integer("0o10").to_s
582
- @nendo.evalStr( " #o777 " ).should == Integer("0o777").to_s
583
- @nendo.evalStr( " #o00000007 " ).should == Integer("0o00000007").to_s
584
- @nendo.evalStr( " #o0123456701234567 " ).should == Integer("0o0123456701234567").to_s
585
- lambda { @nendo.evalStr( " #o8 " ) }.should raise_error(RuntimeError)
586
- lambda { @nendo.evalStr( " #o08 " ) }.should raise_error(RuntimeError)
587
- lambda { @nendo.evalStr( " #oA " ) }.should raise_error(RuntimeError)
588
- @nendo.evalStr( " #d0 " ).should == Integer("0d0").to_s
589
- @nendo.evalStr( " #d9 " ).should == Integer("0d9").to_s
590
- @nendo.evalStr( " #d01 " ).should == Integer("0d01").to_s
591
- @nendo.evalStr( " #d10 " ).should == Integer("0d10").to_s
592
- @nendo.evalStr( " #d999 " ).should == Integer("0d999").to_s
593
- @nendo.evalStr( " #d00000009 " ).should == Integer("0d00000009").to_s
594
- @nendo.evalStr( " #d0123456701234567 " ).should == Integer("0d0123456701234567").to_s
595
- lambda { @nendo.evalStr( " #dA " ) }.should raise_error(RuntimeError)
596
- lambda { @nendo.evalStr( " #dF " ) }.should raise_error(RuntimeError)
597
- @nendo.evalStr( " #x0 " ).should == Integer("0x0").to_s
598
- @nendo.evalStr( " #x9 " ).should == Integer("0x9").to_s
599
- @nendo.evalStr( " #xA " ).should == Integer("0xA").to_s
600
- @nendo.evalStr( " #xF " ).should == Integer("0xF").to_s
601
- @nendo.evalStr( " #x01 " ).should == Integer("0x01").to_s
602
- @nendo.evalStr( " #x10 " ).should == Integer("0x10").to_s
603
- @nendo.evalStr( " #xFFF " ).should == Integer("0xFFF").to_s
604
- @nendo.evalStr( " #x0000000F " ).should == Integer("0x0000000F").to_s
605
- @nendo.evalStr( " #x0123456789ABCDEF0123456789ABCDEF " ).should == Integer("0x0123456789ABCDEF0123456789ABCDEF").to_s
606
- lambda { @nendo.evalStr( " #xg " ) }.should raise_error(RuntimeError)
607
- lambda { @nendo.evalStr( " #xh " ) }.should raise_error(RuntimeError)
608
- lambda { @nendo.evalStr( " #xz " ) }.should raise_error(RuntimeError)
609
- lambda { @nendo.evalStr( " #xG " ) }.should raise_error(RuntimeError)
610
- lambda { @nendo.evalStr( " #xH " ) }.should raise_error(RuntimeError)
611
- lambda { @nendo.evalStr( " #xZ " ) }.should raise_error(RuntimeError)
612
- lambda { @nendo.evalStr( " #a " ) }.should raise_error(NameError)
613
- lambda { @nendo.evalStr( " #c " ) }.should raise_error(NameError)
614
- lambda { @nendo.evalStr( " #e " ) }.should raise_error(NameError)
615
- lambda { @nendo.evalStr( " #tt " ) }.should raise_error(NameError)
616
- lambda { @nendo.evalStr( " #ff " ) }.should raise_error(NameError)
617
- lambda { @nendo.evalStr( " #abc " ) }.should raise_error(NameError)
618
- lambda { @nendo.evalStr( " #? " ) }.should raise_error(NameError)
619
- lambda { @nendo.evalStr( " #?a " ) }.should raise_error(NameError)
620
- lambda { @nendo.evalStr( " #= " ) }.should raise_error(NameError)
621
- lambda { @nendo.evalStr( " #?? " ) }.should raise_error(NameError)
622
- end
623
- end
624
-
625
- describe Nendo, "when use regexp litteral and library functions " do
626
- before do
627
- @nendo = Nendo::Core.new()
628
- @nendo.loadInitFile
629
- end
630
- it "should" do
631
- @nendo.evalStr( " #/abc/ " ).should == "#/abc/"
632
- @nendo.evalStr( " #/[a-z]/ " ).should == "#/[a-z]/"
633
- @nendo.evalStr( " #/[a-zA-Z0-9]+/ " ).should == "#/[a-zA-Z0-9]+/"
634
- @nendo.evalStr( " #/\\d/ " ).should == "#/\\d/"
635
- @nendo.evalStr( " #/[\\/]/ " ).should == "#/[/]/"
636
- @nendo.evalStr( " #/abc/i " ).should == "#/abc/i"
637
- @nendo.evalStr( " #/[a-z]/i " ).should == "#/[a-z]/i"
638
- lambda { @nendo.evalStr( " #/[a-z]/I " ) }.should raise_error(NameError)
639
- lambda { @nendo.evalStr( " #/[a-z]/a " ) }.should raise_error(NameError)
640
-
641
- @nendo.evalStr( " (string->regexp \"abc\") " ).should == "#/abc/"
642
- @nendo.evalStr( " (string->regexp \"[a-z]\") " ).should == "#/[a-z]/"
643
- @nendo.evalStr( " (string->regexp \"[a-zA-Z0-9]+\" ) " ).should == "#/[a-zA-Z0-9]+/"
644
- @nendo.evalStr( " (string->regexp \"\\\\d\" ) " ).should == "#/\\d/"
645
- @nendo.evalStr( " (regexp? #/str/ ) " ).should == "#t"
646
- @nendo.evalStr( " (regexp? #/str/i ) " ).should == "#t"
647
- @nendo.evalStr( " (regexp? \"str\" ) " ).should == "#f"
648
- @nendo.evalStr( " (regexp? 'str) " ).should == "#f"
649
- @nendo.evalStr( " (regexp? (. \"str\" intern)) " ).should == "#f"
650
- @nendo.evalStr( " (regexp? 100) " ).should == "#f"
651
-
652
- @nendo.evalStr( " (regexp->string #/abc/ ) " ).should == '"abc"'
653
- @nendo.evalStr( " (regexp->string #/[a-z]/ ) " ).should == '"[a-z]"'
654
- @nendo.evalStr( " (regexp->string #/[a-zA-Z0-9]+/ ) " ).should == '"[a-zA-Z0-9]+"'
655
- @nendo.evalStr( ' (regexp->string #/\d+/ ) ' ).should == '"\\\\d+"'
656
-
657
- @nendo.evalStr( ' (define matchdata (rxmatch #/(\d+):(\d+)/ "foo314:2000bar")) ' ).should == '314:2000'
658
- @nendo.evalStr( ' (rxmatch-start matchdata) ' ).should == '3'
659
- @nendo.evalStr( ' (rxmatch-start matchdata 0) ' ).should == '3'
660
- @nendo.evalStr( ' (rxmatch-start matchdata 1) ' ).should == '3'
661
- @nendo.evalStr( ' (rxmatch-start matchdata 2) ' ).should == '7'
662
- @nendo.evalStr( ' (rxmatch-end matchdata) ' ).should == '11'
663
- @nendo.evalStr( ' (rxmatch-end matchdata 0) ' ).should == '11'
664
- @nendo.evalStr( ' (rxmatch-end matchdata 1) ' ).should == '6'
665
- @nendo.evalStr( ' (rxmatch-end matchdata 2) ' ).should == '11'
666
- @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"314:2000"'
667
- @nendo.evalStr( ' (rxmatch-substring matchdata 0) ' ).should == '"314:2000"'
668
- @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"314"'
669
- @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"2000"'
670
- @nendo.evalStr( ' (rxmatch-num-matches matchdata) ' ).should == '3'
671
-
672
- @nendo.evalStr( ' (define matchdata (rxmatch #/(\w+)@([\w.]+)/ "foo@example.com")) ' ).should == 'foo@example.com'
673
- @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"foo@example.com"'
674
- @nendo.evalStr( ' (rxmatch-substring matchdata 0) ' ).should == '"foo@example.com"'
675
- @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"foo"'
676
- @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"example.com"'
677
-
678
- @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com")' ).should == '"foo@example.com"'
679
- @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 0)' ).should == '"foo@example.com"'
680
- @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 1)' ).should == '"foo"'
681
- @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 2)' ).should == '"example.com"'
682
-
683
- @nendo.evalStr( ' (rxmatch->string #/abc/ "000abc00ABC000")' ).should == '"abc"'
684
- @nendo.evalStr( ' (rxmatch->string #/ABC/ "000abc00ABC000")' ).should == '"ABC"'
685
- @nendo.evalStr( ' (rxmatch->string #/abc/i "abc")' ).should == '"abc"'
686
- @nendo.evalStr( ' (rxmatch->string #/abc/i "ABC")' ).should == '"ABC"'
687
- @nendo.evalStr( ' (rxmatch->string #/ABC/i "abc")' ).should == '"abc"'
688
- @nendo.evalStr( ' (rxmatch->string #/abc/i "AbC")' ).should == '"AbC"'
689
-
690
- @nendo.evalStr( ' (rxmatch #/abc/i "xxx")' ).should == '#f'
691
- @nendo.evalStr( ' (rxmatch #/XXX/ "xxx")' ).should == '#f'
692
- @nendo.evalStr( ' (rxmatch->string #/abc/i "xxx")' ).should == '#f'
693
- @nendo.evalStr( ' (rxmatch->string #/XXX/ "xxx")' ).should == '#f'
694
-
695
- pending( "JRuby can't compute correctly" ) if defined? JRUBY_VERSION
696
- @nendo.evalStr( ' (define matchdata (rxmatch #/([あ-ん])([あ-ん])([あ-ん])([あ-ん])([あ-ん])/ "ABC漢字あいうえお漢字ABC")) ' ).should == 'あいうえお'
697
- @nendo.evalStr( ' (rxmatch-start matchdata) ' ).should == '5'
698
- @nendo.evalStr( ' (rxmatch-end matchdata) ' ).should == '10'
699
- @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"あいうえお"'
700
- @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"あ"'
701
- @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"い"'
702
- @nendo.evalStr( ' (rxmatch-substring matchdata 3) ' ).should == '"う"'
703
- end
704
- end
705
556
 
706
557
 
707
558
  class TestClassForBlockArgument
@@ -772,6 +623,7 @@ describe Nendo, "when call evalStr() with built-in functions" do
772
623
  @nendo.evalStr( " (cons '(1 2) '(3 4)) " ).should == "((1 2) 3 4)"
773
624
  @nendo.evalStr( " (cons '(1 2) '((3 4))) " ).should == "((1 2) (3 4))"
774
625
  @nendo.evalStr( " (cons '() '()) " ).should == "(())"
626
+ @nendo.evalStr( " (cons 1 '()) " ).should == "(1)"
775
627
  @nendo.evalStr( " (cons '() (cdr '(100))) " ).should == "(())"
776
628
  @nendo.evalStr( " (cons '() (car '(()))) " ).should == "(())"
777
629
  @nendo.evalStr( " (cons (car '(())) '()) " ).should == "(())"
@@ -898,6 +750,13 @@ describe Nendo, "when call evalStr() with built-in functions" do
898
750
  @nendo.evalStr( ' (string-join \'("Aa" "Bb" "Cc") "//") ' ).should == '"Aa//Bb//Cc"'
899
751
  lambda { @nendo.evalStr( ' (string-join \'("Aa" "Bb" "Cc") 100) ' ) }.should raise_error(TypeError)
900
752
  lambda { @nendo.evalStr( ' (string-join \'("Aa" "Bb" "Cc") :xx) ' ) }.should raise_error(TypeError)
753
+ @nendo.evalStr( ' (read-from-string "1") ' ).should == '1'
754
+ @nendo.evalStr( ' (read-from-string "(+ 1 2)") ' ).should == '(+ 1 2)'
755
+ @nendo.evalStr( ' (read-from-string "(\"Aa\" \"Bb\" \"Cc\")") ' ).should == '("Aa" "Bb" "Cc")'
756
+ lambda { @nendo.evalStr( ' (read-from-string 100) ' ) }.should raise_error(TypeError)
757
+ @nendo.evalStr( ' (write-to-string 1) ' ).should == '"1"'
758
+ @nendo.evalStr( ' (write-to-string \'(+ 1 2)) ' ).should == '"(+ 1 2)"'
759
+ @nendo.evalStr( ' (write-to-string \'("Aa" "Bb" "Cc")) ' ).should == '"(\"Aa\" \"Bb\" \"Cc\")"'
901
760
  end
902
761
  end
903
762
 
@@ -986,6 +845,10 @@ describe Nendo, "when call evalStr() with built-in special forms" do
986
845
  @nendo.evalStr( " ((lambda (arg1) arg1) (+ 1 2 3))" ).should == "6"
987
846
  @nendo.evalStr( " ((if #t + *) 3 4)" ).should == "7"
988
847
  @nendo.evalStr( " ((if #f + *) 3 4)" ).should == "12"
848
+ @nendo.evalStr( " (apply1 + '(1 2))" ).should == "3"
849
+ @nendo.evalStr( " (apply1 + (range 10 1))" ).should == "55"
850
+ @nendo.evalStr( " (apply1 cons '(1 2))" ).should == "(1 . 2)"
851
+ @nendo.evalStr( " (apply1 list '(1 2 3))" ).should == "(1 2 3)"
989
852
  lambda { @nendo.evalStr( " (error \"My Runtime Error\") " ) }.should raise_error( RuntimeError )
990
853
  end
991
854
  end
@@ -1040,6 +903,158 @@ describe Nendo, "when call evalStr() with macroexpand-1 function" do
1040
903
  end
1041
904
  end
1042
905
 
906
+
907
+ describe Nendo, "when use #xxxx syntax " do
908
+ before do
909
+ @nendo = Nendo::Core.new()
910
+ @nendo.loadInitFile
911
+ end
912
+ it "should" do
913
+ @nendo.evalStr( " #t " ).should == "#t"
914
+ @nendo.evalStr( " #f " ).should == "#f"
915
+ @nendo.evalStr( " '#( 1 ) " ).should == "#(1)"
916
+ @nendo.evalStr( " '#() " ).should == "#()"
917
+ @nendo.evalStr( " #! \n #t" ).should == "#t"
918
+ @nendo.evalStr( " #! \n 100" ).should == "100"
919
+ @nendo.evalStr( " #! 123 \n 100" ).should == "100"
920
+ @nendo.evalStr( " '#?=1" ).should == "(debug-print 1 \"(string)\" 1 '1)"
921
+ @nendo.evalStr( " #b0 " ).should == Integer("0b0").to_s
922
+ @nendo.evalStr( " #b01 " ).should == Integer("0b01").to_s
923
+ @nendo.evalStr( " #b10 " ).should == Integer("0b10").to_s
924
+ @nendo.evalStr( " #b00000001 " ).should == Integer("0b00000001").to_s
925
+ @nendo.evalStr( " #b1010101010101010 " ).should == Integer("0b1010101010101010").to_s
926
+ lambda { @nendo.evalStr( " #b2 " ) }.should raise_error(RuntimeError)
927
+ lambda { @nendo.evalStr( " #b02 " ) }.should raise_error(RuntimeError)
928
+ lambda { @nendo.evalStr( " #bF " ) }.should raise_error(RuntimeError)
929
+ @nendo.evalStr( " #o0 " ).should == Integer("0o0").to_s
930
+ @nendo.evalStr( " #o7 " ).should == Integer("0o7").to_s
931
+ @nendo.evalStr( " #o01 " ).should == Integer("0o01").to_s
932
+ @nendo.evalStr( " #o10 " ).should == Integer("0o10").to_s
933
+ @nendo.evalStr( " #o777 " ).should == Integer("0o777").to_s
934
+ @nendo.evalStr( " #o00000007 " ).should == Integer("0o00000007").to_s
935
+ @nendo.evalStr( " #o0123456701234567 " ).should == Integer("0o0123456701234567").to_s
936
+ lambda { @nendo.evalStr( " #o8 " ) }.should raise_error(RuntimeError)
937
+ lambda { @nendo.evalStr( " #o08 " ) }.should raise_error(RuntimeError)
938
+ lambda { @nendo.evalStr( " #oA " ) }.should raise_error(RuntimeError)
939
+ @nendo.evalStr( " #d0 " ).should == Integer("0d0").to_s
940
+ @nendo.evalStr( " #d9 " ).should == Integer("0d9").to_s
941
+ @nendo.evalStr( " #d01 " ).should == Integer("0d01").to_s
942
+ @nendo.evalStr( " #d10 " ).should == Integer("0d10").to_s
943
+ @nendo.evalStr( " #d999 " ).should == Integer("0d999").to_s
944
+ @nendo.evalStr( " #d00000009 " ).should == Integer("0d00000009").to_s
945
+ @nendo.evalStr( " #d0123456701234567 " ).should == Integer("0d0123456701234567").to_s
946
+ lambda { @nendo.evalStr( " #dA " ) }.should raise_error(RuntimeError)
947
+ lambda { @nendo.evalStr( " #dF " ) }.should raise_error(RuntimeError)
948
+ @nendo.evalStr( " #x0 " ).should == Integer("0x0").to_s
949
+ @nendo.evalStr( " #x9 " ).should == Integer("0x9").to_s
950
+ @nendo.evalStr( " #xA " ).should == Integer("0xA").to_s
951
+ @nendo.evalStr( " #xF " ).should == Integer("0xF").to_s
952
+ @nendo.evalStr( " #x01 " ).should == Integer("0x01").to_s
953
+ @nendo.evalStr( " #x10 " ).should == Integer("0x10").to_s
954
+ @nendo.evalStr( " #xFFF " ).should == Integer("0xFFF").to_s
955
+ @nendo.evalStr( " #x0000000F " ).should == Integer("0x0000000F").to_s
956
+ @nendo.evalStr( " #x0123456789ABCDEF0123456789ABCDEF " ).should == Integer("0x0123456789ABCDEF0123456789ABCDEF").to_s
957
+ lambda { @nendo.evalStr( " #xg " ) }.should raise_error(RuntimeError)
958
+ lambda { @nendo.evalStr( " #xh " ) }.should raise_error(RuntimeError)
959
+ lambda { @nendo.evalStr( " #xz " ) }.should raise_error(RuntimeError)
960
+ lambda { @nendo.evalStr( " #xG " ) }.should raise_error(RuntimeError)
961
+ lambda { @nendo.evalStr( " #xH " ) }.should raise_error(RuntimeError)
962
+ lambda { @nendo.evalStr( " #xZ " ) }.should raise_error(RuntimeError)
963
+ lambda { @nendo.evalStr( " #a " ) }.should raise_error(NameError)
964
+ lambda { @nendo.evalStr( " #c " ) }.should raise_error(NameError)
965
+ lambda { @nendo.evalStr( " #e " ) }.should raise_error(NameError)
966
+ lambda { @nendo.evalStr( " #tt " ) }.should raise_error(NameError)
967
+ lambda { @nendo.evalStr( " #ff " ) }.should raise_error(NameError)
968
+ lambda { @nendo.evalStr( " #abc " ) }.should raise_error(NameError)
969
+ lambda { @nendo.evalStr( " #? " ) }.should raise_error(NameError)
970
+ lambda { @nendo.evalStr( " #?a " ) }.should raise_error(NameError)
971
+ lambda { @nendo.evalStr( " #= " ) }.should raise_error(NameError)
972
+ lambda { @nendo.evalStr( " #?? " ) }.should raise_error(NameError)
973
+ end
974
+ end
975
+
976
+ describe Nendo, "when use regexp litteral and library functions " do
977
+ before do
978
+ @nendo = Nendo::Core.new()
979
+ @nendo.loadInitFile
980
+ end
981
+ it "should" do
982
+ @nendo.evalStr( " #/abc/ " ).should == "#/abc/"
983
+ @nendo.evalStr( " #/[a-z]/ " ).should == "#/[a-z]/"
984
+ @nendo.evalStr( " #/[a-zA-Z0-9]+/ " ).should == "#/[a-zA-Z0-9]+/"
985
+ @nendo.evalStr( " #/\\d/ " ).should == "#/\\d/"
986
+ @nendo.evalStr( " #/[\\/]/ " ).should == "#/[/]/"
987
+ @nendo.evalStr( " #/abc/i " ).should == "#/abc/i"
988
+ @nendo.evalStr( " #/[a-z]/i " ).should == "#/[a-z]/i"
989
+ lambda { @nendo.evalStr( " #/[a-z]/I " ) }.should raise_error(NameError)
990
+ lambda { @nendo.evalStr( " #/[a-z]/a " ) }.should raise_error(NameError)
991
+
992
+ @nendo.evalStr( " (string->regexp \"abc\") " ).should == "#/abc/"
993
+ @nendo.evalStr( " (string->regexp \"[a-z]\") " ).should == "#/[a-z]/"
994
+ @nendo.evalStr( " (string->regexp \"[a-zA-Z0-9]+\" ) " ).should == "#/[a-zA-Z0-9]+/"
995
+ @nendo.evalStr( " (string->regexp \"\\\\d\" ) " ).should == "#/\\d/"
996
+ @nendo.evalStr( " (regexp? #/str/ ) " ).should == "#t"
997
+ @nendo.evalStr( " (regexp? #/str/i ) " ).should == "#t"
998
+ @nendo.evalStr( " (regexp? \"str\" ) " ).should == "#f"
999
+ @nendo.evalStr( " (regexp? 'str) " ).should == "#f"
1000
+ @nendo.evalStr( " (regexp? (. \"str\" intern)) " ).should == "#f"
1001
+ @nendo.evalStr( " (regexp? 100) " ).should == "#f"
1002
+
1003
+ @nendo.evalStr( " (regexp->string #/abc/ ) " ).should == '"abc"'
1004
+ @nendo.evalStr( " (regexp->string #/[a-z]/ ) " ).should == '"[a-z]"'
1005
+ @nendo.evalStr( " (regexp->string #/[a-zA-Z0-9]+/ ) " ).should == '"[a-zA-Z0-9]+"'
1006
+ @nendo.evalStr( ' (regexp->string #/\d+/ ) ' ).should == '"\\\\d+"'
1007
+
1008
+ @nendo.evalStr( ' (define matchdata (rxmatch #/(\d+):(\d+)/ "foo314:2000bar")) ' ).should == '314:2000'
1009
+ @nendo.evalStr( ' (rxmatch-start matchdata) ' ).should == '3'
1010
+ @nendo.evalStr( ' (rxmatch-start matchdata 0) ' ).should == '3'
1011
+ @nendo.evalStr( ' (rxmatch-start matchdata 1) ' ).should == '3'
1012
+ @nendo.evalStr( ' (rxmatch-start matchdata 2) ' ).should == '7'
1013
+ @nendo.evalStr( ' (rxmatch-end matchdata) ' ).should == '11'
1014
+ @nendo.evalStr( ' (rxmatch-end matchdata 0) ' ).should == '11'
1015
+ @nendo.evalStr( ' (rxmatch-end matchdata 1) ' ).should == '6'
1016
+ @nendo.evalStr( ' (rxmatch-end matchdata 2) ' ).should == '11'
1017
+ @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"314:2000"'
1018
+ @nendo.evalStr( ' (rxmatch-substring matchdata 0) ' ).should == '"314:2000"'
1019
+ @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"314"'
1020
+ @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"2000"'
1021
+ @nendo.evalStr( ' (rxmatch-num-matches matchdata) ' ).should == '3'
1022
+
1023
+ @nendo.evalStr( ' (define matchdata (rxmatch #/(\w+)@([\w.]+)/ "foo@example.com")) ' ).should == 'foo@example.com'
1024
+ @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"foo@example.com"'
1025
+ @nendo.evalStr( ' (rxmatch-substring matchdata 0) ' ).should == '"foo@example.com"'
1026
+ @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"foo"'
1027
+ @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"example.com"'
1028
+
1029
+ @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com")' ).should == '"foo@example.com"'
1030
+ @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 0)' ).should == '"foo@example.com"'
1031
+ @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 1)' ).should == '"foo"'
1032
+ @nendo.evalStr( ' (rxmatch->string #/(\w+)@([\w.]+)/ "foo@example.com" 2)' ).should == '"example.com"'
1033
+
1034
+ @nendo.evalStr( ' (rxmatch->string #/abc/ "000abc00ABC000")' ).should == '"abc"'
1035
+ @nendo.evalStr( ' (rxmatch->string #/ABC/ "000abc00ABC000")' ).should == '"ABC"'
1036
+ @nendo.evalStr( ' (rxmatch->string #/abc/i "abc")' ).should == '"abc"'
1037
+ @nendo.evalStr( ' (rxmatch->string #/abc/i "ABC")' ).should == '"ABC"'
1038
+ @nendo.evalStr( ' (rxmatch->string #/ABC/i "abc")' ).should == '"abc"'
1039
+ @nendo.evalStr( ' (rxmatch->string #/abc/i "AbC")' ).should == '"AbC"'
1040
+
1041
+ @nendo.evalStr( ' (rxmatch #/abc/i "xxx")' ).should == '#f'
1042
+ @nendo.evalStr( ' (rxmatch #/XXX/ "xxx")' ).should == '#f'
1043
+ @nendo.evalStr( ' (rxmatch->string #/abc/i "xxx")' ).should == '#f'
1044
+ @nendo.evalStr( ' (rxmatch->string #/XXX/ "xxx")' ).should == '#f'
1045
+
1046
+ pending( "JRuby can't compute correctly" ) if defined? JRUBY_VERSION
1047
+ @nendo.evalStr( ' (define matchdata (rxmatch #/([あ-ん])([あ-ん])([あ-ん])([あ-ん])([あ-ん])/ "ABC漢字あいうえお漢字ABC")) ' ).should == 'あいうえお'
1048
+ @nendo.evalStr( ' (rxmatch-start matchdata) ' ).should == '5'
1049
+ @nendo.evalStr( ' (rxmatch-end matchdata) ' ).should == '10'
1050
+ @nendo.evalStr( ' (rxmatch-substring matchdata) ' ).should == '"あいうえお"'
1051
+ @nendo.evalStr( ' (rxmatch-substring matchdata 1) ' ).should == '"あ"'
1052
+ @nendo.evalStr( ' (rxmatch-substring matchdata 2) ' ).should == '"い"'
1053
+ @nendo.evalStr( ' (rxmatch-substring matchdata 3) ' ).should == '"う"'
1054
+ end
1055
+ end
1056
+
1057
+
1043
1058
  describe Nendo, "when call functions in init.nnd " do
1044
1059
  before do
1045
1060
  @nendo = Nendo::Core.new()
@@ -1353,6 +1368,15 @@ describe Nendo, "when use quasiquote macro " do
1353
1368
  @nendo.evalStr( " (set! a 3) `(1 ,@(list 2 a)) " ).should == "(1 2 3)"
1354
1369
  @nendo.evalStr( " (set! a 11) `,a " ).should == "11"
1355
1370
  @nendo.evalStr( " (set! a 12) ``,a " ).should == "`,a"
1371
+ @nendo.evalStr( ' (define str "string") str ' ).should == '"string"'
1372
+ @nendo.evalStr( ' `(,str) ' ).should == '("string")'
1373
+ @nendo.evalStr( ' `("STRING") ' ).should == '("STRING")'
1374
+ @nendo.evalStr( ' `(,str "STRING") ' ).should == '("string" "STRING")'
1375
+ @nendo.evalStr( ' `("STRING" ,str) ' ).should == '("STRING" "string")'
1376
+ @nendo.evalStr( ' (car `("STRING" ,str)) ' ).should == '"STRING"'
1377
+ @nendo.evalStr( ' (second `("STRING" ,str)) ' ).should == '"string"'
1378
+ @nendo.evalStr( ' (caar `(("STRING" ,str))) ' ).should == '"STRING"'
1379
+ @nendo.evalStr( ' (string-join `("A" "B" "C" "D")) ' ).should == '"ABCD"'
1356
1380
  @nendo.evalStr( " `(list ,(+ 1 2) 4) " ).should == "(list 3 4)"
1357
1381
  @nendo.evalStr( " (let ((name 'a)) `(list ,name ',name)) " ).should == "(list a 'a)"
1358
1382
  @nendo.evalStr( " `(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f) " ).should == "(a `(b ,(+ 1 2) ,(foo 4 d) e) f)"
@@ -1371,6 +1395,10 @@ describe Nendo, "when use macros made by quasiquote. " do
1371
1395
  @nendo.evalStr( " (case (length '(1 2 3 )) ((1) \"one\") ((2) \"two\") (else \"else\")) " ).should == '"else"'
1372
1396
  @nendo.evalStr( " (case (length '(1 2 3 4)) ((1) \"one\") ((2) \"two\") (else \"else\")) " ).should == '"else"'
1373
1397
  @nendo.evalStr( " (case 100 ((1) \"one\") ((2) \"two\") (else \"else\")) " ).should == '"else"'
1398
+ @nendo.evalStr( " (case (car '(a b 1)) ((a) 'a) ((b) 'b) (else 'else)) " ).should == 'a'
1399
+ @nendo.evalStr( " (case (cadr '(a b 1)) ((a) 'a) ((b) 'b) (else 'else)) " ).should == 'b'
1400
+ @nendo.evalStr( " (case (caddr '(a b 1)) ((a b) 'a) ((1 2) 'number) (else 'else)) " ).should == 'number'
1401
+ @nendo.evalStr( " (case (cadddr '(a b 1 2)) ((a b) 'a) ((1 2) 'number) (else 'else)) " ).should == 'number'
1374
1402
  @nendo.evalStr( " (let* ((a 1) (b (+ a 2))) (cons a b)) " ).should == "(1 . 3)"
1375
1403
  @nendo.evalStr( " (let* ((a 10) (b (* a 2))) (cons a b)) " ).should == "(10 . 20)"
1376
1404
  @nendo.evalStr( " (let* ((a 10) (b (* a 2)) (c (* b 3))) (list a b c)) " ).should == "(10 20 60)"
@@ -1491,6 +1519,7 @@ describe Nendo, "when use dot-operator (.) macro " do
1491
1519
  @nendo.evalStr( " (define a \"s\") (a.is_a? Fixnum) " ).should == "#f"
1492
1520
  @nendo.evalStr( " (define a \"s\") (a.is_a? Float) " ).should == "#f"
1493
1521
  @nendo.evalStr( " (define a \"s\") (a.is_a? String) " ).should == "#t"
1522
+ @nendo.evalStr( ' (equal? (read-from-string "\"100\"") (. 100 to_s)) ' ).should == "#t"
1494
1523
  end
1495
1524
  end
1496
1525
 
@@ -1565,6 +1594,7 @@ describe Nendo, "when use (use ...) macro " do
1565
1594
  @nendo.evalStr( " (macroexpand '(use a.b.c.d.e.f.g)) " ).should == '(load-library "a/b/c/d/e/f/g")'
1566
1595
  @nendo.evalStr( " (macroexpand '(use srfi-1)) " ).should == '(load-library "srfi-1")'
1567
1596
  @nendo.evalStr( " (macroexpand '(use text.tree)) " ).should == '(load-library "text/tree")'
1597
+ @nendo.evalStr( " (macroexpand '(use debug.syslog)) " ).should == '(load-library "debug/syslog")'
1568
1598
  @nendo.evalStr( " (macroexpand `(use ,(string->symbol (+ \"text\" \".\" \"tree\")))) " ).should == '(load-library "text/tree")'
1569
1599
  lambda { @nendo.evalStr( " (macroexpand '(use '(a)) " ) }.should raise_error( RuntimeError )
1570
1600
  lambda { @nendo.evalStr( " (macroexpand '(use \"srfi-1\") " ) }.should raise_error( RuntimeError )
data/test/nendo_util.nnd CHANGED
@@ -79,13 +79,14 @@ trampCall(
79
79
  else raise NameError.new( \"Error: undefined variable __PLMARK\", \"__PLMARK\" ) end
80
80
  rescue => __e ; __e.set_backtrace( [\"./test/nendo_util.nnd:31\"] + __e.backtrace ) ; raise __e
81
81
  end ,
82
- Cell.new(
82
+ [
83
83
  begin
84
84
  trampCall(_arg1)
85
85
  rescue => __e ; __e.set_backtrace( [\"./test/nendo_util.nnd:31\"] + __e.backtrace ) ; raise __e
86
- end ,Cell.new(
86
+ end ,
87
87
  1
88
- ))))
88
+ ]
89
+ ))
89
90
  )
90
91
  end
91
92
  }