@@ -31,12 +31,13 @@ public void AddsSigned()
3131 _ = LLVM . InitializeNativeAsmParser ( ) ;
3232 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
3333
34- var engine = module . CreateMCJITCompiler ( ) ;
34+ using var engine = module . CreateMCJITCompiler ( ) ;
3535 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( def ) ;
3636 var result = op1 + op2 ;
3737 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
3838
3939 engine . FreeMachineCodeForFunction ( def ) ;
40+ _ = engine . RemoveModule ( module ) ;
4041 }
4142
4243 [ Test ]
@@ -58,11 +59,13 @@ public void ShiftsRight([Range(0, 256)] int op1, [Range(0, 8)] int op2)
5859 _ = LLVM . InitializeNativeAsmParser ( ) ;
5960 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
6061
61- var engine = module . CreateMCJITCompiler ( ) ;
62+ using var engine = module . CreateMCJITCompiler ( ) ;
6263 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( def ) ;
6364 var result = op1 >> op2 ;
6465 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
66+
6567 engine . FreeMachineCodeForFunction ( def ) ;
68+ _ = engine . RemoveModule ( module ) ;
6669 }
6770
6871 [ Test ]
@@ -84,11 +87,13 @@ public void ComparesGreaterThan([Range(0, 10)] int op1, [Range(0, 10)] int op2)
8487 _ = LLVM . InitializeNativeAsmParser ( ) ;
8588 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
8689
87- var engine = module . CreateMCJITCompiler ( ) ;
90+ using var engine = module . CreateMCJITCompiler ( ) ;
8891 var func = engine . GetPointerToGlobal < Int32Int32Int8Delegate > ( def ) ;
8992 var result = op1 > op2 ? 1 : 0 ;
9093 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
94+
9195 engine . FreeMachineCodeForFunction ( def ) ;
96+ _ = engine . RemoveModule ( module ) ;
9297 }
9398
9499 [ Test ]
@@ -116,13 +121,14 @@ public void CallsFunction([Range(0, 10)] int op1, [Range(0, 10)] int op2)
116121 _ = LLVM . InitializeNativeAsmParser ( ) ;
117122 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
118123
119- var engine = module . CreateMCJITCompiler ( ) ;
124+ using var engine = module . CreateMCJITCompiler ( ) ;
120125 var func = engine . GetPointerToGlobal < Int32Int32Int32Delegate > ( entryDef ) ;
121126 var result = op1 + op2 ;
122127 Assert . That ( func ( op1 , op2 ) , Is . EqualTo ( result ) ) ;
123128
124129 engine . FreeMachineCodeForFunction ( entryDef ) ;
125130 engine . FreeMachineCodeForFunction ( addDef ) ;
131+ _ = engine . RemoveModule ( module ) ;
126132 }
127133
128134 [ Test ]
@@ -143,11 +149,12 @@ public void ReturnsConstant([Range(0, 10)] int input)
143149 _ = LLVM . InitializeNativeAsmParser ( ) ;
144150 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
145151
146- var engine = module . CreateMCJITCompiler ( ) ;
152+ using var engine = module . CreateMCJITCompiler ( ) ;
147153 var func = engine . GetPointerToGlobal < Int32Delegate > ( def ) ;
148154 Assert . That ( func ( ) , Is . EqualTo ( input ) ) ;
149155
150156 engine . FreeMachineCodeForFunction ( def ) ;
157+ _ = engine . RemoveModule ( module ) ;
151158 }
152159
153160 [ Test ]
@@ -169,10 +176,11 @@ public void ReturnsSizeOf()
169176 _ = LLVM . InitializeNativeAsmParser ( ) ;
170177 _ = LLVM . InitializeNativeAsmPrinter ( ) ;
171178
172- var engine = module . CreateMCJITCompiler ( ) ;
179+ using var engine = module . CreateMCJITCompiler ( ) ;
173180 var func = engine . GetPointerToGlobal < Int32Delegate > ( def ) ;
174181 Assert . That ( func ( ) , Is . EqualTo ( 8 ) ) ;
175182
176183 engine . FreeMachineCodeForFunction ( def ) ;
184+ _ = engine . RemoveModule ( module ) ;
177185 }
178186}
0 commit comments