1616
1717import org .junit .jupiter .api .Test ;
1818import org .swift .swiftkit .core .ConfinedSwiftMemorySession ;
19+ import org .swift .swiftkit .core .SwiftArena ;
1920
21+ import java .lang .foreign .Arena ;
2022import java .util .Optional ;
2123import java .util .OptionalInt ;
2224
2527public class VehicleEnumTest {
2628 @ Test
2729 void bicycle () {
28- try (var arena = new ConfinedSwiftMemorySession ()) {
30+ try (var arena = SwiftArena . ofConfined ()) {
2931 Vehicle vehicle = Vehicle .bicycle (arena );
3032 assertNotNull (vehicle );
3133 }
3234 }
3335
3436 @ Test
3537 void car () {
36- try (var arena = new ConfinedSwiftMemorySession ()) {
38+ try (var arena = SwiftArena . ofConfined ()) {
3739 Vehicle vehicle = Vehicle .car ("Porsche 911" , Optional .empty (), arena );
3840 assertNotNull (vehicle );
3941 }
4042 }
4143
4244 @ Test
4345 void motorbike () {
44- try (var arena = new ConfinedSwiftMemorySession ()) {
46+ try (var arena = SwiftArena . ofConfined ()) {
4547 Vehicle vehicle = Vehicle .motorbike ("Yamaha" , 750 , OptionalInt .empty (), arena );
4648 assertNotNull (vehicle );
4749 }
4850 }
4951
5052 @ Test
5153 void initName () {
52- try (var arena = new ConfinedSwiftMemorySession ()) {
54+ try (var arena = SwiftArena . ofConfined ()) {
5355 assertFalse (Vehicle .init ("bus" , arena ).isPresent ());
5456 Optional <Vehicle > vehicle = Vehicle .init ("car" , arena );
5557 assertTrue (vehicle .isPresent ());
@@ -59,15 +61,15 @@ void initName() {
5961
6062 @ Test
6163 void nameProperty () {
62- try (var arena = new ConfinedSwiftMemorySession ()) {
64+ try (var arena = SwiftArena . ofConfined ()) {
6365 Vehicle vehicle = Vehicle .bicycle (arena );
6466 assertEquals ("bicycle" , vehicle .getName ());
6567 }
6668 }
6769
6870 @ Test
6971 void isFasterThan () {
70- try (var arena = new ConfinedSwiftMemorySession ()) {
72+ try (var arena = SwiftArena . ofConfined ()) {
7173 Vehicle bicycle = Vehicle .bicycle (arena );
7274 Vehicle car = Vehicle .car ("Porsche 911" , Optional .empty (), arena );
7375 assertFalse (bicycle .isFasterThan (car ));
@@ -77,7 +79,7 @@ void isFasterThan() {
7779
7880 @ Test
7981 void upgrade () {
80- try (var arena = new ConfinedSwiftMemorySession ()) {
82+ try (var arena = SwiftArena . ofConfined ()) {
8183 Vehicle vehicle = Vehicle .bicycle (arena );
8284 assertEquals ("bicycle" , vehicle .getName ());
8385 vehicle .upgrade ();
@@ -89,7 +91,7 @@ void upgrade() {
8991
9092 @ Test
9193 void getAsBicycle () {
92- try (var arena = new ConfinedSwiftMemorySession ()) {
94+ try (var arena = SwiftArena . ofConfined ()) {
9395 Vehicle vehicle = Vehicle .bicycle (arena );
9496 Vehicle .Bicycle bicycle = vehicle .getAsBicycle ().orElseThrow ();
9597 assertNotNull (bicycle );
@@ -98,7 +100,7 @@ void getAsBicycle() {
98100
99101 @ Test
100102 void getAsCar () {
101- try (var arena = new ConfinedSwiftMemorySession ()) {
103+ try (var arena = SwiftArena . ofConfined ()) {
102104 Vehicle vehicle = Vehicle .car ("BMW" , Optional .empty (), arena );
103105 Vehicle .Car car = vehicle .getAsCar ().orElseThrow ();
104106 assertEquals ("BMW" , car .arg0 ());
@@ -111,7 +113,7 @@ void getAsCar() {
111113
112114 @ Test
113115 void getAsMotorbike () {
114- try (var arena = new ConfinedSwiftMemorySession ()) {
116+ try (var arena = SwiftArena . ofConfined ()) {
115117 Vehicle vehicle = Vehicle .motorbike ("Yamaha" , 750 , OptionalInt .empty (), arena );
116118 Vehicle .Motorbike motorbike = vehicle .getAsMotorbike ().orElseThrow ();
117119 assertEquals ("Yamaha" , motorbike .arg0 ());
@@ -126,7 +128,7 @@ void getAsMotorbike() {
126128
127129 @ Test
128130 void getAsTransformer () {
129- try (var arena = new ConfinedSwiftMemorySession ()) {
131+ try (var arena = SwiftArena . ofConfined ()) {
130132 Vehicle vehicle = Vehicle .transformer (Vehicle .bicycle (arena ), Vehicle .car ("BMW" , Optional .empty (), arena ), arena );
131133 Vehicle .Transformer transformer = vehicle .getAsTransformer (arena ).orElseThrow ();
132134 assertTrue (transformer .front ().getAsBicycle ().isPresent ());
@@ -136,7 +138,7 @@ void getAsTransformer() {
136138
137139 @ Test
138140 void getAsBoat () {
139- try (var arena = new ConfinedSwiftMemorySession ()) {
141+ try (var arena = SwiftArena . ofConfined ()) {
140142 Vehicle vehicle = Vehicle .boat (OptionalInt .of (10 ), Optional .of ((short ) 1 ), arena );
141143 Vehicle .Boat boat = vehicle .getAsBoat ().orElseThrow ();
142144 assertEquals (OptionalInt .of (10 ), boat .passengers ());
@@ -146,7 +148,7 @@ void getAsBoat() {
146148
147149 @ Test
148150 void associatedValuesAreCopied () {
149- try (var arena = new ConfinedSwiftMemorySession ()) {
151+ try (var arena = SwiftArena . ofConfined ()) {
150152 Vehicle vehicle = Vehicle .car ("BMW" , Optional .empty (), arena );
151153 Vehicle .Car car = vehicle .getAsCar ().orElseThrow ();
152154 assertEquals ("BMW" , car .arg0 ());
@@ -160,7 +162,7 @@ void associatedValuesAreCopied() {
160162
161163 @ Test
162164 void getDiscriminator () {
163- try (var arena = new ConfinedSwiftMemorySession ()) {
165+ try (var arena = SwiftArena . ofConfined ()) {
164166 assertEquals (Vehicle .Discriminator .BICYCLE , Vehicle .bicycle (arena ).getDiscriminator ());
165167 assertEquals (Vehicle .Discriminator .CAR , Vehicle .car ("BMW" , Optional .empty (), arena ).getDiscriminator ());
166168 assertEquals (Vehicle .Discriminator .MOTORBIKE , Vehicle .motorbike ("Yamaha" , 750 , OptionalInt .empty (), arena ).getDiscriminator ());
@@ -170,7 +172,7 @@ void getDiscriminator() {
170172
171173 @ Test
172174 void getCase () {
173- try (var arena = new ConfinedSwiftMemorySession ()) {
175+ try (var arena = SwiftArena . ofConfined ()) {
174176 Vehicle vehicle = Vehicle .bicycle (arena );
175177 Vehicle .Case caseElement = vehicle .getCase (arena );
176178 assertInstanceOf (Vehicle .Bicycle .class , caseElement );
@@ -179,7 +181,7 @@ void getCase() {
179181
180182 @ Test
181183 void switchGetCase () {
182- try (var arena = new ConfinedSwiftMemorySession ()) {
184+ try (var arena = SwiftArena . ofConfined ()) {
183185 Vehicle vehicle = Vehicle .car ("BMW" , Optional .empty (), arena );
184186 switch (vehicle .getCase (arena )) {
185187 case Vehicle .Bicycle b :
0 commit comments