[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / test / -ext- / test_recursion.rb
blobdb7a8539886721a78e4bf80e6814123a9be064a5
1 # -*- coding: us-ascii -*-
2 # frozen_string_literal: false
3 require 'test/unit'
5 class TestRecursion < Test::Unit::TestCase
6   require '-test-/recursion'
8   def setup
9     @obj = Struct.new(:visited).new(false)
10     @obj.extend(Bug::Recursive)
11   end
13   def test_recursive
14     def @obj.doit
15       self.visited = true
16       exec_recursive(:doit)
17       raise "recursive"
18     end
19     assert_raise_with_message(RuntimeError, "recursive") {
20       @obj.exec_recursive(:doit)
21     }
22     assert(@obj.visited, "obj.hash was not called")
23   end
25   def test_recursive_outer
26     def @obj.doit
27       self.visited = true
28       exec_recursive_outer(:doit)
29       raise "recursive_outer should short circuit intermediate calls"
30     end
31     assert_nothing_raised {
32       @obj.exec_recursive_outer(:doit)
33     }
34     assert(@obj.visited, "obj.hash was not called")
35   end
36 end