|
35 | 35 | struct FeatureView: View { |
36 | 36 | let model = Model() |
37 | 37 | var body: some View { |
38 | | - Text(expectRuntimeWarning { model.count }.description) |
| 38 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
39 | 39 | } |
40 | 40 | } |
41 | 41 | try await render(FeatureView()) |
|
47 | 47 | let model = Model() |
48 | 48 | var body: some View { |
49 | 49 | Wrapper { |
50 | | - Text(expectRuntimeWarning { model.count }.description) |
| 50 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
|
88 | 88 | @Perception.Bindable var model: Model |
89 | 89 | var body: some View { |
90 | 90 | Form { |
91 | | - TextField("", text: expectRuntimeWarning { $model.text }) |
| 91 | + TextField("", text: expectRuntimeWarning(on: #"\Model.text"#) { $model.text }) |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | 95 | #if os(macOS) |
96 | 96 | // NB: This failure is triggered out-of-body by the binding. |
97 | | - XCTExpectFailure { $0.compactDescription.contains("Perceptible state was accessed") } |
| 97 | + XCTExpectFailure { $0.compactDescription.contains(#"Perceptible state '\Model.text' was accessed"#) } |
98 | 98 | #endif |
99 | 99 | try await render(FeatureView(model: Model())) |
100 | 100 | } |
|
117 | 117 | struct FeatureView: View { |
118 | 118 | let model: Model |
119 | 119 | var body: some View { |
120 | | - ForEach(expectRuntimeWarning { model.list }) { model in |
121 | | - Text(expectRuntimeWarning { model.count }.description) |
| 120 | + ForEach(expectRuntimeWarning(on: #"\Model.list"#) { model.list }) { model in |
| 121 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
|
141 | 141 | struct FeatureView: View { |
142 | 142 | let model: Model |
143 | 143 | var body: some View { |
144 | | - ForEach(expectRuntimeWarning { model.list }) { model in |
| 144 | + ForEach(expectRuntimeWarning(on: #"\Model.list"#) { model.list }) { model in |
145 | 145 | WithPerceptionTracking { |
146 | 146 | Text(model.count.description) |
147 | 147 | } |
|
169 | 169 | var body: some View { |
170 | 170 | WithPerceptionTracking { |
171 | 171 | ForEach(model.list) { model in |
172 | | - Text(expectRuntimeWarning { model.count }.description) |
| 172 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
|
222 | 222 | @Perception.Bindable var model: Model |
223 | 223 | var body: some View { |
224 | 224 | Text("Parent") |
225 | | - .sheet(item: expectRuntimeWarning { $model.child }) { child in |
226 | | - Text(expectRuntimeWarning { child.count }.description) |
| 225 | + .sheet(item: expectRuntimeWarning(on: #"\Model.child"#) { $model.child }) { child in |
| 226 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { child.count }.description) |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | // NB: This failure is triggered out-of-body by the binding. |
231 | | - XCTExpectFailure { $0.compactDescription.contains("Perceptible state was accessed") } |
| 231 | + XCTExpectFailure { $0.compactDescription.contains(#"Perceptible state '\Model.child' was accessed"#) } |
232 | 232 | try await render(FeatureView(model: Model(child: Model()))) |
233 | 233 | } |
234 | 234 |
|
|
238 | 238 | @Perception.Bindable var model: Model |
239 | 239 | var body: some View { |
240 | 240 | Text("Parent") |
241 | | - .sheet(item: expectRuntimeWarning { $model.child }) { child in |
| 241 | + .sheet(item: expectRuntimeWarning(on: #"\Model.child"#) { $model.child }) { child in |
242 | 242 | WithPerceptionTracking { |
243 | 243 | Text(child.count.description) |
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
248 | 248 | // NB: This failure is triggered out-of-body by the binding. |
249 | | - XCTExpectFailure { $0.compactDescription.contains("Perceptible state was accessed") } |
| 249 | + XCTExpectFailure { $0.compactDescription.contains(#"Perceptible state '\Model.child' was accessed"#) } |
250 | 250 | try await render(FeatureView(model: Model(child: Model()))) |
251 | 251 | } |
252 | 252 |
|
|
258 | 258 | WithPerceptionTracking { |
259 | 259 | Text("Parent") |
260 | 260 | .sheet(item: $model.child) { child in |
261 | | - Text(expectRuntimeWarning { child.count }.description) |
| 261 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { child.count }.description) |
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
|
384 | 384 | var body: some View { |
385 | 385 | VStack { |
386 | 386 | ChildView(model: self.childModel) |
387 | | - Text(expectRuntimeWarning { childModel.count }.description) |
| 387 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { childModel.count }.description) |
388 | 388 | } |
389 | 389 | .onAppear { let _ = childModel.count } |
390 | 390 | } |
|
398 | 398 | struct ChildView: View { |
399 | 399 | let model: Model |
400 | 400 | var body: some View { |
401 | | - Text(expectRuntimeWarning { model.count }.description) |
| 401 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
402 | 402 | .onAppear { let _ = model.count } |
403 | 403 | } |
404 | 404 | } |
|
426 | 426 | struct ChildView: View { |
427 | 427 | let model: Model |
428 | 428 | var body: some View { |
429 | | - Text(expectRuntimeWarning { model.count }.description) |
| 429 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
430 | 430 | .onAppear { let _ = model.count } |
431 | 431 | } |
432 | 432 | } |
|
440 | 440 | var body: some View { |
441 | 441 | VStack { |
442 | 442 | ChildView(model: self.childModel) |
443 | | - Text(expectRuntimeWarning { childModel.count }.description) |
| 443 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { childModel.count }.description) |
444 | 444 | } |
445 | 445 | .onAppear { let _ = childModel.count } |
446 | 446 | } |
|
535 | 535 | var body: some View { |
536 | 536 | WithPerceptionTracking { |
537 | 537 | GeometryReader { _ in |
538 | | - Text(expectRuntimeWarning { model.count }.description) |
| 538 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
539 | 539 | } |
540 | 540 | } |
541 | 541 | } |
|
569 | 569 | } |
570 | 570 | var content: some View { |
571 | 571 | GeometryReader { _ in |
572 | | - Text(expectRuntimeWarning { model.count }.description) |
| 572 | + Text(expectRuntimeWarning(on: #"\Model.count"#) { model.count }.description) |
573 | 573 | } |
574 | 574 | } |
575 | 575 | } |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 |
|
616 | | - private func expectRuntimeWarning<R>(failingBlock: () -> R) -> R { |
| 616 | + private func expectRuntimeWarning<R>(on keyPathString: String, failingBlock: () -> R) -> R { |
617 | 617 | XCTExpectFailure(failingBlock: failingBlock) { |
618 | | - $0.compactDescription.contains("Perceptible state was accessed") |
| 618 | + $0.compactDescription.contains("Perceptible state '\(keyPathString)' was accessed") |
619 | 619 | } |
620 | 620 | } |
621 | 621 |
|
|
0 commit comments