@@ -42,4 +42,31 @@ func TestErrorUnwrap(t *testing.T) {
4242 require .NotNil (t , unwrapped )
4343 require .True (t , errors .Is (unwrapped , io .EOF ))
4444 })
45- }
45+
46+ t .Run ("Nested" , func (t * testing.T ) {
47+ err := Decorate (Decorate (testType .NewWithNoMessage (), "" ), "" )
48+ unwrapped := errors .Unwrap (err )
49+ require .NotNil (t , unwrapped )
50+ unwrapped = errors .Unwrap (unwrapped )
51+ require .NotNil (t , unwrapped )
52+ require .True (t , IsOfType (unwrapped , testType ))
53+ })
54+
55+ t .Run ("NestedWrapped" , func (t * testing.T ) {
56+ err := Decorate (testTypeBar1 .Wrap (testType .NewWithNoMessage (), "" ), "" )
57+ unwrapped := errors .Unwrap (err )
58+ require .NotNil (t , unwrapped )
59+ require .True (t , IsOfType (unwrapped , testTypeBar1 ))
60+ unwrapped = errors .Unwrap (unwrapped )
61+ require .Nil (t , unwrapped )
62+ })
63+
64+ t .Run ("NestedForeign" , func (t * testing.T ) {
65+ err := Decorate (Decorate (io .EOF , "" ), "" )
66+ unwrapped := errors .Unwrap (err )
67+ require .NotNil (t , unwrapped )
68+ unwrapped = errors .Unwrap (unwrapped )
69+ require .NotNil (t , unwrapped )
70+ require .True (t , errors .Is (unwrapped , io .EOF ))
71+ })
72+ }
0 commit comments