summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-08-04 17:40:18 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2013-08-04 17:40:18 -0700
commite8c3dd26d55822bcc8e526de51074e72bc7e02d2 (patch)
tree689e823f783d277b2923c2493a515d07c4ebdfbc
parente7be58efda6b2446ce46e61d91d637c77dec4fd5 (diff)
parentaa3ff53f048045065baeb58ef903f2637bdcebf3 (diff)
downloadmruby-e8c3dd26d55822bcc8e526de51074e72bc7e02d2.tar.gz
mruby-e8c3dd26d55822bcc8e526de51074e72bc7e02d2.zip
Merge pull request #1435 from Bovi-Li/test-fix-order
[mrbtest] assert_equal(expect, actual) order fix
-rw-r--r--mrbgems/mruby-enum-ext/test/enum.rb21
-rw-r--r--mrbgems/mruby-hash-ext/test/hash.rb12
-rw-r--r--mrbgems/mruby-numeric-ext/test/numeric.rb4
-rw-r--r--mrbgems/mruby-object-ext/test/nil.rb6
-rw-r--r--mrbgems/mruby-object-ext/test/object.rb2
-rw-r--r--mrbgems/mruby-objectspace/test/objectspace.rb73
-rw-r--r--mrbgems/mruby-proc-ext/test/proc.rb16
-rw-r--r--mrbgems/mruby-range-ext/test/range.rb12
-rw-r--r--mrbgems/mruby-string-ext/test/string.rb12
-rw-r--r--mrbgems/mruby-symbol-ext/test/symbol.rb4
-rw-r--r--mrbgems/mruby-toplevel-ext/test/toplevel.rb20
11 files changed, 89 insertions, 93 deletions
diff --git a/mrbgems/mruby-enum-ext/test/enum.rb b/mrbgems/mruby-enum-ext/test/enum.rb
index aa56cdf84..a7762231b 100644
--- a/mrbgems/mruby-enum-ext/test/enum.rb
+++ b/mrbgems/mruby-enum-ext/test/enum.rb
@@ -4,41 +4,40 @@
assert("Enumerable#drop") do
a = [1, 2, 3, 4, 5, 0]
- assert_equal a.drop(3), [4, 5, 0]
- assert_equal a.drop(6), []
+ assert_equal [4, 5, 0], a.drop(3)
+ assert_equal [], a.drop(6)
end
assert("Enumerable#drop_while") do
a = [1, 2, 3, 4, 5, 0]
- assert_equal a.drop_while {|i| i < 3 }, [3, 4, 5, 0]
+ assert_equal [3, 4, 5, 0], a.drop_while {|i| i < 3 }
end
assert("Enumerable#take") do
a = [1, 2, 3, 4, 5, 0]
- assert_equal a.take(3), [1, 2, 3]
+ assert_equal [1, 2, 3], a.take(3)
end
assert("Enumerable#take_while") do
a = [1, 2, 3, 4, 5, 0]
- assert_equal a.take_while {|i| i < 3 }, [1, 2]
+ assert_equal [1, 2], a.take_while {|i| i < 3}
end
assert("Enumerable#each_cons") do
a = []
(1..5).each_cons(3){|e| a << e}
- assert_equal a, [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
+ assert_equal [[1, 2, 3], [2, 3, 4], [3, 4, 5]], a
end
assert("Enumerable#each_slice") do
a = []
(1..10).each_slice(3){|e| a << e}
- assert_equal a, [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
+ assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], a
end
assert("Enumerable#group_by") do
r = (1..6).group_by {|i| i % 3 }
- assert_equal r[0], [3, 6]
- assert_equal r[1], [1, 4]
- assert_equal r[2], [2, 5]
+ assert_equal [3, 6], r[0]
+ assert_equal [1, 4], r[1]
+ assert_equal [2, 5], r[2]
end
-
diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb
index 73e12d8f2..40f6ac8bf 100644
--- a/mrbgems/mruby-hash-ext/test/hash.rb
+++ b/mrbgems/mruby-hash-ext/test/hash.rb
@@ -12,15 +12,13 @@ assert('Hash#merge!') 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',
- 'xyz_key' => 'xyz_value' }
+ assert_equal({'abc_key' => 'abc_value', 'cba_key' => 'XXX',
+ 'xyz_key' => 'xyz_value' }, result_1)
+ assert_equal({'abc_key' => 'abc_value', 'cba_key' => 'cba_value',
+ 'xyz_key' => 'xyz_value' }, result_2)
end
assert('Hash#values_at') do
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
- result = h.values_at("cow", "cat")
-
- result == ["bovine", "feline"]
+ assert_equal ["bovine", "feline"], h.values_at("cow", "cat")
end
diff --git a/mrbgems/mruby-numeric-ext/test/numeric.rb b/mrbgems/mruby-numeric-ext/test/numeric.rb
index 6c1cf0fce..7d85eaaa2 100644
--- a/mrbgems/mruby-numeric-ext/test/numeric.rb
+++ b/mrbgems/mruby-numeric-ext/test/numeric.rb
@@ -2,8 +2,8 @@
# Numeric(Ext) Test
assert('Integer#chr') do
- assert_equal(65.chr, "A")
- assert_equal(0x42.chr, "B")
+ assert_equal("A", 65.chr)
+ assert_equal("B", 0x42.chr)
# multibyte encoding (not support yet)
assert_raise(RangeError) { 12345.chr }
diff --git a/mrbgems/mruby-object-ext/test/nil.rb b/mrbgems/mruby-object-ext/test/nil.rb
index e385dec6a..5cd1cf4ed 100644
--- a/mrbgems/mruby-object-ext/test/nil.rb
+++ b/mrbgems/mruby-object-ext/test/nil.rb
@@ -1,11 +1,11 @@
assert('NilClass#to_a') do
- assert_equal nil.to_a, []
+ assert_equal [], nil.to_a
end
assert('NilClass#to_f') do
- assert_equal nil.to_f, 0.0
+ assert_equal 0.0, nil.to_f
end
assert('NilClass#to_i') do
- assert_equal nil.to_i, 0
+ assert_equal 0, nil.to_i
end
diff --git a/mrbgems/mruby-object-ext/test/object.rb b/mrbgems/mruby-object-ext/test/object.rb
index 1a75622f6..1f2dd1b64 100644
--- a/mrbgems/mruby-object-ext/test/object.rb
+++ b/mrbgems/mruby-object-ext/test/object.rb
@@ -5,5 +5,5 @@ assert('Object#instance_exec') do
end
end
k = KlassWithSecret.new
- assert_equal k.instance_exec(5) {|x| @secret+x }, 104
+ assert_equal 104, k.instance_exec(5) {|x| @secret+x }
end
diff --git a/mrbgems/mruby-objectspace/test/objectspace.rb b/mrbgems/mruby-objectspace/test/objectspace.rb
index 37137eb04..612137019 100644
--- a/mrbgems/mruby-objectspace/test/objectspace.rb
+++ b/mrbgems/mruby-objectspace/test/objectspace.rb
@@ -1,38 +1,37 @@
assert('ObjectSpace.count_objects') do
- h = {}
- ObjectSpace.count_objects(h)
- assert_kind_of(Hash, h)
- assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
- assert_true(h.values.all? {|x| x.is_a?(Integer) })
-
- assert_true(h.has_key?(:TOTAL))
- assert_true(h.has_key?(:FREE))
-
- h = ObjectSpace.count_objects
- assert_kind_of(Hash, h)
- assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
- assert_true(h.values.all? {|x| x.is_a?(Integer) })
-
- assert_raise(TypeError) { ObjectSpace.count_objects(1) }
-
- h0 = {:MRB_TT_FOO=>1000}
- h = ObjectSpace.count_objects(h0)
- assert_false(h0.has_key?(:MRB_TT_FOO))
-
- GC.start
- h_after = {}
- h_before = ObjectSpace.count_objects
-
- objs = []
- 1000.times do
- objs << {}
- end
- objs = nil
- ObjectSpace.count_objects(h)
- GC.start
- ObjectSpace.count_objects(h_after)
-
- assert_equal(h_before[:MRB_TT_HASH] + 1000, h[:MRB_TT_HASH])
- assert_equal(h_before[:MRB_TT_HASH], h_after[:MRB_TT_HASH])
-
-end \ No newline at end of file
+ h = {}
+ ObjectSpace.count_objects(h)
+ assert_kind_of(Hash, h)
+ assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
+ assert_true(h.values.all? {|x| x.is_a?(Integer) })
+
+ assert_true(h.has_key?(:TOTAL))
+ assert_true(h.has_key?(:FREE))
+
+ h = ObjectSpace.count_objects
+ assert_kind_of(Hash, h)
+ assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
+ assert_true(h.values.all? {|x| x.is_a?(Integer) })
+
+ assert_raise(TypeError) { ObjectSpace.count_objects(1) }
+
+ h0 = {:MRB_TT_FOO=>1000}
+ h = ObjectSpace.count_objects(h0)
+ assert_false(h0.has_key?(:MRB_TT_FOO))
+
+ GC.start
+ h_after = {}
+ h_before = ObjectSpace.count_objects
+
+ objs = []
+ 1000.times do
+ objs << {}
+ end
+ objs = nil
+ ObjectSpace.count_objects(h)
+ GC.start
+ ObjectSpace.count_objects(h_after)
+
+ assert_equal(h[:MRB_TT_HASH], h_before[:MRB_TT_HASH] + 1000)
+ assert_equal(h_after[:MRB_TT_HASH], h_before[:MRB_TT_HASH])
+end
diff --git a/mrbgems/mruby-proc-ext/test/proc.rb b/mrbgems/mruby-proc-ext/test/proc.rb
index a868a39a5..abbd7a9d9 100644
--- a/mrbgems/mruby-proc-ext/test/proc.rb
+++ b/mrbgems/mruby-proc-ext/test/proc.rb
@@ -8,24 +8,24 @@ end
assert('Proc#===') do
proc = Proc.new {|a| a * 2}
- assert_equal (proc === 10), 20
+ assert_equal 20, (proc === 10)
end
assert('Proc#yield') do
proc = Proc.new {|a| a * 2}
- assert_equal proc.yield(10), 20
+ assert_equal 20, proc.yield(10)
end
assert('Proc#curry') do
b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
- assert_equal b.curry[1][2][3], 6
- assert_equal b.curry[1, 2][3, 4], 6
- assert_equal b.curry(5)[1][2][3][4][5], 6
- assert_equal b.curry(5)[1, 2][3, 4][5], 6
- assert_equal b.curry(1)[1], 1
+ assert_equal 6, b.curry[1][2][3]
+ assert_equal 6, b.curry[1, 2][3, 4]
+ assert_equal 6, b.curry(5)[1][2][3][4][5]
+ assert_equal 6, b.curry(5)[1, 2][3, 4][5]
+ assert_equal 1, b.curry(1)[1]
b = lambda {|x, y, z| (x||0) + (y||0) + (z||0) }
- assert_equal b.curry[1][2][3], 6
+ assert_equal 6, b.curry[1][2][3]
assert_raise(ArgumentError) { b.curry[1, 2][3, 4] }
assert_raise(ArgumentError) { b.curry(5) }
assert_raise(ArgumentError) { b.curry(1) }
diff --git a/mrbgems/mruby-range-ext/test/range.rb b/mrbgems/mruby-range-ext/test/range.rb
index 6442d6e16..2a170a66a 100644
--- a/mrbgems/mruby-range-ext/test/range.rb
+++ b/mrbgems/mruby-range-ext/test/range.rb
@@ -8,13 +8,13 @@ assert('Range#cover?') do
end
assert('Range#first') do
- assert_equal (10..20).first, 10
- assert_equal (10..20).first(3), [10, 11, 12]
+ assert_equal 10, (10..20).first
+ assert_equal [10, 11, 12], (10..20).first(3)
end
assert('Range#last') do
- assert_equal (10..20).last, 20
- assert_equal (10...20).last, 20
- assert_equal (10..20).last(3), [18, 19, 20]
- assert_equal (10...20).last(3), [17, 18, 19]
+ assert_equal 20, (10..20).last
+ assert_equal 20, (10...20).last
+ assert_equal [18, 19, 20], (10..20).last(3)
+ assert_equal [17, 18, 19], (10...20).last(3)
end
diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb
index 2bb32cef3..9eb6f6aaa 100644
--- a/mrbgems/mruby-string-ext/test/string.rb
+++ b/mrbgems/mruby-string-ext/test/string.rb
@@ -74,8 +74,8 @@ assert('String#rstrip!') do
end
assert('String#swapcase') do
- assert_equal "Hello".swapcase, "hELLO"
- assert_equal "cYbEr_PuNk11".swapcase, "CyBeR_pUnK11"
+ assert_equal "hELLO", "Hello".swapcase
+ assert_equal "CyBeR_pUnK11", "cYbEr_PuNk11".swapcase
end
assert('String#swapcase!') do
@@ -95,10 +95,10 @@ assert('String#concat') do
end
assert('String#casecmp') do
- assert_equal "abcdef".casecmp("abcde"), 1
- assert_equal "aBcDeF".casecmp("abcdef"), 0
- assert_equal "abcdef".casecmp("abcdefg"),-1
- assert_equal "abcdef".casecmp("ABCDEF"), 0
+ assert_equal 1, "abcdef".casecmp("abcde")
+ assert_equal 0, "aBcDeF".casecmp("abcdef")
+ assert_equal(-1, "abcdef".casecmp("abcdefg"))
+ assert_equal 0, "abcdef".casecmp("ABCDEF")
end
assert('String#start_with?') do
diff --git a/mrbgems/mruby-symbol-ext/test/symbol.rb b/mrbgems/mruby-symbol-ext/test/symbol.rb
index b04847b3f..741315d74 100644
--- a/mrbgems/mruby-symbol-ext/test/symbol.rb
+++ b/mrbgems/mruby-symbol-ext/test/symbol.rb
@@ -2,11 +2,11 @@
# Symbol(Ext) Test
assert('Symbol#to_proc') do
- assert_equal :abs.to_proc[-5], 5
+ assert_equal 5, :abs.to_proc[-5]
end
assert('Symbol.all_symbols') do
foo = [:__symbol_test_1, :__symbol_test_2, :__symbol_test_3].sort
symbols = Symbol.all_symbols.select{|sym|sym.to_s.include? '__symbol_test'}.sort
- assert_equal symbols, foo
+ assert_equal foo, symbols
end
diff --git a/mrbgems/mruby-toplevel-ext/test/toplevel.rb b/mrbgems/mruby-toplevel-ext/test/toplevel.rb
index 4401beba1..9630fe3dd 100644
--- a/mrbgems/mruby-toplevel-ext/test/toplevel.rb
+++ b/mrbgems/mruby-toplevel-ext/test/toplevel.rb
@@ -1,19 +1,19 @@
##
# Toplevel Self(Ext) Test
-module ToplevelTestModule1
- def method_foo
- :foo
- end
+assert('Toplevel#include') do
+ module ToplevelTestModule1
+ def method_foo
+ :foo
+ end
- CONST_BAR = :bar
-end
+ CONST_BAR = :bar
+ end
-module ToplevelTestModule2
- CONST_BAR = :bar2
-end
+ module ToplevelTestModule2
+ CONST_BAR = :bar2
+ end
-assert('Toplevel#include') do
self.include ToplevelTestModule2, ToplevelTestModule1
assert_true self.class.included_modules.include?( ToplevelTestModule1 )