File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Tests/AssociatedObjectTests Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,38 @@ final class AssociatedObjectTests: XCTestCase {
7272 )
7373 }
7474
75+ func testStringWithOtherPolicy( ) throws {
76+ assertMacroExpansion (
77+ """
78+ @AssociatedObject(.OBJC_ASSOCIATION_COPY)
79+ var string: String = " text "
80+ """ ,
81+ expandedSource:
82+ """
83+ var string: String = " text " {
84+ get {
85+ objc_getAssociatedObject(
86+ self,
87+ &Self.__associated_stringKey
88+ ) as? String
89+ ?? " text "
90+ }
91+ set {
92+ objc_setAssociatedObject(
93+ self,
94+ &Self.__associated_stringKey,
95+ newValue,
96+ .OBJC_ASSOCIATION_COPY
97+ )
98+ }
99+ }
100+
101+ static var __associated_stringKey: UInt8 = 0
102+ """ ,
103+ macros: macros
104+ )
105+ }
106+
75107 func testOptionalString( ) throws {
76108 assertMacroExpansion (
77109 """
You can’t perform that action at this time.
0 commit comments