File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Tests/OpenAttributeGraphCompatibilityTests/Attribute/Attribute Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,37 @@ struct AttributeCompatibilityTests {
1414 #expect( intAttribute. value == 0 )
1515 }
1616
17+ @Test
18+ func initWithRule( ) {
19+ struct TestRule : Rule {
20+ var value : Int {
21+ return 0
22+ }
23+ }
24+ let attribute1 = Attribute ( TestRule ( ) )
25+ #expect( attribute1. value == 0 )
26+
27+ let attribute2 = Attribute ( TestRule ( ) , initialValue: 1 )
28+ #expect( attribute2. value == 1 )
29+ }
30+
31+ @Test
32+ func initWithStatefulRule( ) {
33+ struct TestStatefuleRule : StatefulRule {
34+ typealias Value = Int
35+ func updateValue( ) {
36+ withUnsafePointer ( to: 0 ) { ptr in
37+ Graph . setOutputValue ( ptr)
38+ }
39+ }
40+ }
41+ let attribute1 = Attribute ( TestStatefuleRule ( ) )
42+ #expect( attribute1. value == 0 )
43+
44+ let attribute2 = Attribute ( TestStatefuleRule ( ) , initialValue: 1 )
45+ #expect( attribute2. value == 1 )
46+ }
47+
1748 @Test
1849 func hashableAndEquatable( ) {
1950 let a = Attribute < Int > ( identifier: . nil )
You can’t perform that action at this time.
0 commit comments