@@ -14,100 +14,106 @@ class TestTimeout < Test::Unit::TestCase
1414
1515 # when an exception to raise is not specified and the inner code does not catch Exception
1616 def test_1
17- subject ( nil , StandardError )
17+ s = ErrorLifeCycleTester . new
18+ s . subject ( nil , StandardError )
1819
1920 # EXPECTED
20- assert $ inner_attempted
21- assert !$ inner_else
22- assert !$ inner_rescue
23- assert $ inner_ensure
24- assert $ outer_rescue
25- assert $ outer_ensure
26- assert $ inner_ensure_has_time_to_finish
27- assert $ outer_ensure_has_time_to_finish
21+ assert s . inner_attempted
22+ assert !s . inner_else
23+ assert !s . inner_rescue
24+ assert s . inner_ensure
25+ assert s . outer_rescue
26+ assert s . outer_ensure
27+ assert s . inner_ensure_has_time_to_finish
28+ assert s . outer_ensure_has_time_to_finish
2829 end
2930
3031 # when an exception to raise is not specified and the inner code does catch Exception
3132 def test_2
32- subject ( nil , Exception )
33+ s = ErrorLifeCycleTester . new
34+ s . subject ( nil , Exception )
3335
3436 # EXPECTED
35- assert $ inner_attempted
36- assert !$ inner_else
37- assert $ inner_ensure
38- assert $ outer_ensure
39- assert $ inner_ensure_has_time_to_finish
40- assert $ outer_ensure_has_time_to_finish
41- assert $ inner_rescue # true in 1.9, false in gem 0.2.0, true in 0.4.0
37+ assert s . inner_attempted
38+ assert !s . inner_else
39+ assert s . inner_ensure
40+ assert s . outer_ensure
41+ assert s . inner_ensure_has_time_to_finish
42+ assert s . outer_ensure_has_time_to_finish
43+ assert s . inner_rescue # true in 1.9, false in gem 0.2.0, true in 0.4.0
4244
4345 # BAD?
44- assert !$ outer_rescue # false in 1.9 stdlib, true in gem 0.2.0, false in 0.4.0
46+ assert !s . outer_rescue # false in 1.9 stdlib, true in gem 0.2.0, false in 0.4.0
4547 end
4648
4749 # when an exception to raise is StandardError and the inner code does not catch Exception
4850 def test_3
49- subject ( MyStandardError , StandardError )
51+ s = ErrorLifeCycleTester . new
52+ s . subject ( MyStandardError , StandardError )
5053
5154 # EXPECTED
52- assert $ inner_attempted
53- assert !$ inner_else
54- assert $ inner_rescue
55- assert $ inner_ensure
56- assert $ outer_ensure
57- assert $ inner_ensure_has_time_to_finish
58- assert $ outer_ensure_has_time_to_finish
55+ assert s . inner_attempted
56+ assert !s . inner_else
57+ assert s . inner_rescue
58+ assert s . inner_ensure
59+ assert s . outer_ensure
60+ assert s . inner_ensure_has_time_to_finish
61+ assert s . outer_ensure_has_time_to_finish
5962
6063 # BAD?
61- assert !$ outer_rescue
64+ assert !s . outer_rescue
6265 end
6366
6467 # when an exception to raise is StandardError and the inner code does catch Exception
6568 def test_4
66- subject ( MyStandardError , Exception )
69+ s = ErrorLifeCycleTester . new
70+ s . subject ( MyStandardError , Exception )
6771
6872 # EXPECTED
69- assert $ inner_attempted
70- assert !$ inner_else
71- assert $ inner_rescue
72- assert $ inner_ensure
73- assert $ outer_ensure
74- assert $ inner_ensure_has_time_to_finish
75- assert $ outer_ensure_has_time_to_finish
73+ assert s . inner_attempted
74+ assert !s . inner_else
75+ assert s . inner_rescue
76+ assert s . inner_ensure
77+ assert s . outer_ensure
78+ assert s . inner_ensure_has_time_to_finish
79+ assert s . outer_ensure_has_time_to_finish
7680
7781 # BAD?
78- assert !$ outer_rescue
82+ assert !s . outer_rescue
7983 end
8084
8185 # when an exception to raise is Exception and the inner code does not catch Exception
8286 def test_5
83- subject ( MyException , StandardError )
87+ s = ErrorLifeCycleTester . new
88+ s . subject ( MyException , StandardError )
8489
8590 # EXPECTED
86- assert $ inner_attempted
87- assert !$ inner_else
88- assert !$ inner_rescue
89- assert $ inner_ensure
90- assert $ outer_ensure
91- assert $ outer_rescue
92- assert $ inner_ensure_has_time_to_finish
93- assert $ outer_ensure_has_time_to_finish
91+ assert s . inner_attempted
92+ assert !s . inner_else
93+ assert !s . inner_rescue
94+ assert s . inner_ensure
95+ assert s . outer_ensure
96+ assert s . outer_rescue
97+ assert s . inner_ensure_has_time_to_finish
98+ assert s . outer_ensure_has_time_to_finish
9499 end
95100
96101 # when an exception to raise is Exception and the inner code does catch Exception
97102 def test_6
98- subject ( MyException , Exception )
103+ s = ErrorLifeCycleTester . new
104+ s . subject ( MyException , Exception )
99105
100106 # EXPECTED
101- assert $ inner_attempted
102- assert !$ inner_else
103- assert $ inner_rescue
104- assert $ inner_ensure
105- assert $ outer_ensure
106- assert $ inner_ensure_has_time_to_finish
107- assert $ outer_ensure_has_time_to_finish
107+ assert s . inner_attempted
108+ assert !s . inner_else
109+ assert s . inner_rescue
110+ assert s . inner_ensure
111+ assert s . outer_ensure
112+ assert s . inner_ensure_has_time_to_finish
113+ assert s . outer_ensure_has_time_to_finish
108114
109115 # BAD?
110- assert !$ outer_rescue
116+ assert !s . outer_rescue
111117 end
112118
113119end
0 commit comments