From fce7467e601e76d64a175929f2f14f89cfd450dd Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 21 Jan 2003 05:51:41 +0000 Subject: * lib/pp.rb: Use Test::Unit. * lib/prettyprint.rb: Ditto * lib/time.rb: Ditto * lib/tsort.rb: Ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/pp.rb | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'lib/pp.rb') diff --git a/lib/pp.rb b/lib/pp.rb index 94a5aa18b5..b14611ff05 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -423,10 +423,9 @@ end } if __FILE__ == $0 - require 'runit/testcase' - require 'runit/cui/testrunner' + require 'test/unit' - class PPTest < RUNIT::TestCase + class PPTest < Test::Unit::TestCase def test_list0123_12 assert_equal("[0, 1, 2, 3]\n", PP.pp([0,1,2,3], '', 12)) end @@ -474,7 +473,15 @@ if __FILE__ == $0 end end - class PPInspectTest < RUNIT::TestCase + class PrettyPrintInspect < HasPrettyPrint + alias inspect pretty_print_inspect + end + + class PrettyPrintInspectWithoutPrettyPrint + alias inspect pretty_print_inspect + end + + class PPInspectTest < Test::Unit::TestCase def test_hasinspect a = HasInspect.new(1) assert_equal("\n", PP.pp(a, '')) @@ -489,9 +496,21 @@ if __FILE__ == $0 a = HasBoth.new(1) assert_equal("\n", PP.pp(a, '')) end + + def test_pretty_print_inspect + a = PrettyPrintInspect.new(1) + assert_equal("", a.inspect) + a = PrettyPrintInspectWithoutPrettyPrint.new + assert_raises(RuntimeError) { a.inspect } + end + + def test_proc + a = proc {1} + assert_equal("#{a.inspect}\n", PP.pp(a, '')) + end end - class PPCycleTest < RUNIT::TestCase + class PPCycleTest < Test::Unit::TestCase def test_array a = [] a << a @@ -522,9 +541,15 @@ if __FILE__ == $0 a << HasInspect.new(a) assert_equal("[]\n", PP.pp(a, '')) end - end - RUNIT::CUI::TestRunner.run(PPTest.suite) - RUNIT::CUI::TestRunner.run(PPInspectTest.suite) - RUNIT::CUI::TestRunner.run(PPCycleTest.suite) + def test_share_nil + begin + PP.sharing_detection = true + a = [nil, nil] + assert_equal("[nil, nil]\n", PP.pp(a, '')) + ensure + PP.sharing_detection = false + end + end + end end -- cgit v1.2.3