nendo 0.5.3 → 0.5.4

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/test/nendo_spec.rb CHANGED
@@ -1807,6 +1807,22 @@ EOS
1807
1807
  end
1808
1808
  end
1809
1809
 
1810
+ describe Nendo, "when use raise function " do
1811
+ before do
1812
+ @nendo = Nendo::Core.new()
1813
+ @nendo.setDisplayErrors( false )
1814
+ @nendo.loadInitFile
1815
+ end
1816
+ it "should" do
1817
+ lambda { @nendo.evalStr( ' (%raise TypeError "typeError" "nendo_spec.rb:1 typeError" ) ' ) }.should raise_error( TypeError )
1818
+ lambda { @nendo.evalStr( ' (%raise ArgumentError "argumentError" "nendo_spec.rb:1 argumentError") ' ) }.should raise_error( ArgumentError )
1819
+ lambda { @nendo.evalStr( ' (raise TypeError "typeError" ) ' ) }.should raise_error( TypeError )
1820
+ lambda { @nendo.evalStr( ' (raise ArgumentError "argumentError" ) ' ) }.should raise_error( ArgumentError )
1821
+ lambda { @nendo.evalStr( ' (raise TypeError ) ' ) }.should raise_error( TypeError )
1822
+ lambda { @nendo.evalStr( ' (raise ArgumentError ) ' ) }.should raise_error( ArgumentError )
1823
+ end
1824
+ end
1825
+
1810
1826
  describe Nendo, "when use values " do
1811
1827
  before do
1812
1828
  @nendo = Nendo::Core.new()
@@ -2127,8 +2143,8 @@ describe Nendo, "when use dot-operator (.) macro " do
2127
2143
  lambda { @nendo.evalStr( " (macroexpand '(. open)) " ) }.should raise_error( ArgumentError )
2128
2144
  lambda { @nendo.evalStr( " (macroexpand '(. open \"aaa\")) " ) }.should raise_error( TypeError )
2129
2145
  @nendo.evalStr( " (macroexpand '(. a size)) " ).should == "(a.size)"
2130
- @nendo.evalStr( " (macroexpand '(. (. a size) to_s)) " ).gsub( /[12]0[0-9][0-9][0-9]/, "X0000" ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (a.size))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_s))"
2131
- @nendo.evalStr( " (macroexpand '(. (. (. a size) to_s) to_i)) " ).gsub( /[12]0[0-9][0-9][0-9]/, "X0000" ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (a.size))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_s)))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_i))"
2146
+ @nendo.evalStr( " (macroexpand '(. (. a size) to_s)) " ).gsub( /_[0-9][0-9][0-9][0-9][0-9]/, "_X0000" ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (a.size))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_s))"
2147
+ @nendo.evalStr( " (macroexpand '(. (. (. a size) to_s) to_i)) " ).gsub( /_[0-9][0-9][0-9][0-9][0-9]/, "_X0000" ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (a.size))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_s)))) (__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000.to_i))"
2132
2148
  lambda { @nendo.evalStr( " (macroexpand '(. (. a size))) " ) }.should raise_error( ArgumentError )
2133
2149
  @nendo.evalStr( " (set! str \"str\") str.size " ).should == "3"
2134
2150
  @nendo.evalStr( " (set! str \"str\") (. str size) " ).should == "3"
@@ -2484,7 +2500,7 @@ EOS
2484
2500
  (bar 2))
2485
2501
  ))
2486
2502
  EOS
