File tree Expand file tree Collapse file tree 4 files changed +30
-5
lines changed
java/com/baeldung/chicory Expand file tree Collapse file tree 4 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 4040 <artifactId >asm-util</artifactId >
4141 <version >${asm.version} </version >
4242 </dependency >
43+ <dependency >
44+ <groupId >com.dylibso.chicory</groupId >
45+ <artifactId >runtime</artifactId >
46+ <version >${chicory.version} </version >
47+ </dependency >
4348 <!--
4449 Importing the libraries as jars using system path. These are two versions of the same library, which is generated
4550 from the code inside /incompatibleclasschange/libraries/modified and /incompatibleclasschange/libraries/original
118123 <asm .version>5.2</asm .version>
119124 <teavm .version>0.10.1</teavm .version>
120125 <objenesis .version>3.4</objenesis .version>
126+ <chicory .version>1.5.3</chicory .version>
121127 </properties >
122128
123129</project >
Original file line number Diff line number Diff line change 11package com .baeldung .chicory ;
22
3- import static org .junit .Assert .assertTrue ;
4-
3+ import com .dylibso .chicory .runtime .ExportFunction ;
4+ import com .dylibso .chicory .runtime .Instance ;
5+ import com .dylibso .chicory .wasm .Parser ;
56import org .junit .jupiter .api .Test ;
67
8+ import java .io .InputStream ;
9+
10+ import static org .junit .jupiter .api .Assertions .assertEquals ;
11+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
12+
713class ChicoryUnitTest {
814
915 @ Test
10- void whenProjectLoads_thenTestsRun () {
11- assertTrue (true );
16+ void givenAddModule_whenCallingAddWithTwoAndForty_thenResultIsFortyTwo () {
17+ InputStream wasm = getClass ().getResourceAsStream ("/wasm/add.wasm" );
18+ assertNotNull (wasm );
19+
20+ var module = Parser .parse (wasm );
21+ Instance instance = Instance .builder (module ).build ();
22+ ExportFunction add = instance .export ("add" );
23+
24+ long [] result = add .apply (2 , 40 );
25+
26+ assertEquals (42 , (int ) result [0 ]);
1227 }
1328}
14-
Original file line number Diff line number Diff line change 1+ (module
2+ (func (export " add" ) (param i32 i32 ) (result i32 )
3+ local.get 0
4+ local.get 1
5+ i32.add ))
You can’t perform that action at this time.
0 commit comments