Class: PPCycleTest
- Defined in:
- lib/pp.rb
Defined Under Namespace
Classes: S
Instance Method Summary collapse
- #test_anonymous ⇒ Object
- #test_array ⇒ Object
- #test_hash ⇒ Object
- #test_object ⇒ Object
- #test_share_nil ⇒ Object
- #test_struct ⇒ Object
- #test_withinspect ⇒ Object
Instance Method Details
#test_anonymous ⇒ Object
625 626 627 628 |
# File 'lib/pp.rb', line 625 def test_anonymous a = Class.new.new assert_equal(a.inspect + "\n", PP.pp(a, '')) end |
#test_array ⇒ Object
597 598 599 600 601 602 |
# File 'lib/pp.rb', line 597 def test_array a = [] a << a assert_equal("[[...]]\n", PP.pp(a, '')) assert_equal("#{a.inspect}\n", PP.pp(a, '')) end |
#test_hash ⇒ Object
604 605 606 607 608 609 |
# File 'lib/pp.rb', line 604 def test_hash a = {} a[0] = a assert_equal("{0=>{...}}\n", PP.pp(a, '')) assert_equal("#{a.inspect}\n", PP.pp(a, '')) end |
#test_object ⇒ Object
619 620 621 622 623 |
# File 'lib/pp.rb', line 619 def test_object a = Object.new a.instance_eval {@a = a} assert_equal(a.inspect + "\n", PP.pp(a, '')) end |
#test_share_nil ⇒ Object
637 638 639 640 641 642 643 644 645 |
# File 'lib/pp.rb', line 637 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 |
#test_struct ⇒ Object
612 613 614 615 616 617 |
# File 'lib/pp.rb', line 612 def test_struct a = S.new(1,2) a.b = a assert_equal("#<struct Struct::S a=1, b=#<struct Struct::S:...>>\n", PP.pp(a, '')) assert_equal("#{a.inspect}\n", PP.pp(a, '')) end |
#test_withinspect ⇒ Object
630 631 632 633 634 635 |
# File 'lib/pp.rb', line 630 def test_withinspect a = [] a << HasInspect.new(a) assert_equal("[<inspect:[...]>]\n", PP.pp(a, '')) assert_equal("#{a.inspect}\n", PP.pp(a, '')) end |