summaryrefslogtreecommitdiff
path: root/test_ffi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test_ffi/tests')
-rw-r--r--test_ffi/tests/integration_tests.rs2
-rw-r--r--test_ffi/tests/test.js17
2 files changed, 16 insertions, 3 deletions
diff --git a/test_ffi/tests/integration_tests.rs b/test_ffi/tests/integration_tests.rs
index 55b0f7a60..4982ffad5 100644
--- a/test_ffi/tests/integration_tests.rs
+++ b/test_ffi/tests/integration_tests.rs
@@ -30,6 +30,7 @@ fn basic() {
.arg("--allow-read")
.arg("--unstable")
.arg("--quiet")
+ .arg(r#"--v8-flags=--allow-natives-syntax"#)
.arg("tests/test.js")
.env("NO_COLOR", "1")
.output()
@@ -62,6 +63,7 @@ fn basic() {
true\n\
579\n\
579\n\
+ 579\n\
8589934590n\n\
-8589934590n\n\
8589934590n\n\
diff --git a/test_ffi/tests/test.js b/test_ffi/tests/test.js
index 94c2069c0..4e05be3ed 100644
--- a/test_ffi/tests/test.js
+++ b/test_ffi/tests/test.js
@@ -1,6 +1,8 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file
+// Run using cargo test or `--v8-options=--allow-natives-syntax`
+
import { assertThrows } from "../../test_util/std/testing/asserts.ts";
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
@@ -182,8 +184,9 @@ const dylib = Deno.dlopen(libPath, {
type: "pointer",
},
});
+const { symbols } = dylib;
-dylib.symbols.printSomething();
+symbols.printSomething();
const buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
const buffer2 = new Uint8Array([9, 10]);
dylib.symbols.print_buffer(buffer, buffer.length);
@@ -238,7 +241,15 @@ const before = performance.now();
await sleepNonBlocking.call(100);
console.log(performance.now() - before >= 100);
-console.log(dylib.symbols.add_u32(123, 456));
+const { add_u32 } = symbols;
+function addU32Fast(a, b) {
+ return add_u32(a, b);
+};
+
+%PrepareFunctionForOptimization(addU32Fast);
+console.log(addU32Fast(123, 456));
+%OptimizeFunctionOnNextCall(addU32Fast);
+console.log(addU32Fast(123, 456));
console.log(dylib.symbols.add_i32(123, 456));
console.log(dylib.symbols.add_u64(0xffffffffn, 0xffffffffn));
@@ -448,4 +459,4 @@ After: ${postStr}`,
}
console.log("Correct number of resources");
-})();
+})(); \ No newline at end of file