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.rs5
-rw-r--r--test_ffi/tests/test.js13
2 files changed, 17 insertions, 1 deletions
diff --git a/test_ffi/tests/integration_tests.rs b/test_ffi/tests/integration_tests.rs
index 26de8ce0d..4a910a836 100644
--- a/test_ffi/tests/integration_tests.rs
+++ b/test_ffi/tests/integration_tests.rs
@@ -101,6 +101,11 @@ fn basic() {
Static i64: -1242464576485n\n\
Static ptr: true\n\
Static ptr value: 42\n\
+ arrayBuffer.byteLength: 4\n\
+ uint32Array.length: 1\n\
+ uint32Array[0]: 42\n\
+ uint32Array[0] after mutation: 55\n\
+ Static ptr value after mutation: 55\n\
Correct number of resources\n";
assert_eq!(stdout, expected);
assert_eq!(stderr, "");
diff --git a/test_ffi/tests/test.js b/test_ffi/tests/test.js
index ff81f302e..516182f6f 100644
--- a/test_ffi/tests/test.js
+++ b/test_ffi/tests/test.js
@@ -3,7 +3,9 @@
// Run using cargo test or `--v8-options=--allow-natives-syntax`
-import { assertThrows } from "../../test_util/std/testing/asserts.ts";
+import {
+ assertThrows,
+} from "../../test_util/std/testing/asserts.ts";
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
const [libPrefix, libSuffix] = {
@@ -442,6 +444,15 @@ console.log(
const view = new Deno.UnsafePointerView(dylib.symbols.static_ptr);
console.log("Static ptr value:", view.getUint32());
+const arrayBuffer = view.getArrayBuffer(4);
+const uint32Array = new Uint32Array(arrayBuffer);
+console.log("arrayBuffer.byteLength:", arrayBuffer.byteLength);
+console.log("uint32Array.length:", uint32Array.length);
+console.log("uint32Array[0]:", uint32Array[0]);
+uint32Array[0] = 55; // MUTATES!
+console.log("uint32Array[0] after mutation:", uint32Array[0]);
+console.log("Static ptr value after mutation:", view.getUint32());
+
(function cleanup() {
dylib.close();
throwCallback.close();