|
Revision 1921, 1.0 kB
(checked in by nahi, 1 year ago)
|
|
| Line | |
|---|
| 1 |
require 'test/unit' |
|---|
| 2 |
require 'soap/soap' |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
module SOAP |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
class TestNestedException < Test::Unit::TestCase |
|---|
| 9 |
class MyError < SOAP::Error; end |
|---|
| 10 |
|
|---|
| 11 |
def foo |
|---|
| 12 |
begin |
|---|
| 13 |
bar |
|---|
| 14 |
rescue |
|---|
| 15 |
raise MyError.new("foo", $!) |
|---|
| 16 |
end |
|---|
| 17 |
end |
|---|
| 18 |
|
|---|
| 19 |
def bar |
|---|
| 20 |
begin |
|---|
| 21 |
baz |
|---|
| 22 |
rescue |
|---|
| 23 |
raise MyError.new("bar", $!) |
|---|
| 24 |
end |
|---|
| 25 |
end |
|---|
| 26 |
|
|---|
| 27 |
def baz |
|---|
| 28 |
raise MyError.new("baz", $!) |
|---|
| 29 |
end |
|---|
| 30 |
|
|---|
| 31 |
def test_nestedexception |
|---|
| 32 |
begin |
|---|
| 33 |
foo |
|---|
| 34 |
rescue MyError => e |
|---|
| 35 |
trace = e.backtrace.find_all { |line| /test\/unit/ !~ line && /\d\z/ !~ line } |
|---|
| 36 |
trace = trace.map { |line| line.sub(/\A[^:]*/, '') } |
|---|
| 37 |
assert_equal(TOBE, trace) |
|---|
| 38 |
end |
|---|
| 39 |
end |
|---|
| 40 |
|
|---|
| 41 |
TOBE = [ |
|---|
| 42 |
":15:in `foo'", |
|---|
| 43 |
":33:in `test_nestedexception'", |
|---|
| 44 |
":23:in `bar': bar (SOAP::TestNestedException::MyError) [NESTED]", |
|---|
| 45 |
":13:in `foo'", |
|---|
| 46 |
":33:in `test_nestedexception'", |
|---|
| 47 |
":28:in `baz': baz (SOAP::TestNestedException::MyError) [NESTED]", |
|---|
| 48 |
":21:in `bar'", |
|---|
| 49 |
":13:in `foo'", |
|---|
| 50 |
":33:in `test_nestedexception'", |
|---|
| 51 |
] |
|---|
| 52 |
|
|---|
| 53 |
end |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
end |
|---|