Skip to content

Commit c3a70f4

Browse files
authored
Add missing tests for v2 and v3 providers (#396)
1 parent 2be810c commit c3a70f4

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/engine.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,34 @@ mod tests {
263263
assert_eq!(function_run_result.unwrap().memory_usage, 1280);
264264
}
265265

266+
#[test]
267+
fn test_js_v2_function() {
268+
let input = include_bytes!("../tests/fixtures/input/js_function_input.json").to_vec();
269+
let function_run_result = run(FunctionRunParams {
270+
function_path: Path::new("tests/fixtures/build/js_function_v2.wasm").to_path_buf(),
271+
input,
272+
export: DEFAULT_EXPORT,
273+
..Default::default()
274+
});
275+
276+
assert!(function_run_result.is_ok());
277+
assert_eq!(function_run_result.unwrap().memory_usage, 1344);
278+
}
279+
280+
#[test]
281+
fn test_js_v3_function() {
282+
let input = include_bytes!("../tests/fixtures/input/js_function_input.json").to_vec();
283+
let function_run_result = run(FunctionRunParams {
284+
function_path: Path::new("tests/fixtures/build/js_function_v3.wasm").to_path_buf(),
285+
input,
286+
export: DEFAULT_EXPORT,
287+
..Default::default()
288+
});
289+
290+
assert!(function_run_result.is_ok());
291+
assert_eq!(function_run_result.unwrap().memory_usage, 1344);
292+
}
293+
266294
#[test]
267295
fn test_exit_code_zero() {
268296
let function_run_result = run(FunctionRunParams {

tests/fixtures/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ cargo wasi build --profile=wasm -p exit_code -p exports -p log_truncation_functi
1515
cp target/wasm32-wasi/wasm/{exit_code.wasm,exports.wasm,log_truncation_function.wasm} tests/fixtures/build
1616
```
1717

18+
**JS examples:**
19+
20+
js_function_v2.wasm:
21+
```
22+
javy compile -d -o tests/fixtures/build/js_function_v2.wasm tests/fixtures/js_function/src/functions.js
23+
```
24+
25+
js_function_v3.wasm:
26+
```
27+
javy build -C dynamic -C plugin=providers/javy_quickjs_provider_v3.wasm -o tests/fixtures/build/js_function_v3.wasm tests/fixtures/js_function/src/functions.js
28+
```
29+
1830
**`*.wat` examples:**
1931
```
2032
find tests/fixtures -maxdepth 1 -type f -name "*.wat" \
3.45 KB
Binary file not shown.
3.41 KB
Binary file not shown.

0 commit comments

Comments
 (0)