@@ -14,13 +14,14 @@ def greet
14
14
end
15
15
16
16
actual = output_of_whereami { greet }
17
- assert_equal <<EOF . chomp , actual
17
+ expected = <<EOF . chomp
18
18
def greet
19
19
message = 'Hello, world!' # message: "Hello, world!"
20
20
@binding = binding
21
21
message
22
22
end
23
23
EOF
24
+ assert { actual . end_with? ( expected ) }
24
25
end
25
26
26
27
test 'multiple assignment of local variables' do
@@ -30,12 +31,13 @@ def multiple_assign
30
31
end
31
32
32
33
actual = output_of_whereami { multiple_assign }
33
- assert_equal <<EOF . chomp , actual
34
+ expected = <<EOF . chomp
34
35
def multiple_assign
35
36
x, y = 10, 20 # x: 10, y: 20
36
37
@binding = binding
37
38
end
38
39
EOF
40
+ assert { actual . end_with? ( expected ) }
39
41
end
40
42
41
43
test 'operator assign of local variables' do
@@ -48,7 +50,7 @@ def opassign
48
50
end
49
51
50
52
actual = output_of_whereami { opassign }
51
- assert_equal <<EOF . chomp , actual
53
+ expected = <<EOF . chomp
52
54
def opassign
53
55
x, y, z = 1, 2, false
54
56
x += 10 # x: 11
@@ -57,6 +59,7 @@ def opassign
57
59
@binding = binding
58
60
end
59
61
EOF
62
+ assert { actual . end_with? ( expected ) }
60
63
end
61
64
62
65
test 'parameters of block' do
@@ -67,13 +70,14 @@ def block_parameters
67
70
end
68
71
69
72
actual = output_of_whereami { block_parameters }
70
- assert_equal <<EOF . chomp , actual
73
+ expected = <<EOF . chomp
71
74
def block_parameters
72
75
(1..10).each do |i| # i: 5
73
76
@binding = binding if i == 5
74
77
end
75
78
end
76
79
EOF
80
+ assert { actual . end_with? ( expected ) }
77
81
end
78
82
79
83
test 'assignment of instance variable' do
@@ -84,13 +88,14 @@ def assign_instance_variable
84
88
end
85
89
86
90
actual = output_of_whereami { assign_instance_variable }
87
- assert_equal <<EOF . chomp , actual
91
+ expected = <<EOF . chomp
88
92
def assign_instance_variable
89
93
@x = [1, 2, 3] # @x: [1, 2, 3]
90
94
@binding = binding
91
95
@y = [4, 5, 6]
92
96
end
93
97
EOF
98
+ assert { actual . end_with? ( expected ) }
94
99
end
95
100
96
101
test 'assignment of class variable' do
@@ -100,12 +105,13 @@ def assign_class_variable
100
105
end
101
106
102
107
actual = output_of_whereami { assign_class_variable }
103
- assert_equal <<EOF . chomp , actual
108
+ expected = <<EOF . chomp
104
109
def assign_class_variable
105
110
@@var = { x: 10 } # @@var: {:x=>10}
106
111
@binding = binding
107
112
end
108
113
EOF
114
+ assert { actual . end_with? ( expected ) }
109
115
end
110
116
111
117
test 'assignment of global variable' do
@@ -115,12 +121,13 @@ def assign_class_variable
115
121
end
116
122
117
123
actual = output_of_whereami { assign_class_variable }
118
- assert_equal <<EOF . chomp , actual
124
+ expected = <<EOF . chomp
119
125
def assign_class_variable
120
126
$var = { x: 10 } # $var: {:x=>10}
121
127
@binding = binding
122
128
end
123
129
EOF
130
+ assert { actual . end_with? ( expected ) }
124
131
end
125
132
126
133
test 'assignment of var args' do
@@ -129,11 +136,12 @@ def use_var_args(*args)
129
136
end
130
137
131
138
actual = output_of_whereami { use_var_args ( 1 , 2 , 3 ) }
132
- assert_equal <<EOF . chomp , actual
139
+ expected = <<EOF . chomp
133
140
def use_var_args(*args) # args: [1, 2, 3]
134
141
@binding = binding
135
142
end
136
143
EOF
144
+ assert { actual . end_with? ( expected ) }
137
145
end
138
146
139
147
test 'assignment after binding.pry' do
@@ -144,13 +152,14 @@ def assignment_after_binding
144
152
end
145
153
146
154
actual = output_of_whereami { assignment_after_binding }
147
- assert_equal <<EOF . chomp , actual
155
+ expected = <<EOF . chomp
148
156
def assignment_after_binding
149
157
x = 10 # x: 10
150
158
@binding = binding
151
159
y = 10
152
160
end
153
161
EOF
162
+ assert { actual . end_with? ( expected ) }
154
163
end
155
164
156
165
test 'keyword arguments' do
@@ -159,11 +168,12 @@ def keyword_arguments(a: 10, b: 20)
159
168
end
160
169
161
170
actual = output_of_whereami { keyword_arguments ( b : 100 ) }
162
- assert_equal <<EOF . chomp , actual
171
+ expected = <<EOF . chomp
163
172
def keyword_arguments(a: 10, b: 20) # a: 10, b: 100
164
173
@binding = binding
165
174
end
166
175
EOF
176
+ assert { actual . end_with? ( expected ) }
167
177
end
168
178
169
179
test 'combinations of arguments' do
@@ -176,11 +186,12 @@ def f(a, m = 1, *rest, x, k: 1, **kwrest) # a: "a", m: 2, rest: ["f", "b"], x: "
176
186
end
177
187
EOF
178
188
actual = output_of_whereami { f ( 'a' , 2 , 'f' , 'b' , 'x' , k : 42 , u : 'u' ) }
179
- assert_equal <<EOF . chomp , actual
189
+ expected = <<EOF . chomp
180
190
def f(a, m = 1, *rest, x, k: 1, **kwrest) # a: "a", m: 2, rest: ["f", "b"], x: "x", k: 42, kwrest: {:u=>"u"}
181
191
@binding = binding
182
192
end
183
193
EOF
194
+ assert { actual . end_with? ( expected ) }
184
195
end
185
196
186
197
test 'too long function' do
@@ -217,7 +228,7 @@ def too_long_function
217
228
i += 1
218
229
end
219
230
actual = output_of_whereami { too_long_function }
220
- assert_equal <<EOF . chomp , actual
231
+ expected = <<EOF . chomp
221
232
def too_long_function
222
233
i = 0
223
234
i += 1
@@ -230,6 +241,7 @@ def too_long_function
230
241
i += 1
231
242
i += 1
232
243
EOF
244
+ assert { actual . end_with? ( expected ) }
233
245
end
234
246
235
247
test 'line number' do
@@ -241,13 +253,14 @@ def greet_with_line_number
241
253
242
254
actual = output_of_whereami ( with_line_number : true ) { greet_with_line_number }
243
255
lineno = method ( :greet_with_line_number ) . source_location [ 1 ]
244
- assert_equal <<EOF . chomp , actual
256
+ expected = <<EOF . chomp
245
257
#{ lineno + 0 } : def greet_with_line_number
246
258
#{ lineno + 1 } : message = 'Hello, world!' # message: "Hello, world!"
247
259
=> #{ lineno + 2 } : @binding = binding
248
260
#{ lineno + 3 } : message
249
261
#{ lineno + 4 } : end
250
262
EOF
263
+ assert { actual . end_with? ( expected ) }
251
264
end
252
265
253
266
test 'too long debug info' do
@@ -258,12 +271,13 @@ def too_long_debug_info
258
271
259
272
actual = output_of_whereami ( terminal_width : 40 ) { too_long_debug_info }
260
273
# <= 40
261
- assert_equal <<EOF . chomp , actual
274
+ expected = <<EOF . chomp
262
275
def too_long_debug_info
263
276
message = '0' * 100 # message: "000000
264
277
@binding = binding
265
278
end
266
279
EOF
280
+ assert { actual . end_with? ( expected ) }
267
281
end
268
282
269
283
test 'too long debug info and line number' do
@@ -276,12 +290,13 @@ def too_long_debug_info_and_line_number
276
290
too_long_debug_info_and_line_number
277
291
end
278
292
lineno = method ( :too_long_debug_info_and_line_number ) . source_location [ 1 ]
279
- assert_equal <<EOF . chomp , actual
293
+ expected = <<EOF . chomp
280
294
#{ lineno + 0 } : def too_long_debug_info_and_line_number
281
295
#{ lineno + 1 } : message = '0' * 100 # message
282
296
=> #{ lineno + 2 } : @binding = binding
283
297
#{ lineno + 3 } : end
284
298
EOF
299
+ assert { actual . end_with? ( expected ) }
285
300
end
286
301
287
302
test 'too long debug info including wide characters' do
@@ -294,12 +309,13 @@ def too_long_debug_info_including_wide_characters
294
309
too_long_debug_info_including_wide_characters
295
310
end
296
311
# <= 40
297
- assert_equal <<EOF . chomp , actual
312
+ expected = <<EOF . chomp
298
313
def too_long_debug_info_including_wide_characters
299
314
a = 'あa' * 100 # a: "あaあaあaあaあa
300
315
@binding = binding
301
316
end
302
317
EOF
318
+ assert { actual . end_with? ( expected ) }
303
319
end
304
320
305
321
test 'too long debug info including ambigous characters' do
@@ -312,12 +328,13 @@ def too_long_debug_info_including_wide_characters
312
328
too_long_debug_info_including_wide_characters
313
329
end
314
330
# <= 41
315
- assert_equal <<EOF . chomp , actual
331
+ expected = <<EOF . chomp
316
332
def too_long_debug_info_including_wide_characters
317
333
a = 'あa☆' * 100 # a: "あa☆あa☆あa☆
318
334
@binding = binding
319
335
end
320
336
EOF
337
+ assert { actual . end_with? ( expected ) }
321
338
end
322
339
323
340
test 'min debug info width option' do
@@ -330,12 +347,13 @@ def min_debug_info
330
347
min_debug_info
331
348
end
332
349
# <= 40
333
- assert_equal <<EOF . chomp , actual
350
+ expected = <<EOF . chomp
334
351
def min_debug_info
335
352
message = '0' * 100 # message: "0000000000000000000000000000000000000000000000
336
353
@binding = binding
337
354
end
338
355
EOF
356
+ assert { actual . end_with? ( expected ) }
339
357
end
340
358
341
359
test 'first statement' do
@@ -352,7 +370,7 @@ def foo(x)
352
370
end
353
371
354
372
actual = output_of_whereami { foo ( 3 ) }
355
- assert_equal <<EOF . chomp , actual
373
+ expected = <<EOF . chomp
356
374
def foo(x)
357
375
x += 9 # x: 12
358
376
@binding = binding
@@ -361,6 +379,7 @@ def foo(x)
361
379
x
362
380
end
363
381
EOF
382
+ assert { actual . end_with? ( expected ) }
364
383
end
365
384
366
385
test 'rescue variable' do
@@ -371,13 +390,14 @@ def cause_error
371
390
end
372
391
373
392
actual = output_of_whereami { cause_error }
374
- assert_equal <<EOF . chomp , actual
393
+ expected = <<EOF . chomp
375
394
def cause_error
376
395
raise 'Hello, world!'
377
396
rescue => e # e: #<RuntimeError: Hello, world!>
378
397
@binding = binding
379
398
end
380
399
EOF
400
+ assert { actual . end_with? ( expected ) }
381
401
end
382
402
383
403
private
0 commit comments