Permalink
Browse files

Add Test cases for Literals, Enumeration, Exceptions and clean line e…

…ndings
  • Loading branch information...
1 parent ec3944d commit 31e9705022d585d818a5c869f0f91e4d6b7c252e @bovi bovi committed May 28, 2012
View
@@ -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
View
@@ -22,11 +22,47 @@
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 @@
end
# Not ISO specified
-
-
View
@@ -388,4 +388,3 @@ def respond
t = Controller.new
t.test_for_bug
end
-
View
@@ -36,4 +36,3 @@
assert('BS Literal 9') do
Fixnum == 1234.class
end
-
View
@@ -72,3 +72,32 @@
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
View
@@ -24,4 +24,3 @@
assert('FalseClass#|', '15.2.6.3.4') do
FalseClass.new.|(true) and not FalseClass.new.|(false)
end
-
View
@@ -99,4 +99,3 @@
assert('Float#truncate', '15.2.9.3.15') do
3.123456789.truncate == 3
end
-
View
@@ -224,4 +224,3 @@
a.values == ['abc_value']
end
-
View
@@ -4,4 +4,3 @@
assert('IndexError', '15.2.33') do
IndexError.class == Class
end
-
View
@@ -168,4 +168,3 @@
end
a == 6
end
-
View
@@ -122,4 +122,3 @@
# TODO looks strange..
to_s == ''
end
-
View
@@ -7,4 +7,3 @@
# TODO 15.2.25.2.1 LocalJumpError#exit_value
# TODO 15.2.25.2.2 LocalJumpError#reason
-
View
@@ -8,4 +8,3 @@
# TODO not implemented ATM assert('Module.constants', '15.2.2') do
# TODO not implemented ATM assert('Module.nesting', '15.2.2') do
-
View
@@ -12,4 +12,3 @@
e.class == NameError and e.message == 'a'
end
-
View
@@ -24,4 +24,3 @@
assert('NilClass#to_s', '15.2.4.3.5') do
NilClass.new.to_s == ''
end
-
View
@@ -11,4 +11,3 @@
NoMethodError.class == Class and e2.class == NoMethodError
end
-
View
@@ -22,4 +22,3 @@
assert('Numeric#**') do
2.0**3 == 8.0
end
-
View
@@ -4,4 +4,3 @@
assert('Object', '15.2.1') do
Object.class == Class
end
-
View
@@ -42,4 +42,3 @@
a == 1 and a2 == 5
end
-
View
@@ -62,4 +62,3 @@
a.member?(5) and not a.member?(20)
end
-
View
@@ -4,4 +4,3 @@
assert('RangeError', '15.2.26') do
RangeError.class == Class
end
-
View
@@ -2,4 +2,3 @@
# RegexpError ISO Test
# TODO broken ATM assert('RegexpError', '15.2.27') do
-
View
@@ -12,4 +12,3 @@
RuntimeError.class == Class and e2.class == RuntimeError
end
-
View
@@ -4,4 +4,3 @@
assert('StandardError', '15.2.23') do
StandardError.class == Class
end
-
View
@@ -319,4 +319,3 @@
a == 'ABC'
end
-
View
@@ -4,4 +4,3 @@
assert('Struct', '15.2.18') do
Struct.class == Class
end
-
View
@@ -20,4 +20,3 @@
assert('Symbol#to_sym', '15.2.11.3.4') do
:abc.to_sym == :abc
end
-
View
@@ -71,4 +71,3 @@
assert('Time#new') do
Time.new.class == Time
end
-
View
@@ -24,4 +24,3 @@
assert('TrueClass#|', '15.2.5.3.4') do
TrueClass.new.|(true) and TrueClass.new.|(false)
end
-
View
@@ -4,4 +4,3 @@
assert('TypeError', '15.2.29') do
TypeError.class == Class
end
-

0 comments on commit 31e9705

Please sign in to comment.