Skip to content

Commit d2db08f

Browse files
committed
[Diagnostics] Make the experimental formatting tests less fragile
1 parent d87e913 commit d2db08f

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

test/diagnostics/pretty-printed-diagnostics.swift

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func baz() {
1313
bar(a: "hello, world!")
1414
}
1515

16-
struct Foo: Codable {
16+
struct Foo {
1717
var x: Int
1818
var x: Int
1919
}
@@ -39,6 +39,10 @@ let x = {
3939
return y
4040
}
4141
42+
struct B: Decodable {
43+
let a: Foo
44+
}
45+
4246
// Test fallback for non-ASCII characters.
4347
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:35:11
4448
// CHECK: 34 |
@@ -64,34 +68,13 @@ let x = {
6468

6569

6670
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:18:7
67-
// CHECK: 16 | struct Foo: Codable {
71+
// CHECK: 16 | struct Foo {
6872
// CHECK: 17 | var x: Int
6973
// CHECK: | ^ note: 'x' previously declared here
7074
// CHECK: 18 | var x: Int
7175
// CHECK: | ^ error: invalid redeclaration of 'x'
7276
// CHECK: 19 | }
7377

74-
// Test fallback for invalid locations.
75-
// CHECK: Unknown Location
76-
// CHECK: | error: invalid redeclaration of 'x'
77-
// CHECK: | note: 'x' previously declared here
78-
79-
// Test cross-file and decl anchored diagnostics.
80-
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:16:8
81-
// CHECK: 15 |
82-
// CHECK: 16 | struct Foo: Codable {
83-
// CHECK: | ^ error: type 'Foo' does not conform to protocol 'Encodable'
84-
// CHECK: 17 | var x: Int
85-
// CHECK: 18 | var x: Int
86-
// CHECK: | ^ note: cannot automatically synthesize 'Encodable' because
87-
// CHECK: | ^ note: cannot automatically synthesize 'Encodable' because
88-
// CHECK: 19 | }
89-
// CHECK: Swift.Encodable:2:10
90-
// CHECK: 1 | public protocol Encodable {
91-
// CHECK: 2 | func encode(to encoder: Encoder) throws
92-
// CHECK: | ^ note: protocol requires function 'encode(to:)' with type 'Encodable'
93-
// CHECK: 3 | }
94-
9578
// Test out-of-line fix-its on notes.
9679
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:28:1
9780
// CHECK: 27 | }
@@ -125,6 +108,19 @@ let x = {
125108
// CHECK: | ^ error: unable to infer complex closure return type; add explicit type to disambiguate
126109
// CHECK: 38 | let y = 1
127110

111+
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:42:8
112+
// CHECK: 41 |
113+
// CHECK: 42 | struct B: Decodable {
114+
// CHECK: | ^ error: type 'B' does not conform to protocol 'Decodable'
115+
// CHECK: 43 | let a: Foo
116+
// CHECK: | ^ note: cannot automatically synthesize 'Decodable' because 'Foo' does not conform to 'Decodable'
117+
// CHECK: 44 | }
118+
// CHECK: Swift.Decodable:2:5
119+
// CHECK: 1 | public protocol Decodable {
120+
// CHECK: 2 | init(from decoder: Decoder) throws
121+
// CHECK: | ^ note: protocol requires initializer 'init(from:)' with type 'Decodable'
122+
// CHECK: 3 | }
123+
128124
// CHECK: SOURCE_DIR/test/diagnostics/pretty-printed-diagnostics.swift:6:5
129125
// CHECK: 5 | func foo(a: Int, b: Int) {
130126
// CHECK: 6 | a + b

0 commit comments

Comments
 (0)