Skip to content

Commit 33832db

Browse files
committed
Add Empty ViewAliasTests
1 parent 8978255 commit 33832db

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Sources/OpenSwiftUI/View/ViewAlias.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ private protocol AnySourceFormula {
110110
///
111111
/// This is useful for conditionally including views in a hierarchy when their source views
112112
/// may or may not be defined.
113+
@propertyWrapper
113114
struct OptionalViewAlias<Alias>: DynamicProperty where Alias: ViewAlias {
114115
static func _makeProperty<Value>(in buffer: inout _DynamicPropertyBuffer, container: _GraphValue<Value>, fieldOffset: Int, inputs: inout _GraphInputs) {
115116
if let source = inputs[SourceInput<Alias>.self].top {
@@ -127,7 +128,7 @@ struct OptionalViewAlias<Alias>: DynamicProperty where Alias: ViewAlias {
127128
}
128129

129130
/// Indicates whether a source view has been defined for this alias.
130-
var sourceExists: Bool
131+
var sourceExists: Bool = false
131132

132133
/// Returns an instance of the alias if a source view exists, otherwise `nil`.
133134
var wrappedValue: Alias? {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// ViewAliasTests.swift
3+
// OpenSwiftUITests
4+
5+
import Testing
6+
@testable import OpenSwiftUI
7+
@_spi(ForOpenSwiftUIOnly)
8+
import OpenSwiftUICore
9+
#if os(iOS)
10+
import UIKit
11+
#endif
12+
13+
// TODO: Add viewAlias related test after style are implemented
14+
@MainActor
15+
struct ViewAliasTests {
16+
// struct CustomView: View {
17+
// struct Alias: ViewAlias {
18+
// init() {}
19+
// }
20+
// }
21+
// @Test
22+
// func optionalViewAliasDynamicProperty() {
23+
// struct ContentView: View {
24+
// @OptionalViewAlias
25+
// private var alias: CustomView.Alias?
26+
//
27+
// var body: some View {
28+
// CustomView()
29+
// .viewAlias(CustomView.Alias.self) {
30+
// Color.red
31+
// }
32+
// }
33+
// }
34+
// #if os(iOS)
35+
// let hostingView = _UIHostingView(rootView: ContentView())
36+
// hostingView.render()
37+
// #endif
38+
// }
39+
}

0 commit comments

Comments
 (0)