@@ -7,6 +7,7 @@ package xerrors_test
7
7
import (
8
8
"fmt"
9
9
"io"
10
+ "os"
10
11
"path"
11
12
"reflect"
12
13
"regexp"
@@ -90,7 +91,7 @@ func TestErrorFormatter(t *testing.T) {
90
91
nonascii = & wrapped {"café" , nil }
91
92
newline = & wrapped {"msg with\n newline" ,
92
93
& wrapped {"and another\n one" , nil }}
93
- fallback = & wrapped {"fallback" , xerrors . New ( "file does not exist" ) }
94
+ fallback = & wrapped {"fallback" , os . ErrNotExist }
94
95
oldAndNew = & wrapped {"new style" , formatError ("old style" )}
95
96
framed = & withFrameAndMore {
96
97
frame : xerrors .Caller (0 ),
@@ -105,13 +106,6 @@ func TestErrorFormatter(t *testing.T) {
105
106
want string
106
107
regexp bool
107
108
}{{
108
- err : xerrors .New ("foo" ),
109
- fmt : "%+v" ,
110
- want : "foo:" +
111
- "\n golang.org/x/xerrors_test.TestErrorFormatter" +
112
- "\n .+/golang.org/x/xerrors/fmt_test.go:1\\ d\\ d" ,
113
- regexp : true ,
114
- }, {
115
109
err : simple ,
116
110
fmt : "%s" ,
117
111
want : "simple" ,
@@ -162,7 +156,7 @@ func TestErrorFormatter(t *testing.T) {
162
156
fmt : "%+v" ,
163
157
want : "something:" +
164
158
"\n golang.org/x/xerrors_test.TestErrorFormatter" +
165
- "\n .+/fmt_test.go:9 \\ d " +
159
+ "\n .+/fmt_test.go:97 " +
166
160
"\n something more" ,
167
161
regexp : true ,
168
162
}, {
@@ -179,10 +173,7 @@ func TestErrorFormatter(t *testing.T) {
179
173
// Note: no colon after the last error, as there are no details.
180
174
want : "fallback:" +
181
175
"\n somefile.go:123" +
182
- "\n - file does not exist:" +
183
- "\n golang.org/x/xerrors_test.TestErrorFormatter" +
184
- "\n .+/golang.org/x/xerrors/fmt_test.go:9\\ d" ,
185
- regexp : true ,
176
+ "\n - file does not exist" ,
186
177
}, {
187
178
err : opaque ,
188
179
fmt : "%s" ,
@@ -290,12 +281,12 @@ func TestErrorFormatter(t *testing.T) {
290
281
err : simple ,
291
282
fmt : "%T" ,
292
283
want : "*xerrors_test.wrapped" ,
293
- // }, {
294
- // // The behavior for this case is different between go1.12 and go1.13.
295
- // err : simple ,
296
- // fmt: "%🤪 ",
297
- // want: "%!🤪(*xerrors_test.wrapped=&{simple <nil>})", // go1.12
298
- // want: "&{ %!🤪(string= simple) <nil>}", // go1.13
284
+ }, {
285
+ err : simple ,
286
+ fmt : "%🤪" ,
287
+ want : "%!🤪(*xerrors_test.wrapped) " ,
288
+ // For 1.13:
289
+ // want: "%!🤪(*xerrors_test.wrapped=&{ simple <nil>})",
299
290
}, {
300
291
err : formatError ("use fmt.Formatter" ),
301
292
fmt : "%#v" ,
0 commit comments