diff options
| author | Paolo Bosetti <[email protected]> | 2012-05-29 14:32:05 -0700 |
|---|---|---|
| committer | Paolo Bosetti <[email protected]> | 2012-05-29 14:32:05 -0700 |
| commit | d73517877847dab5b345c7fa98091647737bbfe0 (patch) | |
| tree | 6090a2df49b8093606181e5416e6aa6a5040b0ec /test | |
| parent | 391f8dcef02cdafeb4e0acc693945acb166a8d09 (diff) | |
| parent | 1e5d15dbcb977f6d197c24eca4a973ee1c5bf521 (diff) | |
| download | mruby-d73517877847dab5b345c7fa98091647737bbfe0.tar.gz mruby-d73517877847dab5b345c7fa98091647737bbfe0.zip | |
Merge branch 'master' of git://github.com/mruby/mruby into XCode
Diffstat (limited to 'test')
34 files changed, 654 insertions, 72 deletions
diff --git a/test/Makefile b/test/Makefile index d46fa7a3e..170c1dac8 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,17 +16,16 @@ ASSLIB := $(BASEDIR)/assert.rb MRBS := $(BASEDIR)/t/*.rb OBJS := driver.o $(MLIB) -# C compiler (gcc) -CC = gcc -LL = gcc -AR = ar +# libraries, includes +LIBS = -lm +INCLUDES = -I$(BASEDIR)/../src -I$(BASEDIR)/../include + DEBUG_MODE = 1 ifeq ($(DEBUG_MODE),1) CFLAGS = -g else CFLAGS = -O3 endif -INCLUDES = -I../src -I../include ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ifeq ($(OS),Windows_NT) MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" @@ -43,20 +42,6 @@ MRBC = ../bin/mrbc EXE := $(TARGET) endif -# libraries, includes -LIBS = -lm - -# compiler, linker (gcc) -CC = gcc -LL = gcc -YACC = bison -DEBUG_MODE = 1 -ifeq ($(DEBUG_MODE),1) -CFLAGS = -g -O3 -else -CFLAGS = -O3 -endif -ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ############################## # generic build targets, rules @@ -66,7 +51,7 @@ all : $(EXE) ./$(EXE) # executable constructed using linker from object files -$(EXE) : $(OBJS) +$(EXE) : $(OBJS) $(LIBR) $(LL) -o $@ $(CFLAGS) $(OBJS) $(LIBR) $(LIBS) -include $(OBJS:.o=.d) @@ -77,14 +62,14 @@ $(OBJS) : %.o : %.c # Compile C source from merged mruby source $(CLIB) : $(RLIB) $(MRBC) $(INIT) - $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); cat $(INIT) $(DLIB) > $@ + $(MRBC) -Bmrbtest_irep -o$(DLIB) $(RLIB); $(CAT) $(INIT) $(DLIB) > $@ # merge mruby sources $(RLIB) : $(ASSLIB) $(MRBS) - cat $(ASSLIB) $(MRBS) > $@ + $(CAT) $(ASSLIB) $(MRBS) > $@ # clean up .PHONY : clean clean : @echo "make: removing targets, objects and depend files of `pwd`" - -rm -f $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE) + -$(RM_F) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE) diff --git a/test/t/argumenterror.rb b/test/t/argumenterror.rb new file mode 100644 index 000000000..ca998f8de --- /dev/null +++ b/test/t/argumenterror.rb @@ -0,0 +1,15 @@ +## +# ArgumentError ISO Test + +assert('ArgumentError', '15.2.24') do + e2 = nil + a = [] + begin + # this will cause an exception due to the wrong arguments + a[] + rescue => e1 + e2 = e1 + end + + ArgumentError.class == Class and e2.class == ArgumentError +end diff --git a/test/t/array.rb b/test/t/array.rb index 3b9dfedfb..dba1b035d 100644 --- a/test/t/array.rb +++ b/test/t/array.rb @@ -22,11 +22,47 @@ assert('Array#<<', '15.2.12.5.3') do end assert('Array#[]', '15.2.12.5.4') do - [1,2,3].[](1) == 2 + e2 = nil + e3 = nil + a = Array.new + begin + # this will cause an exception due to the wrong arguments + a.[]() + rescue => e1 + e2 = e1 + end + begin + # this will cause an exception due to the wrong arguments + a.[](1,2,3) + rescue => e1 + e3 = e1 + end + + [1,2,3].[](1) == 2 and + e2.class == ArgumentError and + e3.class == ArgumentError end assert('Array#[]=', '15.2.12.5.5') do - [1,2,3].[]=(1,4) == [1, 4, 3] + e2 = nil + e3 = nil + a = Array.new + begin + # this will cause an exception due to the wrong arguments + a.[]=() + rescue => e1 + e2 = e1 + end + begin + # this will cause an exception due to the wrong arguments + a.[]=(1,2,3,4) + rescue => e1 + e3 = e1 + end + + [1,2,3].[]=(1,4) == [1, 4, 3] and + e2.class == ArgumentError and + e3.class == ArgumentError end assert('Array#clear', '15.2.12.5.6') do @@ -193,5 +229,3 @@ assert('Array#unshift', '15.2.12.5.30') do end # Not ISO specified - - diff --git a/test/t/bs_block.rb b/test/t/bs_block.rb index acbade449..b290cb914 100644 --- a/test/t/bs_block.rb +++ b/test/t/bs_block.rb @@ -388,4 +388,3 @@ assert('BS Block [ruby-core:14395]') do t = Controller.new t.test_for_bug end - diff --git a/test/t/bs_literal.rb b/test/t/bs_literal.rb index b1ae3a5d6..842d8704c 100644 --- a/test/t/bs_literal.rb +++ b/test/t/bs_literal.rb @@ -36,4 +36,3 @@ end assert('BS Literal 9') do Fixnum == 1234.class end - diff --git a/test/t/bs_class.rb b/test/t/class.rb index d8bb63c05..92f3df51d 100644 --- a/test/t/bs_class.rb +++ b/test/t/class.rb @@ -1,121 +1,126 @@ ## -# Bootstrap tests for Class +# Class ISO Test -assert('BS Class 1') do +assert('Class', '15.2.3') do + Class.class == Class +end + +# Not ISO specified + +assert('Class 1') do class C; end C.class == Class end -assert('BS Class 2') do +assert('Class 2') do class C; end C.new.class == C end -assert('BS Class 3') do +assert('Class 3') do class C; end C.new.class.class == Class end -assert('BS Class 4') do +assert('Class 4') do class A; end class C < A; end C.class == Class end -assert('BS Class 5') do +assert('Class 5') do class A; end class C < A; end C.new.class == C end -assert('BS Class 6') do +assert('Class 6') do class A; end class C < A; end C.new.class.class == Class end -assert('BS Class Module 1') do +assert('Class Module 1') do module M; end M.class == Module end -assert('BS Class Module 2') do +assert('Class Module 2') do module M; end class C; include M; end C.new.class == C end # nested class -assert('BS Class Nested 1') do +assert('Class Nested 1') do class A; end class A::B; end A::B == A::B end -assert('BS Class Nested 2') do +assert('Class Nested 2') do class A; end class A::B; end A::B.new.class == A::B end -assert('BS Class Nested 3') do +assert('Class Nested 3') do class A; end class A::B; end A::B.new.class.class == Class end -assert('BS Class Nested 4') do +assert('Class Nested 4') do class A; end class A::B; end class A::B::C; end A::B::C == A::B::C end -assert('BS Class Nested 5') do +assert('Class Nested 5') do class A; end class A::B; end class A::B::C; end A::B::C.class == Class end -assert('BS Class Nested 6') do +assert('Class Nested 6') do class A; end class A::B; end class A::B::C; end A::B::C.new.class == A::B::C end -assert('BS Class Nested 7') do +assert('Class Nested 7') do class A; end class A::B; end class A::B2 < A::B; end A::B2 == A::B2 end -assert('BS Class Nested 8') do +assert('Class Nested 8') do class A; end class A::B; end class A::B2 < A::B; end A::B2.class == Class end -assert('BS Class Colon 1') do +assert('Class Colon 1') do class A; end; A::C = 1; A::C == 1 end -assert('BS Class Colon 2') do +assert('Class Colon 2') do class A; class ::C; end end; C == C end -assert('BS Class Colon 3') do +assert('Class Colon 3') do class A; class ::C; end end; C.class == Class end -assert('BS Class Dup 1') do +assert('Class Dup 1') do class C; end; C.dup.class == Class end -assert('BS Class Dup 2') do +assert('Class Dup 2') do module M; end; M.dup.class == Module end - diff --git a/test/t/enumerable.rb b/test/t/enumerable.rb new file mode 100644 index 000000000..de0bb5a34 --- /dev/null +++ b/test/t/enumerable.rb @@ -0,0 +1,103 @@ +## +# Enumerable ISO Test + +assert('Enumerable', '15.3.2') do + Enumerable.class == Module +end + +assert('Enumerable#all?', '15.3.2.2.1') do + [1,2,3].all? and not [1,false,3].all? +end + +assert('Enumerable#any?', '15.3.2.2.2') do + [false,true,false].any? and not [false,false,false].any? +end + +assert('Enumerable#collect', '15.3.2.2.3') do + [1,2,3].collect { |i| i + i } == [2,4,6] +end + +assert('Enumerable#detect', '15.3.2.2.4') do + [1,2,3].detect() { true } and [1,2,3].detect("a") { false } == 'a' +end + +assert('Array#each_with_index', '15.3.2.2.5') do + a = nil + b = nil + + [1].each_with_index {|e,i| a = e; b = i} + + a == 1 and b == 0 +end + +assert('Enumerable#entries', '15.3.2.2.6') do + [1].entries == [1] +end + +assert('Enumerable#find', '15.3.2.2.7') do + [1,2,3].find() { true } and [1,2,3].find("a") { false } == 'a' +end + +assert('Enumerable#find_all', '15.3.2.2.8') do + [1,2,3,4,5,6,7,8,9].find_all() {|i| i%2 == 0} == [2,4,6,8] +end + +assert('Enumerable#grep', '15.3.2.2.9') do + [1,2,3,4,5,6,7,8,9].grep(4..6) == [4,5,6] +end + +assert('Enumerable#include?', '15.3.2.2.10') do + [1,2,3,4,5,6,7,8,9].include?(5) and + not [1,2,3,4,5,6,7,8,9].include?(0) +end + +assert('Enumerable#inject', '15.3.2.2.11') do + [1,2,3,4,5,6].inject() {|s, n| s + n} == 21 and + [1,2,3,4,5,6].inject(1) {|s, n| s + n} == 22 +end + +assert('Enumerable#map', '15.3.2.2.12') do + [1,2,3].map { |i| i + i } == [2,4,6] +end + +assert('Enumerable#max', '15.3.2.2.13') do + a = ['aaa', 'bb', 'c'] + a.max == 'c' and + a.max {|i1,i2| i1.length <=> i2.length} == 'aaa' +end + +assert('Enumerable#min', '15.3.2.2.14') do + a = ['aaa', 'bb', 'c'] + a.min == 'aaa' and + a.min {|i1,i2| i1.length <=> i2.length} == 'c' +end + +assert('Enumerable#member?', '15.3.2.2.15') do + [1,2,3,4,5,6,7,8,9].member?(5) and + not [1,2,3,4,5,6,7,8,9].member?(0) +end + +assert('Enumerable#partion', '15.3.2.2.16') do + [0,1,2,3,4,5,6,7,8,9].partition do |i| + i % 2 == 0 + end == [[0,2,4,6,8], [1,3,5,7,9]] +end + +assert('Enumerable#reject', '15.3.2.2.17') do + [0,1,2,3,4,5,6,7,8,9].reject do |i| + i % 2 == 0 + end == [1,3,5,7,9] +end + +assert('Enumerable#select', '15.3.2.2.18') do + [1,2,3,4,5,6,7,8,9].select() {|i| i%2 == 0} == [2,4,6,8] +end + +assert('Enumerable#sort', '15.3.2.2.19') do + [7,3,1,2,6,4].sort == [1,2,3,4,6,7] and + [7,3,1,2,6,4].sort {|e1,e2| e2<=>e1} == [7,6,4,3,2,1] +end + +assert('Enumerable#to_a', '15.3.2.2.20') do + [1].to_a == [1] +end diff --git a/test/t/bs_exception.rb b/test/t/exception.rb index 6ab2cee2a..6b46314d0 100644 --- a/test/t/bs_exception.rb +++ b/test/t/exception.rb @@ -1,7 +1,45 @@ ## -# Bootstrap tests for Exceptions +# Exception ISO Test -assert('BS Exception 1') do +assert('Exception', '15.2.22') do + Exception.class == Class +end + +assert('Exception.exception', '15.2.22.4.1') do + e = Exception.exception('a') + + e.class == Exception +end + +assert('Exception#exception', '15.2.22.5.1') do + e1 = Exception.exception() + e2 = Exception.exception('b') + + e1.class == Exception and e2.class == Exception +end + +assert('Exception#message', '15.2.22.5.2') do + e = Exception.exception('a') + + e.message == 'a' +end + +assert('Exception#to_s', '15.2.22.5.3') do + e = Exception.exception('a') + + e.to_s == 'a' +end + +assert('Exception.exception', '15.2.22.4.1') do + e = Exception.exception() + e.initialize('a') + + e.message == 'a' +end + +# Not ISO specified + +assert('Exception 1') do begin 1+1 ensure @@ -9,7 +47,7 @@ assert('BS Exception 1') do end == 2 end -assert('BS Exception 2') do +assert('Exception 2') do begin 1+1 begin @@ -22,7 +60,7 @@ assert('BS Exception 2') do end == 4 end -assert('BS Exception 3') do +assert('Exception 3') do begin 1+1 begin @@ -40,7 +78,7 @@ assert('BS Exception 3') do end == 4 end -assert('BS Exception 4') do +assert('Exception 4') do a = nil 1.times{|e| begin @@ -51,7 +89,7 @@ assert('BS Exception 4') do a == NilClass end -assert('BS Exception 5') do +assert('Exception 5') do $ans = [] def m $! @@ -69,7 +107,7 @@ assert('BS Exception 5') do $ans == [nil] end -assert('BS Exception 6') do +assert('Exception 6') do $i = 0 def m iter{ @@ -95,7 +133,7 @@ assert('BS Exception 6') do $i == 7 end -assert('BS Exception 7') do +assert('Exception 7') do $i = 0 def m begin @@ -115,7 +153,7 @@ assert('BS Exception 7') do $i == 10 end -assert('BS Exception 8') do +assert('Exception 8') do begin 1 rescue @@ -125,7 +163,7 @@ assert('BS Exception 8') do end == 3 end -assert('BS Exception 9') do +assert('Exception 9') do begin 1+1 rescue @@ -137,7 +175,7 @@ assert('BS Exception 9') do end == 6 end -assert('BS Exception 10') do +assert('Exception 10') do begin 1+1 begin @@ -155,4 +193,3 @@ assert('BS Exception 10') do 7+7 end == 12 end - diff --git a/test/t/false.rb b/test/t/false.rb new file mode 100644 index 000000000..c2db283c8 --- /dev/null +++ b/test/t/false.rb @@ -0,0 +1,26 @@ +## +# FalseClass ISO Test + +assert('FalseClass', '15.2.6') do + FalseClass.class == Class +end + +assert('FalseClass false', '15.2.6.1') do + not false +end + +assert('FalseClass#&', '15.2.6.3.1') do + not FalseClass.new.&(true) and not FalseClass.new.&(false) +end + +assert('FalseClass#^', '15.2.6.3.2') do + FalseClass.new.^(true) and not FalseClass.new.^(false) +end + +assert('FalseClass#to_s', '15.2.6.3.3') do + FalseClass.new.to_s == 'false' +end + +assert('FalseClass#|', '15.2.6.3.4') do + FalseClass.new.|(true) and not FalseClass.new.|(false) +end diff --git a/test/t/float.rb b/test/t/float.rb index fd87bb04f..fc87a5b22 100644 --- a/test/t/float.rb +++ b/test/t/float.rb @@ -99,4 +99,3 @@ end assert('Float#truncate', '15.2.9.3.15') do 3.123456789.truncate == 3 end - diff --git a/test/t/hash.rb b/test/t/hash.rb index bb2ef1209..af662688a 100644 --- a/test/t/hash.rb +++ b/test/t/hash.rb @@ -224,4 +224,3 @@ assert('Hash#values', '15.2.13.4.28') do a.values == ['abc_value'] end - diff --git a/test/t/indexerror.rb b/test/t/indexerror.rb new file mode 100644 index 000000000..d0cb81f32 --- /dev/null +++ b/test/t/indexerror.rb @@ -0,0 +1,6 @@ +## +# IndexError ISO Test + +assert('IndexError', '15.2.33') do + IndexError.class == Class +end diff --git a/test/t/integer.rb b/test/t/integer.rb index 5e73b41b5..8c112861a 100644 --- a/test/t/integer.rb +++ b/test/t/integer.rb @@ -168,4 +168,3 @@ assert('Integer#upto', '15.2.8.3.27') do end a == 6 end - diff --git a/test/t/kernel.rb b/test/t/kernel.rb new file mode 100644 index 000000000..cd1f2d99e --- /dev/null +++ b/test/t/kernel.rb @@ -0,0 +1,124 @@ +## +# Kernel ISO Test + +assert('Kernel', '15.3.1') do + Kernel.class == Module +end + +assert('Kernel.block_given?', '15.3.1.2.2') do + Kernel.block_given? == false +end + +assert('Kernel.global_variables', '15.3.1.2.4') do + Kernel.global_variables.class == Array +end + +assert('Kernel.iterator?', '15.3.1.2.5') do + Kernel.iterator? == false +end + +assert('Kernel.lambda', '15.3.1.2.6') do + l = Kernel.lambda do + true + end + + l.call and l.class == Proc +end + +assert('Kernel.local_variables', '15.3.1.2.7') do + Kernel.local_variables.class == Array +end + +assert('Kernel.loop', '15.3.1.2.8') do + i = 0 + + Kernel.loop do + i += 1 + break if i == 100 + end + + i == 100 +end + +assert('Kernel.p', '15.3.1.2.9') do + # TODO search for a way to test p to stdio + true +end + +assert('Kernel.print', '15.3.1.2.10') do + # TODO search for a way to test print to stdio + true +end + +assert('Kernel.puts', '15.3.1.2.11') do + # TODO search for a way to test puts to stdio + true +end + +# TODO fails at the moment without arguments +assert('Kernel.raise', '15.3.1.2.12') do + e_list = [] + + begin + raise RuntimeError.new + rescue => e + e_list << e + end + + e_list[0].class == RuntimeError +end + +assert('Kernel#hash', '15.3.1.2.15') do + hash == hash +end + +assert('Kernel#local_variables', '15.3.1.2.28') do + local_variables.class == Array +end + +assert('Kernel#loop', '15.3.1.2.29') do + i = 0 + + loop do + i += 1 + break if i == 100 + end + + i == 100 +end + +assert('Kernel#methods', '15.3.1.2.31') do + methods.class == Array +end + +assert('Kernel#nil?', '15.3.1.2.32') do + # TODO why is Kernel nil ???? + nil? == true +end + +assert('Kernel#private_methods', '15.3.1.2.36') do + private_methods.class == Array +end + +assert('Kernel#protected_methods', '15.3.1.2.37') do + protected_methods.class == Array +end + +assert('Kernel#public_methods', '15.3.1.2.38') do + public_methods.class == Array +end + +assert('Kernel#respond_to?', '15.3.1.2.43') do + respond_to? :nil? +end + +# TODO at the moment doesn't comply to ISO assert('Kernel#send', '15.3.1.2.44') do + +assert('Kernel#singleton_methods', '15.3.1.2.45') do + singleton_methods.class == Array +end + +assert('Kernel#to_s', '15.3.1.2.46') do + # TODO looks strange.. + to_s == '' +end diff --git a/test/t/literals.rb b/test/t/literals.rb new file mode 100644 index 000000000..700c4c846 --- /dev/null +++ b/test/t/literals.rb @@ -0,0 +1,67 @@ +## +# Literals ISO Test + +assert('Literals Numerical', '8.7.6.2') do + # signed and unsigned integer + 1 == 1 and -1 == -1 and +1 == +1 and + # signed and unsigned float + 1.0 == 1.0 and -1.0 == -1.0 and + # binary + 0b10000000 == 128 and 0B10000000 == 128 + # octal + 0o10 == 8 and 0O10 == 8 and 0_10 == 8 + # hex + 0xff == 255 and 0Xff == 255 and + # decimal + 0d999 == 999 and 0D999 == 999 and + # decimal seperator + 10_000_000 == 10000000 and 1_0 == 10 and + # integer with exponent + 1e1 == 10.0 and 1e-1 == 0.1 and 1e+1 == 10.0 + # float with exponent + 1.0e1 == 10.0 and 1.0e-1 == 0.1 and 1.0e+1 == 10.0 +end + +assert('Literals Strings Single Quoted', '8.7.6.3.2') do + 'abc' == 'abc' and '\'' == '\'' and '\\' == '\\' +end + +assert('Literals Strings Double Quoted', '8.7.6.3.3') do + a = "abc" + + "abc" == "abc" and "\"" == "\"" and "\\" == "\\" and + "#{a}" == "abc" +end + +assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do + a = %q{abc} + b = %q(abc) + c = %q[abc] + d = %q<abc> + e = %q/abc/ + f = %q/ab\/c/ + + a == 'abc' and b == 'abc' and c == 'abc' and d == 'abc' and + e == 'abc' and f == 'ab/c' +end + +assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do + a = %Q{abc} + b = %Q(abc) + c = %Q[abc] + d = %Q<abc> + e = %Q/abc/ + f = %Q/ab\/c/ + g = %Q{#{a}} + + a == 'abc' and b == 'abc' and c == 'abc' and d == 'abc' and + e == 'abc' and f == 'ab/c' and g == 'abc' +end + +# Not Implemented ATM assert('Literals Strings Here documents', '8.7.6.3.6') do + +# Not Implemented ATM assert('Literals Array', '8.7.6.4') do + +# Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do + +# Not Implemented ATM assert('Literals Symbol', '8.7.6.6') do diff --git a/test/t/localjumperror.rb b/test/t/localjumperror.rb new file mode 100644 index 000000000..9d1df9594 --- /dev/null +++ b/test/t/localjumperror.rb @@ -0,0 +1,9 @@ +## +# LocalJumpError ISO Test + +assert('LocalJumoError', '15.2.25') do + LocalJumpError.class == Class +end + +# TODO 15.2.25.2.1 LocalJumpError#exit_value +# TODO 15.2.25.2.2 LocalJumpError#reason diff --git a/test/t/module.rb b/test/t/module.rb new file mode 100644 index 000000000..854be75a5 --- /dev/null +++ b/test/t/module.rb @@ -0,0 +1,10 @@ +## +# Module ISO Test + +assert('Module', '15.2.2') do + Module.class == Class +end + +# TODO not implemented ATM assert('Module.constants', '15.2.2') do + +# TODO not implemented ATM assert('Module.nesting', '15.2.2') do diff --git a/test/t/nameerror.rb b/test/t/nameerror.rb new file mode 100644 index 000000000..67451ecf8 --- /dev/null +++ b/test/t/nameerror.rb @@ -0,0 +1,14 @@ +## +# NameError ISO Test + +assert('NameError', '15.2.31') do + NameError.class == Class +end + +# TODO 15.2.31.2.1 NameError#name + +assert('NameError#initialize', '15.2.31.2.2') do + e = NameError.new.initialize('a') + + e.class == NameError and e.message == 'a' +end diff --git a/test/t/nil.rb b/test/t/nil.rb new file mode 100644 index 000000000..3188a9516 --- /dev/null +++ b/test/t/nil.rb @@ -0,0 +1,26 @@ +## +# NilClass ISO Test + +assert('NilClass', '15.2.4') do + NilClass.class == Class +end + +assert('NilClass#&', '15.2.4.3.1') do + not NilClass.new.& and not NilClass.new.&(nil) +end + +assert('NilClass#^', '15.2.4.3.2') do + NilClass.new.^(true) and not NilClass.new.^(false) +end + +assert('NilClass#|', '15.2.4.3.3') do + NilClass.new.|(true) and not NilClass.new.|(false) +end + +assert('NilClass#nil?', '15.2.4.3.4') do + NilClass.new.nil? +end + +assert('NilClass#to_s', '15.2.4.3.5') do + NilClass.new.to_s == '' +end diff --git a/test/t/nomethoderror.rb b/test/t/nomethoderror.rb new file mode 100644 index 000000000..9eb122158 --- /dev/null +++ b/test/t/nomethoderror.rb @@ -0,0 +1,13 @@ +## +# NoMethodError ISO Test + +assert('NoMethodError', '15.2.32') do + e2 = nil + begin + doesNotExistAsAMethodNameForVerySure("") + rescue => e1 + e2 = e1 + end + + NoMethodError.class == Class and e2.class == NoMethodError +end diff --git a/test/t/numeric.rb b/test/t/numeric.rb index 40b5845c0..924889a0e 100644 --- a/test/t/numeric.rb +++ b/test/t/numeric.rb @@ -22,4 +22,3 @@ end assert('Numeric#**') do 2.0**3 == 8.0 end - diff --git a/test/t/object.rb b/test/t/object.rb new file mode 100644 index 000000000..96929031b --- /dev/null +++ b/test/t/object.rb @@ -0,0 +1,6 @@ +## +# Object ISO Test + +assert('Object', '15.2.1') do + Object.class == Class +end diff --git a/test/t/proc.rb b/test/t/proc.rb new file mode 100644 index 000000000..6d98cb40c --- /dev/null +++ b/test/t/proc.rb @@ -0,0 +1,44 @@ +## +# Proc ISO Test + +assert('Proc', '15.2.17') do + Proc.class == Class +end + +assert('Proc.new', '15.2.17.3.1') do + a = nil + + begin + Proc.new + rescue => e + a = e + end + + b = Proc.new {} + + a.class == ArgumentError and b.class == Proc +end + +assert('Proc#[]', '15.2.17.4.1') do + a = 0 + b = Proc.new { a += 1 } + b.[] + + a2 = 0 + b2 = Proc.new { |i| a2 += i } + b2.[](5) + + a == 1 and a2 == 5 +end + +assert('Proc#call', '15.2.17.4.3') do + a = 0 + b = Proc.new { a += 1 } + b.call + + a2 = 0 + b2 = Proc.new { |i| a2 += i } + b2.call(5) + + a == 1 and a2 == 5 +end diff --git a/test/t/range.rb b/test/t/range.rb index 42677e72e..05bac8779 100644 --- a/test/t/range.rb +++ b/test/t/range.rb @@ -62,4 +62,3 @@ assert('Range#member?', '15.2.14.4.11') do a.member?(5) and not a.member?(20) end - diff --git a/test/t/rangeerror.rb b/test/t/rangeerror.rb new file mode 100644 index 000000000..7edb5d2d9 --- /dev/null +++ b/test/t/rangeerror.rb @@ -0,0 +1,6 @@ +## +# RangeError ISO Test + +assert('RangeError', '15.2.26') do + RangeError.class == Class +end diff --git a/test/t/regexperror.rb b/test/t/regexperror.rb new file mode 100644 index 000000000..b8f8c2c1f --- /dev/null +++ b/test/t/regexperror.rb @@ -0,0 +1,4 @@ +## +# RegexpError ISO Test + +# TODO broken ATM assert('RegexpError', '15.2.27') do diff --git a/test/t/runtimeerror.rb b/test/t/runtimeerror.rb new file mode 100644 index 000000000..9157293cd --- /dev/null +++ b/test/t/runtimeerror.rb @@ -0,0 +1,14 @@ +## +# RuntimeError ISO Test + +assert('RuntimeError', '15.2.28') do + e2 = nil + begin + # this will cause an exception due to the wrong location + retry + rescue => e1 + e2 = e1 + end + + RuntimeError.class == Class and e2.class == RuntimeError +end diff --git a/test/t/standarderror.rb b/test/t/standarderror.rb new file mode 100644 index 000000000..550c337c1 --- /dev/null +++ b/test/t/standarderror.rb @@ -0,0 +1,6 @@ +## +# StandardError ISO Test + +assert('StandardError', '15.2.23') do + StandardError.class == Class +end diff --git a/test/t/string.rb b/test/t/string.rb index 7fd48761c..76df18aaf 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -319,4 +319,3 @@ assert('String#upcase!', '15.2.10.5.43') do a == 'ABC' end - diff --git a/test/t/struct.rb b/test/t/struct.rb new file mode 100644 index 000000000..c41319f8a --- /dev/null +++ b/test/t/struct.rb @@ -0,0 +1,6 @@ +## +# Struct ISO Test + +assert('Struct', '15.2.18') do + Struct.class == Class +end diff --git a/test/t/symbol.rb b/test/t/symbol.rb index 325c8d990..e9c310971 100644 --- a/test/t/symbol.rb +++ b/test/t/symbol.rb @@ -20,4 +20,3 @@ end assert('Symbol#to_sym', '15.2.11.3.4') do :abc.to_sym == :abc end - diff --git a/test/t/time.rb b/test/t/time.rb index 9ad0e4aff..22fc2e7c3 100644 --- a/test/t/time.rb +++ b/test/t/time.rb @@ -71,4 +71,3 @@ end assert('Time#new') do Time.new.class == Time end - diff --git a/test/t/true.rb b/test/t/true.rb new file mode 100644 index 000000000..bb648a7cd --- /dev/null +++ b/test/t/true.rb @@ -0,0 +1,26 @@ +## +# TrueClass ISO Test + +assert('TrueClass', '15.2.5') do + TrueClass.class == Class +end + +assert('TrueClass true', '15.2.5.1') do + true +end + +assert('TrueClass#&', '15.2.5.3.1') do + TrueClass.new.&(true) and not TrueClass.new.&(false) +end + +assert('TrueClass#^', '15.2.5.3.2') do + not TrueClass.new.^(true) and TrueClass.new.^(false) +end + +assert('TrueClass#to_s', '15.2.5.3.3') do + TrueClass.new.to_s == 'true' +end + +assert('TrueClass#|', '15.2.5.3.4') do + TrueClass.new.|(true) and TrueClass.new.|(false) +end diff --git a/test/t/typeerror.rb b/test/t/typeerror.rb new file mode 100644 index 000000000..c4434aa24 --- /dev/null +++ b/test/t/typeerror.rb @@ -0,0 +1,6 @@ +## +# TypeError ISO Test + +assert('TypeError', '15.2.29') do + TypeError.class == Class +end |
