@@ -19,15 +19,94 @@ struct InterpolationTests {
1919 #expect( string == " <a href= \" \( test) \" >Test</a> " )
2020 }
2121
22- @Test func multiline_with_interpolation ( ) {
23- let test : String = " again "
22+ @Test func multiline_decl_interpolation ( ) {
23+ let test : String = " prophecy "
2424 let string : String = #html(
2525 div (
2626 " dune " ,
2727 test
2828 )
2929 )
30- #expect( string == " <div>dune again</div> " )
30+ #expect( string == " <div>dune prophecy</div> " )
31+ }
32+
33+ @Test func multiline_func_interpolation( ) {
34+ var string : String = #html(
35+ div (
36+ " Bikini Bottom: " ,
37+ InterpolationTests . spongebobCharacter (
38+ " spongebob "
39+ ) ,
40+ " , " ,
41+ InterpolationTests . spongebobCharacter ( " patrick "
42+ ) ,
43+ " , " ,
44+ InterpolationTests . spongebobCharacter (
45+ " squidward " ) ,
46+ " , " ,
47+ InterpolationTests
48+ . spongebobCharacter (
49+ " krabs "
50+ ) ,
51+ " , " ,
52+ InterpolationTests . sandyCheeks ( ) ,
53+ " , " ,
54+ InterpolationTests
55+ . spongebobCharacter (
56+ " pearl krabs "
57+ )
58+ )
59+ )
60+ #expect( string == " <div>Bikini Bottom: Spongebob Squarepants, Patrick Star, Squidward Tentacles, Mr. Krabs, Sandy Cheeks, Pearl Krabs</div> " )
61+
62+ string = #html(
63+ div (
64+ " Don't forget " ,
65+ InterpolationTests . BikiniBottom. gary ( ) ,
66+ " ! "
67+ )
68+ )
69+ #expect( string == " <div>Don't forget Gary!</div> " )
70+
71+ string = #html(
72+ div (
73+ InterpolationTests
74+ . spongebob (
75+ isBoob: false ,
76+ isSquare:
77+ true ,
78+ middleName: Shrek
79+ . isLife
80+ . rawValue,
81+ lastName: InterpolationTests
82+ . sandyCheeks ( )
83+ )
84+ )
85+ )
86+ #expect( string == " <div>Spongeboob</div> " )
87+ }
88+
89+ @Test func multiline_member_interpolation( ) {
90+ var string : String = #html(
91+ div (
92+ " Shrek " ,
93+ Shrek . isLove. rawValue,
94+ " , Shrek " ,
95+ Shrek
96+ . isLife. rawValue
97+ )
98+ )
99+ #expect( string == " <div>Shrek isLove, Shrek isLife</div> " )
100+
101+ string = #html(
102+ div (
103+ " Shrek " ,
104+ InterpolationTests . Shrek. isLove. rawValue,
105+ " , Shrek " ,
106+ InterpolationTests . Shrek. isLife. rawValue
107+ )
108+ )
109+ #expect( string == " <div>Shrek isLove, Shrek isLife</div> " )
31110 }
32111
33112 @Test func flatten( ) {
@@ -72,15 +151,28 @@ extension InterpolationTests {
72151}
73152
74153extension InterpolationTests {
154+ enum BikiniBottom {
155+ static func gary( ) -> String { " Gary " }
156+ }
75157 static let spongebob : String = " Spongebob Squarepants "
76158 static let patrick : String = " Patrick Star "
77159 static func spongebobCharacter( _ string: String ) -> String {
78160 switch string {
79161 case " spongebob " : return " Spongebob Squarepants "
80162 case " patrick " : return " Patrick Star "
163+ case " squidward " : return " Squidward Tentacles "
164+ case " krabs " : return " Mr. Krabs "
165+ case " pearl krabs " : return " Pearl Krabs "
166+ case " karen " : return " Karen "
81167 default : return " Plankton "
82168 }
83169 }
170+ static func sandyCheeks( ) -> String {
171+ return " Sandy Cheeks "
172+ }
173+ static func spongebob( isBoob: Bool , isSquare: Bool , middleName: String , lastName: String ) -> String {
174+ return " Spongeboob "
175+ }
84176
85177 @Test func third_party_literal( ) {
86178 var string : String = #html( div ( attributes: [ . title( InterpolationTests . spongebob) ] ) )
@@ -89,11 +181,11 @@ extension InterpolationTests {
89181 string = #html( div ( attributes: [ . title( InterpolationTests . patrick) ] ) )
90182 #expect( string == " <div title= \" Patrick Star \" ></div> " )
91183
92- var static_string : StaticString = #html( div ( attributes: [ . title( " Mr. Crabs " ) ] ) )
93- #expect( static_string == " <div title= \" Mr. Crabs \" ></div> " )
184+ var static_string : StaticString = #html( div ( attributes: [ . title( " Mr. Krabs " ) ] ) )
185+ #expect( static_string == " <div title= \" Mr. Krabs \" ></div> " )
94186
95- static_string = #html( div ( attributes: [ . title( " Mr. Crabs " ) ] ) )
96- #expect( static_string == " <div title= \" Mr. Crabs \" ></div> " )
187+ static_string = #html( div ( attributes: [ . title( " Mr. Krabs " ) ] ) )
188+ #expect( static_string == " <div title= \" Mr. Krabs \" ></div> " )
97189 }
98190 @Test func third_party_func( ) {
99191 let string : String = #html( div ( attributes: [ . title( InterpolationTests . spongebobCharacter ( " patrick " ) ) ] ) )
0 commit comments