зеркало из https://github.com/github/ruby.git
* test/csv/test_data_converters.rb, test/csv/test_table.rb: don't
not call setup within tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c9958d6ab4
Коммит
36feefecb9
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Dec 25 22:04:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/csv/test_data_converters.rb, test/csv/test_table.rb: don't
|
||||||
|
not call setup within tests.
|
||||||
|
|
||||||
Sat Dec 25 20:01:40 2010 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat Dec 25 20:01:40 2010 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* io.c (pipe_open): Added rb_thread_atfork(). We must reinitialize
|
* io.c (pipe_open): Added rb_thread_atfork(). We must reinitialize
|
||||||
|
|
|
@ -63,24 +63,25 @@ class TestCSV::DataConverters < TestCSV
|
||||||
assert_instance_of(String, CSV::Converters[:date_time]["junk"])
|
assert_instance_of(String, CSV::Converters[:date_time]["junk"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_convert_with_builtin
|
def test_convert_with_builtin_integer
|
||||||
# setup parser...
|
# setup parser...
|
||||||
assert(@parser.respond_to?(:convert))
|
assert(@parser.respond_to?(:convert))
|
||||||
assert_nothing_raised(Exception) { @parser.convert(:integer) }
|
assert_nothing_raised(Exception) { @parser.convert(:integer) }
|
||||||
|
|
||||||
# and use
|
# and use
|
||||||
assert_equal(["Numbers", ":integer", 1, ":float", "3.015"], @parser.shift)
|
assert_equal(["Numbers", ":integer", 1, ":float", "3.015"], @parser.shift)
|
||||||
|
end
|
||||||
|
|
||||||
setup # reset
|
def test_convert_with_builtin_float
|
||||||
|
|
||||||
# setup parser...
|
# setup parser...
|
||||||
|
assert(@parser.respond_to?(:convert))
|
||||||
assert_nothing_raised(Exception) { @parser.convert(:float) }
|
assert_nothing_raised(Exception) { @parser.convert(:float) }
|
||||||
|
|
||||||
# and use
|
# and use
|
||||||
assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015], @parser.shift)
|
assert_equal(["Numbers", ":integer", 1.0, ":float", 3.015], @parser.shift)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_convert_order
|
def test_convert_order_float_integer
|
||||||
# floats first, then integers...
|
# floats first, then integers...
|
||||||
assert_nothing_raised(Exception) do
|
assert_nothing_raised(Exception) do
|
||||||
@parser.convert(:float)
|
@parser.convert(:float)
|
||||||
|
@ -90,9 +91,9 @@ class TestCSV::DataConverters < TestCSV
|
||||||
# gets us nothing but floats
|
# gets us nothing but floats
|
||||||
assert_equal( [String, String, Float, String, Float],
|
assert_equal( [String, String, Float, String, Float],
|
||||||
@parser.shift.map { |field| field.class } )
|
@parser.shift.map { |field| field.class } )
|
||||||
|
end
|
||||||
|
|
||||||
setup # reset
|
def test_convert_order_integer_float
|
||||||
|
|
||||||
# integers have precendance...
|
# integers have precendance...
|
||||||
assert_nothing_raised(Exception) do
|
assert_nothing_raised(Exception) do
|
||||||
@parser.convert(:integer)
|
@parser.convert(:integer)
|
||||||
|
@ -132,9 +133,9 @@ class TestCSV::DataConverters < TestCSV
|
||||||
|
|
||||||
# and use
|
# and use
|
||||||
assert_equal(["Numbers", :integer, "1", :float, "3.015"], @parser.shift)
|
assert_equal(["Numbers", :integer, "1", :float, "3.015"], @parser.shift)
|
||||||
|
end
|
||||||
|
|
||||||
setup # reset
|
def test_convert_with_custom_code_mix
|
||||||
|
|
||||||
# mix built-in and custom...
|
# mix built-in and custom...
|
||||||
assert_nothing_raised(Exception) { @parser.convert(:numeric) }
|
assert_nothing_raised(Exception) { @parser.convert(:numeric) }
|
||||||
assert_nothing_raised(Exception) { @parser.convert(&@custom) }
|
assert_nothing_raised(Exception) { @parser.convert(&@custom) }
|
||||||
|
|
|
@ -270,7 +270,7 @@ class TestCSV::Table < TestCSV
|
||||||
assert_equal(CSV::Row.new(%w[A B C], [13, 14, 15]), @table[-1])
|
assert_equal(CSV::Row.new(%w[A B C], [13, 14, 15]), @table[-1])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete
|
def test_delete_mixed
|
||||||
##################
|
##################
|
||||||
### Mixed Mode ###
|
### Mixed Mode ###
|
||||||
##################
|
##################
|
||||||
|
@ -286,11 +286,12 @@ class TestCSV::Table < TestCSV
|
||||||
2,3
|
2,3
|
||||||
8,9
|
8,9
|
||||||
END_RESULT
|
END_RESULT
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_column
|
||||||
###################
|
###################
|
||||||
### Column Mode ###
|
### Column Mode ###
|
||||||
###################
|
###################
|
||||||
setup
|
|
||||||
@table.by_col!
|
@table.by_col!
|
||||||
|
|
||||||
assert_equal(@rows.map { |row| row[0] }, @table.delete(0))
|
assert_equal(@rows.map { |row| row[0] }, @table.delete(0))
|
||||||
|
@ -303,11 +304,12 @@ class TestCSV::Table < TestCSV
|
||||||
5
|
5
|
||||||
8
|
8
|
||||||
END_RESULT
|
END_RESULT
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_row
|
||||||
################
|
################
|
||||||
### Row Mode ###
|
### Row Mode ###
|
||||||
################
|
################
|
||||||
setup
|
|
||||||
@table.by_row!
|
@table.by_row!
|
||||||
|
|
||||||
assert_equal(@rows[1], @table.delete(1))
|
assert_equal(@rows[1], @table.delete(1))
|
||||||
|
@ -327,7 +329,7 @@ class TestCSV::Table < TestCSV
|
||||||
assert_equal(["ra2", nil, "rb2"], table.delete("col2"))
|
assert_equal(["ra2", nil, "rb2"], table.delete("col2"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_if
|
def test_delete_if_row
|
||||||
######################
|
######################
|
||||||
### Mixed/Row Mode ###
|
### Mixed/Row Mode ###
|
||||||
######################
|
######################
|
||||||
|
@ -339,11 +341,12 @@ class TestCSV::Table < TestCSV
|
||||||
A,B,C
|
A,B,C
|
||||||
4,5,6
|
4,5,6
|
||||||
END_RESULT
|
END_RESULT
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_if_column
|
||||||
###################
|
###################
|
||||||
### Column Mode ###
|
### Column Mode ###
|
||||||
###################
|
###################
|
||||||
setup
|
|
||||||
@table.by_col!
|
@table.by_col!
|
||||||
|
|
||||||
assert_equal(@table, @table.delete_if { |h, v| h > "A" })
|
assert_equal(@table, @table.delete_if { |h, v| h > "A" })
|
||||||
|
|
Загрузка…
Ссылка в новой задаче