diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-11 04:53:57 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-11 04:53:57 +0000 |
| commit | 8589d540c45edb3236467e6ccd81b692ef08467f (patch) | |
| tree | a0e93d21918fbb9e8599628b333290410a5cdba8 /lib | |
| parent | f8a45c1cbf91afaf183caea6ceafffa973a5924d (diff) | |
| download | ruby-8589d540c45edb3236467e6ccd81b692ef08467f.tar.gz ruby-8589d540c45edb3236467e6ccd81b692ef08467f.tar.xz ruby-8589d540c45edb3236467e6ccd81b692ef08467f.zip | |
* lib/pp.rb: refine to_s test.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pp.rb | 25 | ||||
| -rw-r--r-- | lib/prettyprint.rb | 2 |
2 files changed, 16 insertions, 11 deletions
@@ -115,6 +115,9 @@ PP#pp to print the object. If you implement (({pretty_print})), it can be used as follows. alias inspect pretty_print_inspect + +== AUTHOR +Tanaka Akira <akr@m17n.org> =end require 'prettyprint' @@ -524,21 +527,21 @@ if __FILE__ == $0 assert_equal("#{a.inspect}\n", PP.pp(a, '')) end - class Test_to_s_with_iv - def initialize() @a = nil end - def to_s() "aaa" end - end def test_to_s_with_iv - a = Test_to_s_with_iv.new - assert_equal("#{a.inspect}\n", PP.pp(a, '')) + a = Object.new + def a.to_s() "aaa" end + a.instance_eval { @a = nil } + result = PP.pp(a, '') + assert_equal("#{a.inspect}\n", result) + assert_match(/\A#<Object.*>\n\z/m, result) end - class Test_to_s_without_iv - def to_s() "aaa" end - end def test_to_s_without_iv - a = Test_to_s_without_iv.new - assert_equal("#{a.inspect}\n", PP.pp(a, '')) + a = Object.new + def a.to_s() "aaa" end + result = PP.pp(a, '') + assert_equal("#{a.inspect}\n", result) + assert_equal("aaa\n", result) end end diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index f7b9bbdf5..a815f6453 100644 --- a/lib/prettyprint.rb +++ b/lib/prettyprint.rb @@ -119,6 +119,8 @@ Christian Lindig, Strictly Pretty, March 2000, Philip Wadler, A prettier printer, March 1998, ((<URL:http://www.research.avayalabs.com/user/wadler/topics/recent.html#prettier>)) +== AUTHOR +Tanaka Akira <akr@m17n.org> =end class PrettyPrint |
