Merge pull request #202 from bovi/add-docu

Add Test Cases (Literals, Enumerable, Exceptions, misc)
This commit is contained in:
Yukihiro "Matz" Matsumoto
2012-05-28 15:46:10 -07:00
31 changed files with 126 additions and 33 deletions
+10 -2
View File
@@ -2,6 +2,14 @@
# ArgumentError ISO Test
assert('ArgumentError', '15.2.24') do
ArgumentError.class == Class
end
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
+38 -4
View File
@@ -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
-1
View File
@@ -388,4 +388,3 @@ assert('BS Block [ruby-core:14395]') do
t = Controller.new
t.test_for_bug
end
-1
View File
@@ -36,4 +36,3 @@ end
assert('BS Literal 9') do
Fixnum == 1234.class
end
+29
View File
@@ -72,3 +72,32 @@ assert('Enumerable#min', '15.3.2.2.14') do
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
-1
View File
@@ -24,4 +24,3 @@ end
assert('FalseClass#|', '15.2.6.3.4') do
FalseClass.new.|(true) and not FalseClass.new.|(false)
end
-1
View File
@@ -99,4 +99,3 @@ end
assert('Float#truncate', '15.2.9.3.15') do
3.123456789.truncate == 3
end
-1
View File
@@ -224,4 +224,3 @@ assert('Hash#values', '15.2.13.4.28') do
a.values == ['abc_value']
end
-1
View File
@@ -4,4 +4,3 @@
assert('IndexError', '15.2.33') do
IndexError.class == Class
end
-1
View File
@@ -168,4 +168,3 @@ assert('Integer#upto', '15.2.8.3.27') do
end
a == 6
end
-1
View File
@@ -122,4 +122,3 @@ assert('Kernel#to_s', '15.3.1.2.46') do
# TODO looks strange..
to_s == ''
end
+49
View File
@@ -0,0 +1,49 @@
##
# 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
# creates segmentation fault for now
# '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
#creates segmentation fault for now
#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 = %/abc/
# f = %/ab\/c/
# a == 'abc' and b == 'abc' and c == 'abc' and d == 'abc' and
# e == 'abc' and f 'ab/c'
#end
-1
View File
@@ -7,4 +7,3 @@ end
# TODO 15.2.25.2.1 LocalJumpError#exit_value
# TODO 15.2.25.2.2 LocalJumpError#reason
-1
View File
@@ -8,4 +8,3 @@ end
# TODO not implemented ATM assert('Module.constants', '15.2.2') do
# TODO not implemented ATM assert('Module.nesting', '15.2.2') do
-1
View File
@@ -12,4 +12,3 @@ assert('NameError#initialize', '15.2.31.2.2') do
e.class == NameError and e.message == 'a'
end
-1
View File
@@ -24,4 +24,3 @@ end
assert('NilClass#to_s', '15.2.4.3.5') do
NilClass.new.to_s == ''
end
-1
View File
@@ -11,4 +11,3 @@ assert('NoMethodError', '15.2.32') do
NoMethodError.class == Class and e2.class == NoMethodError
end
-1
View File
@@ -22,4 +22,3 @@ end
assert('Numeric#**') do
2.0**3 == 8.0
end
-1
View File
@@ -4,4 +4,3 @@
assert('Object', '15.2.1') do
Object.class == Class
end
-1
View File
@@ -42,4 +42,3 @@ assert('Proc#call', '15.2.17.4.3') do
a == 1 and a2 == 5
end
-1
View File
@@ -62,4 +62,3 @@ assert('Range#member?', '15.2.14.4.11') do
a.member?(5) and not a.member?(20)
end
-1
View File
@@ -4,4 +4,3 @@
assert('RangeError', '15.2.26') do
RangeError.class == Class
end
-1
View File
@@ -2,4 +2,3 @@
# RegexpError ISO Test
# TODO broken ATM assert('RegexpError', '15.2.27') do
-1
View File
@@ -12,4 +12,3 @@ assert('RuntimeError', '15.2.28') do
RuntimeError.class == Class and e2.class == RuntimeError
end
-1
View File
@@ -4,4 +4,3 @@
assert('StandardError', '15.2.23') do
StandardError.class == Class
end
-1
View File
@@ -319,4 +319,3 @@ assert('String#upcase!', '15.2.10.5.43') do
a == 'ABC'
end
-1
View File
@@ -4,4 +4,3 @@
assert('Struct', '15.2.18') do
Struct.class == Class
end
-1
View File
@@ -20,4 +20,3 @@ end
assert('Symbol#to_sym', '15.2.11.3.4') do
:abc.to_sym == :abc
end
-1
View File
@@ -71,4 +71,3 @@ end
assert('Time#new') do
Time.new.class == Time
end
-1
View File
@@ -24,4 +24,3 @@ end
assert('TrueClass#|', '15.2.5.3.4') do
TrueClass.new.|(true) and TrueClass.new.|(false)
end
-1
View File
@@ -4,4 +4,3 @@
assert('TypeError', '15.2.29') do
TypeError.class == Class
end