2487
- ).gsub( /[24]0[0-9][0-9][0-9]/, "X0000" ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (foo 1))) (if __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (bar 2))) (if __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 #f))))"
2503
+ ).gsub( /_[0-9][0-9][0-9][0-9][0-9][ ]/, "_X0000 " ).should == "(%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (foo 1))) (if __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (%let ((__gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 (bar 2))) (if __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 __gensym__fb4e25e49e9fb4e46342224606faf2e3eabf1251_X0000 #f))))"
2488
2504
  @nendo.evalStr( <<EOS
2489
2505
  (%setup-%tailcall-mark (macroexpand
2490
2506
  '(let loop ((x 1))
data/test/syntax_spec.rb CHANGED
@@ -532,7 +532,7 @@ EOS
532
532
  (let ((x 'outer))
533
533
  (let-syntax ((m (syntax-rules () ((m) x))))
534
534
  (let ((x 'inner))
535
- (m))))
535
+ (m)))) ;; '
536
536
  EOS
537
537
  ).should == "outer"
538
538
 
@@ -560,20 +560,20 @@ EOS
560
560
  EOS
561
561
  ).should == "outer"
562
562
 
563
- pending( "nested let fails on limitation of Nendo's let-syntax." )
564
-
565
- @nendo.evalStr( <<EOS
566
- (define z 'top-level-1)
567
- (let ((x 'outer1))
568
- (let ((y x))
569
- (let ((z y))
570
- (let-syntax ((m (syntax-rules () ((m) z))))
571
- (let ((x 'inner1))
572
- (let ((y x))
573
- (let ((z y))
574
- (m))))))))
575
- EOS
576
- ).should == "outer1"
563
+ # pending( "nested let fails on limitation of Nendo's let-syntax." )
564
+ #
565
+ # @nendo.evalStr( <<EOS
566
+ #(define z 'top-level-1)
567
+ #(let ((x 'outer1))
568
+ # (let ((y x))
569
+ # (let ((z y))
570
+ # (let-syntax ((m (syntax-rules () ((m) z))))
571
+ # (let ((x 'inner1))
572
+ # (let ((y x))
573
+ # (let ((z y))
574
+ # (m))))))))
575
+ #EOS
576
+ # ).should == "outer1"
577
577
 
578
578
  end
579
579
  end
@@ -709,3 +709,327 @@ EOS
709
709
  end
710
710
 
711
711
 
712
+ describe Nendo, "When expand guard special form" do
713
+ before do
714
+ @nendo = Nendo::Core.new()
715
+ @nendo.loadInitFile
716
+ end
717
+ it "should" do
718
+ @nendo.evalStr( <<EOS
719
+ (macroexpand-1
720
+ (quote
721
+ (%guard-var (exc
722
+ (else (print "ELSE"))))))
723
+ EOS
724
+ ).should == "exc"
725
+
726
+ @nendo.evalStr( <<EOS
727
+ (macroexpand-1
728
+ (quote
729
+ (%guard-var (exc
730
+ ((exc.is_a? RuntimeError)
731
+ (print "<<RuntimeError>>"))
732
+ (else (print "ELSE"))))))
733
+ EOS
734
+ ).should == "exc"
735
+
736
+ @nendo.evalStr( <<EOS
737
+ (macroexpand-1
738
+ (quote
739
+ (%guard-var (exc
740
+ ((exc.is_a? RuntimeError)
741
+ (print "<<RuntimeError>>"))
742
+ (else
743
+ => (lambda (e)
744
+ (printf "Type is [%s]\n" e.class)))))))
745
+ EOS
746
+ ).should == "exc"
747
+
748
+ @nendo.evalStr( <<EOS
749
+ (macroexpand-1
750
+ (quote
751
+ (%guard-clause (exc
752
+ (else (print "ELSE"))))))
753
+ EOS
754
+ ).should == '(cond (else (print "ELSE")))'
755
+
756
+
757
+ @nendo.evalStr( <<EOS
758
+ (macroexpand-1
759
+ (quote
760
+ (%guard-clause (exc
761
+ ((exc.is_a? RuntimeError)
762
+ (print "<<RuntimeError>>"))
763
+ (else (print "ELSE"))))))
764
+ EOS
765
+ ).should == '(cond ((exc.is_a? RuntimeError) (print "<<RuntimeError>>")) (else (print "ELSE")))'
766
+
767
+ @nendo.evalStr( <<EOS
768
+ (macroexpand-1
769
+ (quote
770
+ (%guard-clause (exc
771
+ ((exc.is_a? RuntimeError)
772
+ (print "<<RuntimeError>>"))
773
+ (else
774
+ => (lambda (e)
775
+ (printf "Type is [%s]\n" e.class)))))))
776
+ EOS
777
+ ).should == "(cond ((exc.is_a? RuntimeError) (print \"<<RuntimeError>>\")) (else feedto (lambda (e) (printf \"Type is [%s]\n\" e.class))))"
778
+
779
+ end
780
+ end
781
+
782
+
783
+ describe Nendo, "When use guard special form" do
784
+ before do
785
+ @nendo = Nendo::Core.new()
786
+ @nendo.loadInitFile
787
+ end
788
+ it "should" do
789
+ @nendo.evalStr( <<EOS
790
+ (guard
791
+ (exc (else (sprintf "Type is [%s]" (exc.class))))
792
+ (error "This is RuntimeError"))
793
+ EOS
794
+ ).should == '"Type is [RuntimeError]"'
795
+
796
+ @nendo.evalStr( <<EOS
797
+ (guard
798
+ (exc (else (sprintf "Type is [%s]" exc.class)))
799
+ (+ (Array.new) 1))
800
+ EOS
801
+ ).should == '"Type is [TypeError]"'
802
+
803
+ @nendo.evalStr( <<EOS
804
+ (guard
805
+ (exc (else (sprintf "Type is [%s]" exc.class)))
806
+ (+ (Array.new) 1)
807
+ (error "This is RuntimeError"))
808
+ EOS
809
+ ).should == '"Type is [TypeError]"'
810
+
811
+ @nendo.evalStr( <<EOS
812
+ (guard
813
+ (exc (else (sprintf "Type is [%s]" exc.class)))
814
+ (error "This is RuntimeError")
815
+ (+ (Array.new) 1))
816
+ EOS
817
+ ).should == '"Type is [RuntimeError]"'
818
+
819
+ @nendo.evalStr( <<EOS
820
+ (guard
821
+ (exc ((exc.is_a? RuntimeError)
822
+ "Type is [RuntimeError]")
823
+ ((exc.is_a? TypeError)
824
+ "Type is [TypeError]")
825
+ (else
826
+ "Type is Others"))
827
+ (error "This is RuntimeError")
828
+ (+ (Array.new) 1))
829
+ EOS
830
+ ).should == '"Type is [RuntimeError]"'
831
+
832
+ @nendo.evalStr( <<EOS
833
+ (guard
834
+ (exc ((exc.is_a? RuntimeError)
835
+ "Type is [RuntimeError]")
836
+ ((exc.is_a? TypeError)
837
+ "Type is [TypeError]"))
838
+ (+ (Array.new) 1)
839
+ (error "This is RuntimeError"))
840
+ EOS
841
+ ).should == '"Type is [TypeError]"'
842
+
843
+ @nendo.evalStr( <<EOS
844
+ (guard
845
+ (exc ((exc.is_a? TypeError)
846
+ "Type is [TypeError]"))
847
+ (+ (Array.new) 1)
848
+ (error "This is RuntimeError"))
849
+ EOS
850
+ ).should == '"Type is [TypeError]"'
851
+
852
+ @nendo.evalStr( <<EOS
853
+ (guard
854
+ (exc ((exc.is_a? RuntimeError)
855
+ "Type is [RuntimeError]"))
856
+ (error "This is RuntimeError")
857
+ (+ (Array.new) 1))
858
+ EOS
859
+ ).should == '"Type is [RuntimeError]"'
860
+
861
+ @nendo.evalStr( <<EOS
862
+ (begin
863
+ (guard
864
+ (exc ((exc.is_a? RuntimeError)
865
+ "Type is [RuntimeError]"))
866
+ (+ (Array.new) 1))
867
+ \"-END-\")
868
+ EOS
869
+ ).should == '"-END-"'
870
+
871
+ end
872
+ end
873
+
874
+
875
+
876
+ describe Nendo, "When use guard and raise" do
877
+ before do
878
+ @nendo = Nendo::Core.new()
879
+ @nendo.setDisplayErrors( false )
880
+ @nendo.loadInitFile
881
+ end
882
+ it "should" do
883
+ @nendo.evalStr( <<EOS
884
+ (guard
885
+ (exc ((exc.is_a? TypeError)
886
+ "[TypeError]")
887
+ (else
888
+ "[OtherError]"))
889
+ (guard
890
+ (exc (else (+ "a" 1.1)))
891
+ (error "This is RuntimeError")))
892
+ EOS
893
+ ).should == '"[TypeError]"'
894
+
895
+ @nendo.evalStr( <<EOS
896
+ (let1 lst '()
897
+ (guard
898
+ (exc (else (push! lst 2)))
899
+ (guard
900
+ (exc (else (push! lst 1)))
901
+ (error "Error occur")))
902
+ lst)
903
+ EOS
904
+ ).should == '(1)'
905
+
906
+ @nendo.evalStr( <<EOS
907
+ (let1 lst '()
908
+ (guard
909
+ (exc (else (push! lst 2)))
910
+ (guard
911
+ (exc (else (push! lst 1)
912
+ (error "Error occur(2)")))
913
+ (error "Error occur(1)")))
914
+ lst)
915
+ EOS
916
+ ).should == '(2 1)'
917
+
918
+
919
+ lambda { @nendo.evalStr( <<EOS
920
+ (let1 lst '()
921
+ (guard
922
+ (exc (else (push! lst 3)
923
+ (errorf "Error occur:%s" (write-to-string lst))))
924
+ (guard
925
+ (exc (else (push! lst 2)
926
+ (error "Error occur(3)")))
927
+ (guard
928
+ (exc (else (push! lst 1)
929
+ (error "Error occur(2)")))
930
+ (error "Error occur(1)"))))
931
+ #t)
932
+ EOS
933
+ ) }.should raise_error( RuntimeError, /Error occur:[(]3 2 1[)]/ )
934
+
935
+
936
+ @nendo.evalStr( <<EOS
937
+ (define a
938
+ (guard
939
+ (exc (else (exc.message))) ;; line 1
940
+ (raise RuntimeError)))
941
+ (define b
942
+ (guard
943
+ (exc (else (exc.message))) ;; line 5
944
+ (raise NoMethodError)))
945
+ (define c
946
+ (guard
947
+ (exc (else (exc.message))) ;; line 9
948
+ (raise ArgumentError)))
949
+ (list a b c)
950
+ EOS
951
+ ).should == '("(string):1 raised RuntimeError" "(string):5 raised NoMethodError" "(string):9 raised ArgumentError")'
952
+
953
+
954
+ end
955
+ end
956
+
957
+
958
+ describe Nendo, "When use unwind-protect" do
959
+ before do
960
+ @nendo = Nendo::Core.new()
961
+ @nendo.setDisplayErrors( false )
962
+ @nendo.loadInitFile
963
+ end
964
+
965
+ it "should" do
966
+ @nendo.evalStr( "(macroexpand '(unwind-protect 1 2)) ;; '" ).should match( /[(]%guard #<SyntacticClosure.exc:_exc__gensym/ )
967
+
968
+ lambda { @nendo.evalStr( <<EOS
969
+ (let1 cnt 0
970
+ (begin
971
+ (set! cnt (+ cnt 1))
972
+ (set! cnt (+ cnt "string"))
973
+ ))
974
+ EOS
975
+ ) }.should raise_error( TypeError )
976
+
977
+ @nendo.evalStr( <<EOS
978
+ (let1 cnt 0
979
+ (unwind-protect
980
+ 1
981
+ 2))
982
+ EOS
983
+ ).should == '1'
984
+
985
+ @nendo.evalStr( <<EOS
986
+ (let1 cnt 0
987
+ (unwind-protect
988
+ (begin 1 2)
989
+ 3))
990
+ EOS
991
+ ).should == '2'
992
+
993
+ @nendo.evalStr( <<EOS
994
+ (let* ([cnt 0]
995
+ [result (unwind-protect
996
+ (begin
997
+ (set! cnt (+ cnt 1))
998
+ (set! cnt (+ cnt 2))
999
+ (+ 1.1 "str")
1000
+ (set! cnt (+ cnt 3)))
1001
+ (set! cnt (+ cnt 100)))])
1002
+ (list result cnt))
1003
+ EOS
1004
+ ).should == '(#f 103)'
1005
+
1006
+ @nendo.evalStr( <<EOS
1007
+ (let* ([cnt 0]
1008
+ [result (unwind-protect
1009
+ (begin
1010
+ (set! cnt (+ cnt 10))
1011
+ (set! cnt (+ cnt 01))
1012
+ (error "[RuntimeError]")
1013
+ (set! cnt (+ cnt 02)))
1014
+ (set! cnt (+ cnt 100)))])
1015
+ (list result cnt))
1016
+ EOS
1017
+ ).should == '(#f 111)'
1018
+
1019
+ @nendo.evalStr( <<EOS
1020
+ (let* ([cnt 0]
1021
+ [result (unwind-protect
1022
+ (begin
1023
+ (set! cnt (+ cnt 10))
1024
+ (set! cnt (+ cnt 01))
1025
+ (guard (exc (else (set! cnt (+ cnt 100))))
1026
+ (error "[RuntimeError]"))
1027
+ (set! cnt (+ cnt 02)))
1028
+ (set! cnt (+ cnt 1000)))])
1029
+ (list result cnt))
1030
+ EOS
1031
+ ).should == '(113 1113)'
1032
+
1033
+ end
1034
+ end
1035
+
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+ #
4
+ # syntax_spec.rb - "RSpec file for nendo language (nendo.test framework part)"
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
+ require 'timeout'
38
+
39
+ describe Nendo, "when use NendoTestError " do
40
+ before do
41
+ @nendoError1 = NendoTestError.new
42
+ @runtimeError = RuntimeError.new
43
+ @argumentError = ArgumentError.new
44
+ @nendoError2 = NendoTestError.new( @runtimeError.class )
45
+ end
46
+
47
+ it "should" do
48
+ @nendoError1.type.should == RuntimeError
49
+ @nendoError1.type = @runtimeError.class
50
+ @nendoError1.type.should == RuntimeError
51
+ @nendoError1.type = RuntimeError
52
+ @nendoError1.type.should == RuntimeError
53
+ @nendoError1.type = Timeout::Error
54
+ @nendoError1.type.should == Timeout::Error
55
+ @nendoError2.type.should == RuntimeError
56
+ end
57
+ end
58
+
59
+
60
+ describe Nendo, "when use test function " do
61
+ before do
62
+ @nendo = Nendo::Core.new()
63
+ @nendo.loadInitFile
64
+ @nendo.evalStr( "(use nendo.test)" )
65
+ end
66
+
67
+ it "should" do
68
+ @nendo.evalStr( '(test-section "(test)")' ).should == '"(test)"'
69
+
70
+ @nendo.evalStr( '(test "true false" #t (lambda () #t))' ).should == '#t'
71
+ @nendo.evalStr( '(test "true false" #f (lambda () #f))' ).should == '#t'
72
+ @nendo.evalStr( '(test "number" 0 (lambda () 0))' ).should == '#t'
73
+ @nendo.evalStr( '(test "number" 0 (lambda () 1))' ).should == '#f'
74
+ @nendo.evalStr( '(test "string" "ab" (lambda () (+ "a" "b")))' ).should == '#t'
75
+ end
76
+ end
77
+
78
+ describe Nendo, "when use test* function " do
79
+ before do
80
+ @nendo = Nendo::Core.new()
81
+ @nendo.loadInitFile
82
+ @nendo.evalStr( "(use nendo.test)" )
83
+ end
84
+
85
+ it "should" do
86
+ @nendo.evalStr( '(test-section "(test*)")' ).should == '"(test*)"'
87
+
88
+ @nendo.evalStr( '(test* "true false" #t #t)' ).should == '#t'
89
+ @nendo.evalStr( '(test* "true false" #f #f)' ).should == '#t'
90
+ @nendo.evalStr( '(test* "number" 0 0)' ).should == '#t'
91
+ @nendo.evalStr( '(test* "number" 0 1)' ).should == '#f'
92
+ @nendo.evalStr( '(test* "string" "ab" (+ "a" "b"))' ).should == '#t'
93
+ @nendo.evalStr( <<EOS
94
+ (test* "eq?" '(a b) '(a b) eq?)
95
+ EOS
96
+ ).should == '#f'
97
+
98
+ @nendo.evalStr( <<EOS
99
+ (test* "eqv?" '(a b) '(a b) eqv?)
100
+ EOS
101
+ ).should == '#f'
102
+
103
+ @nendo.evalStr( <<EOS
104
+ (test* "equal?" '(a b) '(a b) )
105
+ EOS
106
+ ).should == '#t'
107
+
108
+ end
109
+ end
110
+
111
+
112
+ describe Nendo, "when test framework handle exception " do
113
+ before do
114
+ @nendo = Nendo::Core.new()
115
+ @nendo.loadInitFile
116
+ @nendo.evalStr( "(use nendo.test)" )
117
+ end
118
+
119
+ it "should" do
120
+ @nendo.evalStr( '(test-section "exceptions")' ).should == '"exceptions"'
121
+
122
+ @nendo.evalStr( '(. (test-error ) class)' ).should == 'Nendo::NendoTestError'
123
+ @nendo.evalStr( '(. (test-error RuntimeError) class)' ).should == 'Nendo::NendoTestError'
124
+
125
+ @nendo.evalStr( '(. (test-error RuntimeError) type)' ).should == 'RuntimeError'
126
+ @nendo.evalStr( '(. (test-error ArgumentError) type)' ).should == 'ArgumentError'
127
+ @nendo.evalStr( '(. (test-error SyntaxError) type)' ).should == 'SyntaxError'
128
+
129
+ @nendo.evalStr( '(test-error? (test-error)) ' ).should == '#t'
130
+ @nendo.evalStr( '(test-error? (test-error RuntimeError)) ' ).should == '#t'
131
+ @nendo.evalStr( '(test-error? (test-error ArgumentError)) ' ).should == '#t'
132
+ @nendo.evalStr( '(test-error? (test-error SyntaxError)) ' ).should == '#t'
133
+
134
+ @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error RuntimeError ))' ).should == '#t'
135
+ @nendo.evalStr( '(test-check 1 (test-error RuntimeError ))' ).should == '#f'
136
+ @nendo.evalStr( '(test-check (test-error RuntimeError) 1 )' ).should == '#f'
137
+ @nendo.evalStr( '(test-check 1 1 )' ).should == '#t'
138
+ @nendo.evalStr( '(test-check 1 2 )' ).should == '#f'
139
+ @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error ArgumentError))' ).should == '#f'
140
+ @nendo.evalStr( '(test-check (test-error RuntimeError) (test-error SyntaxError ))' ).should == '#f'
141
+ @nendo.evalStr( '(test-check (test-error ArgumentError) (test-error RuntimeError ))' ).should == '#f'
142
+ @nendo.evalStr( '(test-check (test-error SyntaxError) (test-error RuntimeError ))' ).should == '#f'
143
+
144
+ @nendo.evalStr( '(test* "exception" (test-error TypeError) (+ 1.1 "str"))' ).should == '#t'
145
+ @nendo.evalStr( '(test* "exception" (test-error RuntimeError) (+ 1.1 "str"))' ).should == '#f'
146
+ @nendo.evalStr( '(test* "exception" (test-error TypeError) (error "[RuntimeError]"))' ).should == '#f'
147
+ @nendo.evalStr( '(test* "exception" (test-error RuntimeError) (error "[RuntimeError]"))' ).should == '#t'
148
+ @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise RuntimeError "[RuntimeError]"))' ).should == '#f'
149
+ @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise ArgumentError "[ArgumentError]"))' ).should == '#t'
150
+ @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise TypeError "[TypeError]"))' ).should == '#f'
151
+ @nendo.evalStr( '(test* "exception" (test-error ArgumentError) (raise NoMethodError "[NoMethodError]"))' ).should == '#f'
152
+ end
153
+ end
@@ -48,8 +48,8 @@
48
48
  (receive r (split-at* '(a b c d) 0) r))
49
49
  (test* "split-at* (boundary)" '((a b c d) ())
50
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))
51
+ (test* "split-at* (error)" (test-error)
52
+ (receive r (split-at* '(a b c d) -1) r))
53
53
  (test* "split-at* (shorten)" '((a b c d) ())
54
54
  (receive r (split-at* '(a b c d) 5) r))
55
55
  (test* "split-at* (fill)" '((a b c d #f #f) ())
@@ -60,7 +60,7 @@
60
60
  (test* "take* (normal)" '(a b c) (take* '(a b c d) 3))
61
61
  (test* "take* (boundary)" '() (take* '(a b c d) 0))
62
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))
63
+ (test* "take* (error)" (test-error) (take* '(a b c d) -1))
64
64
  (test* "take* (shorten)" '(a b c d) (take* '(a b c d) 5))
65
65
  (test* "take* (fill)" '(a b c d #f #f) (take* '(a b c d) 6 #t))
66
66
  (test* "take* (fill)" '(a b c d z z) (take* '(a b c d) 6 #t 'z))
@@ -68,20 +68,20 @@
68
68
  (test* "drop* (normal)" '(c d) (drop* '(a b c d) 2))
69
69
  (test* "drop* (boundary)" '(a b c d) (drop* '(a b c d) 0))
70
70
  (test* "drop* (boundary)" '() (drop* '(a b c d) 4))
71
- ;;(test* "drop* (error)" (test-error) (drop* '(a b c d) -3))
71
+ (test* "drop* (error)" (test-error) (drop* '(a b c d) -3))
72
72
  (test* "drop* (past)" '() (drop* '(a b c d) 5))
73
73
 
74
74
  (test* "take-right* (normal)" '(b c d) (take-right* '(a b c d) 3))
75
75
  (test* "take-right* (boundary)" '() (take-right* '(a b c d) 0))
76
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))
77
+ (test* "take-right* (error)" (test-error) (take-right* '(a b c d) -1))
78
78
  (test* "take-right* (shorten)" '(a b c d) (take-right* '(a b c d) 6))
79
79
  (test* "take-right* (fill)" '(z z a b c d) (take-right* '(a b c d) 6 #t 'z))
80
80
 
81
81
  (test* "drop-right* (normal)" '(a b c) (drop-right* '(a b c d) 1))
82
82
  (test* "drop-right* (boundary)" '() (drop-right* '(a b c d) 4))
83
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))
84
+ (test* "drop-right* (error)" (test-error) (drop-right* '(a b c d) -1))
85
85
  (test* "drop-right* (past)" '() (drop-right* '(a b c d) 7))
86
86
 
87
87
  (test* "slices (normal)" '((0 1 2 3) (4 5 6 7) (8 9 10 11) (12 13 14 15))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nendo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 4
10
+ version: 0.5.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kiyoka Nishiyama
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-13 00:00:00 Z
18
+ date: 2011-10-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -168,6 +168,7 @@ files:
168
168
  - test/srfi-2-test.nnd
169
169
  - test/srfi-26-test.nnd
170
170
  - test/syntax_spec.rb
171
+ - test/testframework_spec.rb
171
172
  - test/textlib-test.nnd
172
173
  - test/util-combinations-test.nnd
173
174
  - test/util-list-test.nnd
@@ -201,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  requirements: []
202
203
 
203
204
  rubyforge_project:
204
- rubygems_version: 1.7.2
205
+ rubygems_version: 1.8.10
205
206
  signing_key:
206
207
  specification_version: 3
207
208
  summary: Nendo is a dialect of Lisp.