summaryrefslogtreecommitdiff
path: root/lib/pp.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 05:51:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-01-21 05:51:41 +0000
commitfce7467e601e76d64a175929f2f14f89cfd450dd (patch)
treeb12c0550733bcac2a76b583ff5fd88f60340ea92 /lib/pp.rb
parentc2dbfe53fc1d34b3c38172bda2a801fc60f26e66 (diff)
* 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
Diffstat (limited to 'lib/pp.rb')
-rw-r--r--lib/pp.rb43
1 files changed, 34 insertions, 9 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 94a5aa18b5c..b14611ff050 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("<inspect:1>\n", PP.pp(a, ''))
@@ -489,9 +496,21 @@ if __FILE__ == $0
a = HasBoth.new(1)
assert_equal("<pretty_print:1>\n", PP.pp(a, ''))
end
+
+ def test_pretty_print_inspect
+ a = PrettyPrintInspect.new(1)
+ assert_equal("<pretty_print:1>", 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("[<inspect:[...]>]\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