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