You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/ruby/core/kernel/raise_spec.rb
+78Lines changed: 78 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -203,6 +203,84 @@
203
203
e.cause.should == e1
204
204
end
205
205
end
206
+
207
+
it"re-raises a previously rescued exception that doesn't have a cause and isn't a cause of any other exception with setting a cause implicitly"do
208
+
begin
209
+
begin
210
+
raise"Error 1"
211
+
rescue=>e1
212
+
begin
213
+
raise"Error 2"
214
+
rescue=>e2
215
+
raise"Error 3"
216
+
end
217
+
end
218
+
rescue=>e
219
+
e.message.should == "Error 3"
220
+
e.cause.should == e2
221
+
end
222
+
end
223
+
224
+
it"re-raises a previously rescued exception that doesn't have a cause and is a cause of other exception without setting a cause implicitly"do
225
+
begin
226
+
begin
227
+
raise"Error 1"
228
+
rescue=>e1
229
+
begin
230
+
raise"Error 2"
231
+
rescue=>e2
232
+
e1.cause.should == nil
233
+
e2.cause.should == e1
234
+
raisee1
235
+
end
236
+
end
237
+
rescue=>e
238
+
e.should == e1
239
+
e.cause.should == nil
240
+
end
241
+
end
242
+
243
+
it"re-raises a previously rescued exception that doesn't have a cause and is a cause of other exception (that wasn't raised explicitly) without setting a cause implicitly"do
244
+
begin
245
+
begin
246
+
raise"Error 1"
247
+
rescue=>e1
248
+
begin
249
+
foo# raises NameError
250
+
rescue=>e2
251
+
e1.cause.should == nil
252
+
e2.cause.should == e1
253
+
raisee1
254
+
end
255
+
end
256
+
rescue=>e
257
+
e.should == e1
258
+
e.cause.should == nil
259
+
end
260
+
end
261
+
262
+
it"re-raises a previously rescued exception that has a cause but isn't a cause of any other exception without setting a cause implicitly"do
0 commit comments