File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ // REQUIRES: swift_swift_parser, executable_test
2
+
3
+ // RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking -enable-experimental-feature InitAccessors -enable-experimental-feature Macros -Xfrontend -plugin-path -Xfrontend %swift-host-lib-dir/plugins) | %FileCheck %s
4
+
5
+ // Asserts is required for '-enable-experimental-feature InitAccessors'.
6
+ // REQUIRES: asserts
7
+
8
+ // REQUIRES: observation
9
+ // REQUIRES: concurrency
10
+ // REQUIRES: objc_interop
11
+ // UNSUPPORTED: use_os_stdlib
12
+ // UNSUPPORTED: back_deployment_runtime
13
+
14
+ import _Observation
15
+
16
+ @Observable
17
+ public class Model {
18
+ public enum State {
19
+ case initializing
20
+ case running
21
+ case complete
22
+ }
23
+
24
+ public var state : State = . initializing {
25
+ willSet {
26
+ print ( " new state= \( String ( describing: newValue) ) " )
27
+ }
28
+
29
+ didSet {
30
+ guard oldValue != state else { return }
31
+ print ( " old state= \( String ( describing: oldValue) ) " )
32
+ }
33
+ }
34
+ }
35
+
36
+
37
+ let m = Model ( )
38
+
39
+ // CHECK: new state=running
40
+ // CHECK: old state=initializing
41
+ m. state = . running
42
+ // CHECK: new state=complete
43
+ // CHECK: old state=running
44
+ m. state = . complete
You can’t perform that action at this time.
0 commit comments