Commit 124fd73c authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

resolve conflict

parents ef5087bc d8c8893e
...@@ -62,7 +62,7 @@ def assert(str = 'Assertion failed', iso = '') ...@@ -62,7 +62,7 @@ def assert(str = 'Assertion failed', iso = '')
$asserts.push(assertion_string('Error: ', str, iso, e)) $asserts.push(assertion_string('Error: ', str, iso, e))
$kill_test += 1 $kill_test += 1
t_print('X') t_print('X')
end end
ensure ensure
$mrbtest_assert = nil $mrbtest_assert = nil
end end
......
...@@ -2,36 +2,36 @@ ...@@ -2,36 +2,36 @@
# Hash ISO Test # Hash ISO Test
assert('Hash', '15.2.13') do assert('Hash', '15.2.13') do
Hash.class == Class assert_equal Hash.class, Class
end end
assert('Hash superclass', '15.2.13.2') do assert('Hash superclass', '15.2.13.2') do
Hash.superclass == Object assert_equal Hash.superclass, Object
end end
assert('Hash#==', '15.2.13.4.1') do assert('Hash#==', '15.2.13.4.1') do
({ 'abc' => 'abc' } == { 'abc' => 'abc' }) and assert_true({ 'abc' => 'abc' } == { 'abc' => 'abc' })
not ({ 'abc' => 'abc' } == { 'cba' => 'cba' }) assert_false({ 'abc' => 'abc' } == { 'cba' => 'cba' })
end end
assert('Hash#[]', '15.2.13.4.2') do assert('Hash#[]', '15.2.13.4.2') do
a = { 'abc' => 'abc' } a = { 'abc' => 'abc' }
a['abc'] == 'abc' assert_equal a['abc'], 'abc'
end end
assert('Hash#[]=', '15.2.13.4.3') do assert('Hash#[]=', '15.2.13.4.3') do
a = Hash.new a = Hash.new
a['abc'] = 'abc' a['abc'] = 'abc'
a['abc'] == 'abc' assert_equal a['abc'], 'abc'
end end
assert('Hash#clear', '15.2.13.4.4') do assert('Hash#clear', '15.2.13.4.4') do
a = { 'abc' => 'abc' } a = { 'abc' => 'abc' }
a.clear a.clear
a == { } assert_equal a, { }
end end
assert('Hash#default', '15.2.13.4.5') do assert('Hash#default', '15.2.13.4.5') do
...@@ -39,15 +39,18 @@ assert('Hash#default', '15.2.13.4.5') do ...@@ -39,15 +39,18 @@ assert('Hash#default', '15.2.13.4.5') do
b = Hash.new('abc') b = Hash.new('abc')
c = Hash.new {|s,k| s[k] = k} c = Hash.new {|s,k| s[k] = k}
a.default == nil and b.default == 'abc' and assert_nil a.default
c.default == nil and c.default('abc') == 'abc' assert_equal b.default, 'abc'
assert_nil c.default
assert_equal c.default('abc'), 'abc'
end end
assert('Hash#default=', '15.2.13.4.6') do assert('Hash#default=', '15.2.13.4.6') do
a = { 'abc' => 'abc' } a = { 'abc' => 'abc' }
a.default = 'cba' a.default = 'cba'
a['abc'] == 'abc' and a['notexist'] == 'cba' assert_equal a['abc'], 'abc'
assert_equal a['notexist'], 'cba'
end end
assert('Hash#default_proc', '15.2.13.4.7') do assert('Hash#default_proc', '15.2.13.4.7') do
...@@ -56,8 +59,10 @@ assert('Hash#default_proc', '15.2.13.4.7') do ...@@ -56,8 +59,10 @@ assert('Hash#default_proc', '15.2.13.4.7') do
c = b[2] c = b[2]
d = b['cat'] d = b['cat']
a.default_proc == nil and b.default_proc.class == Proc and assert_nil a.default_proc
c = 4 and d = 'catcat' assert_equal b.default_proc.class, Proc
assert_equal c, 4
assert_equal d, 'catcat'
end end
assert('Hash#delete', '15.2.13.4.8') do assert('Hash#delete', '15.2.13.4.8') do
...@@ -74,8 +79,10 @@ assert('Hash#delete', '15.2.13.4.8') do ...@@ -74,8 +79,10 @@ assert('Hash#delete', '15.2.13.4.8') do
b_tmp_2 = true b_tmp_2 = true
end end
a.delete('cba') == nil and not a.has_key?('abc') and assert_nil a.delete('cba')
not b_tmp_1 and b_tmp_2 assert_false a.has_key?('abc')
assert_false b_tmp_1
assert_true b_tmp_2
end end
assert('Hash#each', '15.2.13.4.9') do assert('Hash#each', '15.2.13.4.9') do
...@@ -88,7 +95,8 @@ assert('Hash#each', '15.2.13.4.9') do ...@@ -88,7 +95,8 @@ assert('Hash#each', '15.2.13.4.9') do
value = v value = v
end end
key == 'abc_key' and value == 'abc_value' assert_equal key, 'abc_key'
assert_equal value, 'abc_value'
end end
assert('Hash#each_key', '15.2.13.4.10') do assert('Hash#each_key', '15.2.13.4.10') do
...@@ -99,7 +107,7 @@ assert('Hash#each_key', '15.2.13.4.10') do ...@@ -99,7 +107,7 @@ assert('Hash#each_key', '15.2.13.4.10') do
key = k key = k
end end
key == 'abc_key' assert_equal key, 'abc_key'
end end
assert('Hash#each_value', '15.2.13.4.11') do assert('Hash#each_value', '15.2.13.4.11') do
...@@ -110,35 +118,39 @@ assert('Hash#each_value', '15.2.13.4.11') do ...@@ -110,35 +118,39 @@ assert('Hash#each_value', '15.2.13.4.11') do
value = v value = v
end end
value == 'abc_value' assert_equal value, 'abc_value'
end end
assert('Hash#empty?', '15.2.13.4.12') do assert('Hash#empty?', '15.2.13.4.12') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
not a.empty? and b.empty? assert_false a.empty?
assert_true b.empty?
end end
assert('Hash#has_key?', '15.2.13.4.13') do assert('Hash#has_key?', '15.2.13.4.13') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.has_key?('abc_key') and not b.has_key?('cba') assert_true a.has_key?('abc_key')
assert_false b.has_key?('cba')
end end
assert('Hash#has_value?', '15.2.13.4.14') do assert('Hash#has_value?', '15.2.13.4.14') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.has_value?('abc_value') and not b.has_value?('cba') assert_true a.has_value?('abc_value')
assert_false b.has_value?('cba')
end end
assert('Hash#include?', '15.2.13.4.15') do assert('Hash#include?', '15.2.13.4.15') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.include?('abc_key') and not b.include?('cba') assert_true a.include?('abc_key')
assert_false b.include?('cba')
end end
assert('Hash#initialize', '15.2.13.4.16') do assert('Hash#initialize', '15.2.13.4.16') do
...@@ -146,44 +158,47 @@ assert('Hash#initialize', '15.2.13.4.16') do ...@@ -146,44 +158,47 @@ assert('Hash#initialize', '15.2.13.4.16') do
h = Hash.new h = Hash.new
h2 = Hash.new(:not_found) h2 = Hash.new(:not_found)
h.is_a? Hash and assert_true h.is_a? Hash
h == { } and assert_equal h, { }
h["hello"] == nil and assert_nil h["hello"]
h2["hello"] == :not_found assert_equal h2["hello"], :not_found
end end
assert('Hash#initialize_copy', '15.2.13.4.17') do assert('Hash#initialize_copy', '15.2.13.4.17') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new.initialize_copy(a) b = Hash.new.initialize_copy(a)
b == { 'abc_key' => 'abc_value' } assert_equal b, { 'abc_key' => 'abc_value' }
end end
assert('Hash#key?', '15.2.13.4.18') do assert('Hash#key?', '15.2.13.4.18') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.key?('abc_key') and not b.key?('cba') assert_true a.key?('abc_key')
assert_false b.key?('cba')
end end
assert('Hash#keys', '15.2.13.4.19') do assert('Hash#keys', '15.2.13.4.19') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
a.keys == ['abc_key'] assert_equal a.keys, ['abc_key']
end end
assert('Hash#length', '15.2.13.4.20') do assert('Hash#length', '15.2.13.4.20') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.length == 1 and b.length == 0 assert_equal a.length, 1
assert_equal b.length, 0
end end
assert('Hash#member?', '15.2.13.4.21') do assert('Hash#member?', '15.2.13.4.21') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.member?('abc_key') and not b.member?('cba') assert_true a.member?('abc_key')
assert_false b.member?('cba')
end end
assert('Hash#merge', '15.2.13.4.22') do assert('Hash#merge', '15.2.13.4.22') do
...@@ -195,9 +210,9 @@ assert('Hash#merge', '15.2.13.4.22') do ...@@ -195,9 +210,9 @@ assert('Hash#merge', '15.2.13.4.22') do
original original
end end
result_1 == {'abc_key' => 'abc_value', 'cba_key' => 'XXX', assert_equal result_1, {'abc_key' => 'abc_value', 'cba_key' => 'XXX',
'xyz_key' => 'xyz_value' } and 'xyz_key' => 'xyz_value' }
result_2 == {'abc_key' => 'abc_value', 'cba_key' => 'cba_value', assert_equal result_2, {'abc_key' => 'abc_value', 'cba_key' => 'cba_value',
'xyz_key' => 'xyz_value' } 'xyz_key' => 'xyz_value' }
end end
...@@ -205,42 +220,44 @@ assert('Hash#replace', '15.2.13.4.23') do ...@@ -205,42 +220,44 @@ assert('Hash#replace', '15.2.13.4.23') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new.replace(a) b = Hash.new.replace(a)
b == { 'abc_key' => 'abc_value' } assert_equal b, { 'abc_key' => 'abc_value' }
end end
assert('Hash#shift', '15.2.13.4.24') do assert('Hash#shift', '15.2.13.4.24') do
a = { 'abc_key' => 'abc_value', 'cba_key' => 'cba_value' } a = { 'abc_key' => 'abc_value', 'cba_key' => 'cba_value' }
b = a.shift b = a.shift
a == { 'abc_key' => 'abc_value' } and assert_equal a, { 'abc_key' => 'abc_value' }
b == [ 'cba_key', 'cba_value' ] assert_equal b, [ 'cba_key', 'cba_value' ]
end end
assert('Hash#size', '15.2.13.4.25') do assert('Hash#size', '15.2.13.4.25') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.size == 1 and b.size == 0 assert_equal a.size, 1
assert_equal b.size, 0
end end
assert('Hash#store', '15.2.13.4.26') do assert('Hash#store', '15.2.13.4.26') do
a = Hash.new a = Hash.new
a.store('abc', 'abc') a.store('abc', 'abc')
a['abc'] == 'abc' assert_equal a['abc'], 'abc'
end end
assert('Hash#value?', '15.2.13.4.27') do assert('Hash#value?', '15.2.13.4.27') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new b = Hash.new
a.value?('abc_value') and not b.value?('cba') assert_true a.value?('abc_value')
assert_false b.value?('cba')
end end
assert('Hash#values', '15.2.13.4.28') do assert('Hash#values', '15.2.13.4.28') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
a.values == ['abc_value'] assert_equal a.values, ['abc_value']
end end
# Not ISO specified # Not ISO specified
...@@ -250,8 +267,8 @@ assert('Hash#reject') do ...@@ -250,8 +267,8 @@ assert('Hash#reject') do
ret = h.reject do |k,v| ret = h.reject do |k,v|
v % 2 == 0 v % 2 == 0
end end
ret == {:one => 1, :three => 3} and assert_equal ret, {:one => 1, :three => 3}
h == {:one => 1, :two => 2, :three => 3, :four => 4} assert_equal h, {:one => 1, :two => 2, :three => 3, :four => 4}
end end
assert('Hash#reject!') do assert('Hash#reject!') do
...@@ -259,8 +276,8 @@ assert('Hash#reject!') do ...@@ -259,8 +276,8 @@ assert('Hash#reject!') do
ret = h.reject! do |k,v| ret = h.reject! do |k,v|
v % 2 == 0 v % 2 == 0
end end
ret == {:one => 1, :three => 3} and assert_equal ret, {:one => 1, :three => 3}
h == {:one => 1, :three => 3} assert_equal h, {:one => 1, :three => 3}
end end
assert('Hash#select') do assert('Hash#select') do
...@@ -268,8 +285,8 @@ assert('Hash#select') do ...@@ -268,8 +285,8 @@ assert('Hash#select') do
ret = h.select do |k,v| ret = h.select do |k,v|
v % 2 == 0 v % 2 == 0
end end
ret == {:two => 2, :four => 4} and assert_equal ret, {:two => 2, :four => 4}
h == {:one => 1, :two => 2, :three => 3, :four => 4} assert_equal h, {:one => 1, :two => 2, :three => 3, :four => 4}
end end
assert('Hash#select!') do assert('Hash#select!') do
...@@ -277,8 +294,8 @@ assert('Hash#select!') do ...@@ -277,8 +294,8 @@ assert('Hash#select!') do
ret = h.select! do |k,v| ret = h.select! do |k,v|
v % 2 == 0 v % 2 == 0
end end
ret == {:two => 2, :four => 4} and assert_equal ret, {:two => 2, :four => 4}
h == {:two => 2, :four => 4} assert_equal h, {:two => 2, :four => 4}
end end
# Not ISO specified # Not ISO specified
...@@ -287,5 +304,7 @@ assert('Hash#inspect') do ...@@ -287,5 +304,7 @@ assert('Hash#inspect') do
h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
ret = h.to_s ret = h.to_s
ret = "{\"c\"=>300, \"a\"=>100, \"d\"=>400}" assert_include ret, '"c"=>300'
assert_include ret, '"a"=>100'
assert_include ret, '"d"=>400'
end end
...@@ -2,39 +2,43 @@ ...@@ -2,39 +2,43 @@
# Integer ISO Test # Integer ISO Test
assert('Integer', '15.2.8') do assert('Integer', '15.2.8') do
Integer.class == Class assert_equal Integer.class, Class
end end
assert('Integer superclass', '15.2.8.2') do assert('Integer superclass', '15.2.8.2') do
Integer.superclass == Numeric assert_equal Integer.superclass, Numeric
end end
assert('Integer#+', '15.2.8.3.1') do assert('Integer#+', '15.2.8.3.1') do
a = 1+1 a = 1+1
b = 1+1.0 b = 1+1.0
a == 2 and b == 2.0 assert_equal a, 2
assert_equal b, 2.0
end end
assert('Integer#-', '15.2.8.3.2') do assert('Integer#-', '15.2.8.3.2') do
a = 2-1 a = 2-1
b = 2-1.0 b = 2-1.0
a == 1 and b == 1.0 assert_equal a, 1
assert_equal b, 1.0
end end
assert('Integer#*', '15.2.8.3.3') do assert('Integer#*', '15.2.8.3.3') do
a = 1*1 a = 1*1
b = 1*1.0 b = 1*1.0
a == 1 and b == 1.0 assert_equal a, 1
assert_equal b, 1.0
end end
assert('Integer#/', '15.2.8.3.4') do assert('Integer#/', '15.2.8.3.4') do
a = 2/1 a = 2/1
b = 2/1.0 b = 2/1.0
a == 2 and b == 2.0 assert_equal a, 2
assert_equal b, 2.0
end end
assert('Integer#%', '15.2.8.3.5') do assert('Integer#%', '15.2.8.3.5') do
...@@ -42,7 +46,9 @@ assert('Integer#%', '15.2.8.3.5') do ...@@ -42,7 +46,9 @@ assert('Integer#%', '15.2.8.3.5') do
b = 1%1.0 b = 1%1.0
c = 2%4 c = 2%4
a == 0 and b == 0.0 and c == 2 assert_equal a, 0
assert_equal b, 0.0
assert_equal c, 2
end end
assert('Integer#<=>', '15.2.8.3.6') do assert('Integer#<=>', '15.2.8.3.6') do
...@@ -50,19 +56,23 @@ assert('Integer#<=>', '15.2.8.3.6') do ...@@ -50,19 +56,23 @@ assert('Integer#<=>', '15.2.8.3.6') do
b = 1<=>1 b = 1<=>1
c = 1<=>2 c = 1<=>2
a == 1 and b == 0 and c == -1 assert_equal a, 1
assert_equal b, 0
assert_equal c, -1
end end
assert('Integer#==', '15.2.8.3.7') do assert('Integer#==', '15.2.8.3.7') do
a = 1==0 a = 1==0
b = 1==1 b = 1==1
a == false and b == true assert_false a
assert_true b
end end
assert('Integer#~', '15.2.8.3.8') do assert('Integer#~', '15.2.8.3.8') do
# Complement # Complement
~0 == -1 and ~2 == -3 assert_equal ~0, -1
assert_equal ~2, -3
end end
assert('Integer#&', '15.2.8.3.9') do assert('Integer#&', '15.2.8.3.9') do
...@@ -70,7 +80,7 @@ assert('Integer#&', '15.2.8.3.9') do ...@@ -70,7 +80,7 @@ assert('Integer#&', '15.2.8.3.9') do
# 0101 (5) # 0101 (5)
# & 0011 (3) # & 0011 (3)
# = 0001 (1) # = 0001 (1)
5 & 3 == 1 assert_equal 5 & 3, 1
end end
assert('Integer#|', '15.2.8.3.10') do assert('Integer#|', '15.2.8.3.10') do
...@@ -78,7 +88,7 @@ assert('Integer#|', '15.2.8.3.10') do ...@@ -78,7 +88,7 @@ assert('Integer#|', '15.2.8.3.10') do
# 0101 (5) # 0101 (5)
# | 0011 (3) # | 0011 (3)
# = 0111 (7) # = 0111 (7)
5 | 3 == 7 assert_equal 5 | 3, 7
end end
assert('Integer#^', '15.2.8.3.11') do assert('Integer#^', '15.2.8.3.11') do
...@@ -86,25 +96,25 @@ assert('Integer#^', '15.2.8.3.11') do ...@@ -86,25 +96,25 @@ assert('Integer#^', '15.2.8.3.11') do
# 0101 (5) # 0101 (5)
# ^ 0011 (3) # ^ 0011 (3)
# = 0110 (6) # = 0110 (6)
5 ^ 3 == 6 assert_equal 5 ^ 3, 6
end end
assert('Integer#<<', '15.2.8.3.12') do assert('Integer#<<', '15.2.8.3.12') do
# Left Shift by one # Left Shift by one
# 00010111 (23) # 00010111 (23)
# = 00101110 (46) # = 00101110 (46)
23 << 1 == 46 assert_equal 23 << 1, 46
end end
assert('Integer#>>', '15.2.8.3.13') do assert('Integer#>>', '15.2.8.3.13') do
# Right Shift by one # Right Shift by one
# 00101110 (46) # 00101110 (46)
# = 00010111 (23) # = 00010111 (23)
46 >> 1 == 23 assert_equal 46 >> 1, 23
end end
assert('Integer#ceil', '15.2.8.3.14') do assert('Integer#ceil', '15.2.8.3.14') do
10.ceil == 10 assert_equal 10.ceil, 10
end end
assert('Integer#downto', '15.2.8.3.15') do assert('Integer#downto', '15.2.8.3.15') do
...@@ -112,7 +122,7 @@ assert('Integer#downto', '15.2.8.3.15') do ...@@ -112,7 +122,7 @@ assert('Integer#downto', '15.2.8.3.15') do
3.downto(1) do |i| 3.downto(1) do |i|
a += i a += i
end end
a == 6 assert_equal a, 6
end end
assert('Integer#eql?', '15.2.8.3.16') do assert('Integer#eql?', '15.2.8.3.16') do
...@@ -120,25 +130,27 @@ assert('Integer#eql?', '15.2.8.3.16') do ...@@ -120,25 +130,27 @@ assert('Integer#eql?', '15.2.8.3.16') do
b = 1.eql?(2) b = 1.eql?(2)
c = 1.eql?(nil) c = 1.eql?(nil)
a == true and b == false and c == false assert_true a
assert_false b
assert_false c
end end
assert('Integer#floor', '15.2.8.3.17') do assert('Integer#floor', '15.2.8.3.17') do
a = 1.floor a = 1.floor
a == 1 assert_equal a, 1
end end
assert('Integer#next', '15.2.8.3.19') do assert('Integer#next', '15.2.8.3.19') do
1.next == 2 assert_equal 1.next, 2
end end
assert('Integer#round', '15.2.8.3.20') do assert('Integer#round', '15.2.8.3.20') do
1.round == 1 assert_equal 1.round, 1
end end
assert('Integer#succ', '15.2.8.3.21') do assert('Integer#succ', '15.2.8.3.21') do
1.succ == 2 assert_equal 1.succ, 2
end end
assert('Integer#times', '15.2.8.3.22') do assert('Integer#times', '15.2.8.3.22') do
...@@ -146,23 +158,24 @@ assert('Integer#times', '15.2.8.3.22') do ...@@ -146,23 +158,24 @@ assert('Integer#times', '15.2.8.3.22') do
3.times do 3.times do
a += 1 a += 1
end end
a == 3 assert_equal a, 3
end end
assert('Integer#to_f', '15.2.8.3.23') do assert('Integer#to_f', '15.2.8.3.23') do
1.to_f == 1.0 assert_equal 1.to_f, 1.0
end end
assert('Integer#to_i', '15.2.8.3.24') do assert('Integer#to_i', '15.2.8.3.24') do
1.to_i == 1 assert_equal 1.to_i, 1
end end
assert('Integer#to_s', '15.2.8.3.25') do assert('Integer#to_s', '15.2.8.3.25') do
1.to_s == '1' and -1.to_s == "-1" assert_equal 1.to_s, '1'
assert_equal(-1.to_s, "-1")
end end
assert('Integer#truncate', '15.2.8.3.26') do assert('Integer#truncate', '15.2.8.3.26') do
1.truncate == 1 assert_equal 1.truncate, 1
end end
assert('Integer#upto', '15.2.8.3.27') do assert('Integer#upto', '15.2.8.3.27') do
...@@ -170,7 +183,7 @@ assert('Integer#upto', '15.2.8.3.27') do ...@@ -170,7 +183,7 @@ assert('Integer#upto', '15.2.8.3.27') do
1.upto(3) do |i| 1.upto(3) do |i|
a += i a += i
end end
a == 6 assert_equal a, 6
end end
# Not ISO specified # Not ISO specified
...@@ -185,6 +198,6 @@ assert('Integer#step') do ...@@ -185,6 +198,6 @@ assert('Integer#step') do
b << i b << i
end end
a == [1, 2, 3] and assert_equal a, [1, 2, 3]
b == [1, 3, 5] assert_equal b, [1, 3, 5]
end end
This diff is collapsed.
...@@ -3,34 +3,51 @@ ...@@ -3,34 +3,51 @@
assert('Literals Numerical', '8.7.6.2') do assert('Literals Numerical', '8.7.6.2') do
# signed and unsigned integer # signed and unsigned integer
1 == 1 and -1 == -1 and +1 == +1 and assert_equal 1, 1
# signed and unsigned float assert_equal(-1, -1)
1.0 == 1.0 and -1.0 == -1.0 and assert_equal(+1, +1)
# binary # signed and unsigned float
0b10000000 == 128 and 0B10000000 == 128 assert_equal 1.0, 1.0
# octal assert_equal(-1.0, -1.0)
0o10 == 8 and 0O10 == 8 and 0_10 == 8 # binary
# hex assert_equal 0b10000000, 128
0xff == 255 and 0Xff == 255 and assert_equal 0B10000000, 128
# decimal # octal
0d999 == 999 and 0D999 == 999 and assert_equal 0o10, 8
# decimal separator assert_equal 0O10, 8
10_000_000 == 10000000 and 1_0 == 10 and assert_equal 0_10, 8
# integer with exponent # hex
1e1 == 10.0 and 1e-1 == 0.1 and 1e+1 == 10.0 assert_equal 0xff, 255
# float with exponent assert_equal 0Xff, 255
1.0e1 == 10.0 and 1.0e-1 == 0.1 and 1.0e+1 == 10.0 # decimal
assert_equal 0d999, 999
assert_equal 0D999, 999
# decimal seperator
assert_equal 10_000_000, 10000000
assert_equal 1_0, 10
# integer with exponent
assert_equal 1e1, 10.0
assert_equal 1e-1, 0.1
assert_equal 1e+1, 10.0
# float with exponent
assert_equal 1.0e1, 10.0
assert_equal 1.0e-1, 0.1
assert_equal 1.0e+1, 10.0
end end
assert('Literals Strings Single Quoted', '8.7.6.3.2') do assert('Literals Strings Single Quoted', '8.7.6.3.2') do
'abc' == 'abc' and '\'' == '\'' and '\\' == '\\' assert_equal 'abc', 'abc'
assert_equal '\'', '\''
assert_equal '\\', '\\'
end end
assert('Literals Strings Double Quoted', '8.7.6.3.3') do assert('Literals Strings Double Quoted', '8.7.6.3.3') do
a = "abc" a = "abc"
"abc" == "abc" and "\"" == "\"" and "\\" == "\\" and assert_equal "abc", "abc"
"#{a}" == "abc" assert_equal "\"", "\""
assert_equal "\\", "\\"
assert_equal "#{a}", "abc"
end end
assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do
...@@ -42,8 +59,13 @@ assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do ...@@ -42,8 +59,13 @@ assert('Literals Strings Quoted Non-Expanded', '8.7.6.3.4') do
f = %q/ab\/c/ f = %q/ab\/c/
g = %q{#{a}} g = %q{#{a}}
a == 'abc' and b == 'abc' and c == 'abc' and d == 'abc' and assert_equal a, 'abc'
e == 'abc' and f == 'ab/c' and g == '#{a}' assert_equal b, 'abc'
assert_equal c, 'abc'
assert_equal d, 'abc'
assert_equal e, 'abc'
assert_equal f, 'ab/c'
assert_equal g, '#{a}'
end end
assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do
...@@ -55,8 +77,13 @@ assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do ...@@ -55,8 +77,13 @@ assert('Literals Strings Quoted Expanded', '8.7.6.3.5') do
f = %Q/ab\/c/ f = %Q/ab\/c/
g = %Q{#{a}} g = %Q{#{a}}
a == 'abc' and b == 'abc' and c == 'abc' and d == 'abc' and assert_equal a, 'abc'
e == 'abc' and f == 'ab/c' and g == 'abc' assert_equal b, 'abc'
assert_equal c, 'abc'
assert_equal d, 'abc'
assert_equal e, 'abc'
assert_equal f, 'ab/c'
assert_equal g, 'abc'
end end
assert('Literals Strings Here documents', '8.7.6.3.6') do assert('Literals Strings Here documents', '8.7.6.3.6') do
...@@ -114,18 +141,18 @@ KKK ...@@ -114,18 +141,18 @@ KKK
z = <<'ZZZ' z = <<'ZZZ'
ZZZ ZZZ
a == "aaa\n" and assert_equal a, "aaa\n"
b == "bbb\n" and assert_equal b, "bbb\n"
c == ["c1\n", "c 2\n", "c 3\n"] and assert_equal c, ["c1\n", "c 2\n", "c 3\n"]
d == "d3DDD\nd\t\nDDD\n\n" and assert_equal d, "d3DDD\nd\t\nDDD\n\n"
e == "e\#{1+2}EEE\ne\\t\nEEE\\n\n" and assert_equal e, "e\#{1+2}EEE\ne\\t\nEEE\\n\n"
f == "F\nFFfFFF\nF\n" and assert_equal f, "F\nFFfFFF\nF\n"
g == " ggg\n" and assert_equal g, " ggg\n"
h == " hhh\n" and assert_equal h, " hhh\n"
i == " iii\n" and assert_equal i, " iii\n"
j == [" j1j\n", " j2j\n", " j\#{3}j\n"] and assert_equal j, [" j1j\n", " j2j\n", " j\#{3}j\n"]
k == 123 and assert_equal k, 123
z == "" assert_equal z, ""
end end
assert('Literals Array', '8.7.6.4') do assert('Literals Array', '8.7.6.4') do
...@@ -146,15 +173,14 @@ assert('Literals Array', '8.7.6.4') do ...@@ -146,15 +173,14 @@ assert('Literals Array', '8.7.6.4') do
d d
x\y x\\y x\\\y) x\y x\\y x\\\y)
test1 = (a == ['abc3def', '}g'] and assert_equal a, ['abc3def', '}g']
b == ['abc', '5', 'def', '(g'] and assert_equal b, ['abc', '5', 'def', '(g']
c == ['7'] and assert_equal c, ['7']
d == ['9'] and assert_equal d, ['9']
e == [] and assert_equal e, []
f == ['[ab', 'cd][ef]'] and assert_equal f, ['[ab', 'cd][ef]']
g == ['ab', '-11', '22'] and assert_equal g, ['ab', '-11', '22']
h == ["a\nb", 'test abc', "c\nd", "xy", "x\\y", "x\\y"] assert_equal h, ["a\nb", 'test abc', "c\nd", "xy", "x\\y", "x\\y"]
)
a = %w{abc#{1+2}def \}g} a = %w{abc#{1+2}def \}g}
b = %w(abc #{2+3} def \(g) b = %w(abc #{2+3} def \(g)
...@@ -173,17 +199,14 @@ d ...@@ -173,17 +199,14 @@ d
d d
x\y x\\y x\\\y) x\y x\\y x\\\y)
test2 = (a == ['abc#{1+2}def', '}g'] and assert_equal a, ['abc#{1+2}def', '}g']
b == ['abc', '#{2+3}', 'def', '(g'] and assert_equal b, ['abc', '#{2+3}', 'def', '(g']
c == ['#{3+4}'] and assert_equal c, ['#{3+4}']
d == ['#{4+5}'] and assert_equal d, ['#{4+5}']
e == [] and assert_equal e, []
f == ['[ab', 'cd][ef]'] and assert_equal f, ['[ab', 'cd][ef]']
g == ['ab', '#{-1}1', '2#{2}'] and assert_equal g, ['ab', '#{-1}1', '2#{2}']
h == ["a\\nb", "test abc", "c\nd", "x\\y", "x\\y", "x\\\\y"] assert_equal h, ["a\\nb", "test abc", "c\nd", "x\\y", "x\\y", "x\\\\y"]
)
test1 and test2
end end
assert('Literals Array of symbols') do assert('Literals Array of symbols') do
...@@ -199,14 +222,13 @@ assert('Literals Array of symbols') do ...@@ -199,14 +222,13 @@ assert('Literals Array of symbols') do
2#{2} 2#{2}
} }
test1 = (a == [:'abc3def', :'}g'] and assert_equal a, [:'abc3def', :'}g']
b == [:'abc', :'5', :'def', :'(g'] and assert_equal b, [:'abc', :'5', :'def', :'(g']
c == [:'7'] and assert_equal c, [:'7']
d == [:'9'] and assert_equal d, [:'9']
e == [] and assert_equal e, []
f == [:'[ab', :'cd][ef]'] and assert_equal f, [:'[ab', :'cd][ef]']
g == [:'ab', :'-11', :'22'] assert_equal g, [:'ab', :'-11', :'22']
)
a = %i{abc#{1+2}def \}g} a = %i{abc#{1+2}def \}g}
b = %i(abc #{2+3} def \(g) b = %i(abc #{2+3} def \(g)
...@@ -220,16 +242,13 @@ assert('Literals Array of symbols') do ...@@ -220,16 +242,13 @@ assert('Literals Array of symbols') do
2#{2} 2#{2}
} }
test2 = (a == [:'abc#{1+2}def', :'}g'] and assert_equal a, [:'abc#{1+2}def', :'}g']
b == [:'abc', :'#{2+3}', :'def', :'(g'] and assert_equal b, [:'abc', :'#{2+3}', :'def', :'(g']
c == [:'#{3+4}'] and assert_equal c, [:'#{3+4}']
d == [:'#{4+5}'] and assert_equal d, [:'#{4+5}']
e == [] and assert_equal e, []
f == [:'[ab', :'cd][ef]'] and assert_equal f, [:'[ab', :'cd][ef]']
g == [:'ab', :'#{-1}1', :'2#{2}'] assert_equal g, [:'ab', :'#{-1}1', :'2#{2}']
)
test1 and test2
end end
assert('Literals Symbol', '8.7.6.6') do assert('Literals Symbol', '8.7.6.6') do
...@@ -255,10 +274,14 @@ qwe] ...@@ -255,10 +274,14 @@ qwe]
g = %s/foo#{1+2}bar/ g = %s/foo#{1+2}bar/
h = %s{{foo bar}} h = %s{{foo bar}}
a == :'asd qwe' and b == :"foo bar" and c == :a3b and d == :asd and assert_equal a, :'asd qwe'
e == :' foo )' and f == :"asd [\nqwe" and g == :'foo#{1+2}bar' and assert_equal b, :"foo bar"
h == :'{foo bar}' assert_equal c, :a3b
assert_equal d, :asd
assert_equal e, :' foo )'
assert_equal f, :"asd [\nqwe"
assert_equal g, :'foo#{1+2}bar'
assert_equal h, :'{foo bar}'
end end
# Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do # Not Implemented ATM assert('Literals Regular expression', '8.7.6.5') do
This diff is collapsed.
...@@ -2,66 +2,73 @@ ...@@ -2,66 +2,73 @@
# Range ISO Test # Range ISO Test
assert('Range', '15.2.14') do assert('Range', '15.2.14') do
Range.class == Class assert_equal Range.class, Class
end end
assert('Range superclass', '15.2.14.2') do assert('Range superclass', '15.2.14.2') do
Range.superclass == Object assert_equal Range.superclass, Object
end end
assert('Range#==', '15.2.14.4.1') do assert('Range#==', '15.2.14.4.1') do
(1..10) == (1..10) and not (1..10) == (1..100) assert_true (1..10) == (1..10)
assert_false (1..10) == (1..100)
end end
assert('Range#===', '15.2.14.4.2') do assert('Range#===', '15.2.14.4.2') do
a = (1..10) a = (1..10)
a === 5 and not a === 20 assert_true a === 5
assert_false a === 20
end end
assert('Range#begin', '15.2.14.4.3') do assert('Range#begin', '15.2.14.4.3') do
(1..10).begin == 1 assert_equal (1..10).begin, 1
end end
assert('Range#each', '15.2.14.4.4') do assert('Range#each', '15.2.14.4.4') do
a = (1..3) a = (1..3)
b = 0 b = 0
a.each {|i| b += i} a.each {|i| b += i}
b == 6 assert_equal b, 6
end end
assert('Range#end', '15.2.14.4.5') do assert('Range#end', '15.2.14.4.5') do
(1..10).end == 10 assert_equal (1..10).end, 10
end end
assert('Range#exclude_end?', '15.2.14.4.6') do assert('Range#exclude_end?', '15.2.14.4.6') do
(1...10).exclude_end? and not (1..10).exclude_end? assert_true (1...10).exclude_end?
assert_false (1..10).exclude_end?
end end
assert('Range#first', '15.2.14.4.7') do assert('Range#first', '15.2.14.4.7') do
(1..10).first == 1 assert_equal (1..10).first, 1
end end
assert('Range#include', '15.2.14.4.8') do assert('Range#include', '15.2.14.4.8') do
a = (1..10) a = (1..10)
a.include?(5) and not a.include?(20) assert_true a.include?(5)
assert_false a.include?(20)
end end
assert('Range#initialize', '15.2.14.4.9') do assert('Range#initialize', '15.2.14.4.9') do
a = Range.new(1, 10, true) a = Range.new(1, 10, true)
b = Range.new(1, 10, false) b = Range.new(1, 10, false)
a == (1...10) and a.exclude_end? and b == (1..10) and assert_equal a, (1...10)
not b.exclude_end? assert_true a.exclude_end?
assert_equal b, (1..10)
assert_false b.exclude_end?
end end
assert('Range#last', '15.2.14.4.10') do assert('Range#last', '15.2.14.4.10') do
(1..10).last == 10 assert_equal (1..10).last, 10
end end
assert('Range#member?', '15.2.14.4.11') do assert('Range#member?', '15.2.14.4.11') do
a = (1..10) a = (1..10)
a.member?(5) and not a.member?(20) assert_true a.member?(5)
assert_false a.member?(20)
end end
This diff is collapsed.
assert('super', '11.3.4') do assert('super', '11.3.4') do
test = false assert_raise NoMethodError do
begin
super super
rescue NoMethodError
test = true
end end
class SuperFoo class SuperFoo
...@@ -23,18 +20,14 @@ assert('super', '11.3.4') do ...@@ -23,18 +20,14 @@ assert('super', '11.3.4') do
end end
end end
bar = SuperBar.new bar = SuperBar.new
test &&= bar.foo
test &&= (bar.bar(1,2,3) == [1,2,3]) assert_true bar.foo
test assert_equal bar.bar(1,2,3), [1,2,3]
end end
assert('yield', '11.3.5') do assert('yield', '11.3.5') do
begin assert_raise LocalJumpError do
yield yield
rescue LocalJumpError
true
else
false
end end
end end
...@@ -43,7 +36,10 @@ assert('Abbreviated variable assignment', '11.4.2.3.2') do ...@@ -43,7 +36,10 @@ assert('Abbreviated variable assignment', '11.4.2.3.2') do
b &&= 1 b &&= 1
c = 1 c = 1
c += 2 c += 2
a == 1 and b == nil and c == 3
assert_equal a, 1
assert_nil b
assert_equal c, 3
end end
assert('Nested const reference') do assert('Nested const reference') do
...@@ -55,8 +51,8 @@ assert('Nested const reference') do ...@@ -55,8 +51,8 @@ assert('Nested const reference') do
end end
end end
end end
Syntax4Const::CONST1 == "hello world" and assert_equal Syntax4Const::CONST1, "hello world"
Syntax4Const::Const2.new.const1 == "hello world" assert_equal Syntax4Const::Const2.new.const1, "hello world"
end end
assert('Abbreviated variable assignment as returns') do assert('Abbreviated variable assignment as returns') do
...@@ -67,5 +63,5 @@ assert('Abbreviated variable assignment as returns') do ...@@ -67,5 +63,5 @@ assert('Abbreviated variable assignment as returns') do
end end
end end
end end
Syntax4AbbrVarAsgnAsReturns::A.new.b == 1 assert_equal Syntax4AbbrVarAsgnAsReturns::A.new.b, 1
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment