mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
tests from #15139
This commit is contained in:
parent
83c9714fb2
commit
dfdd032da1
2 changed files with 16 additions and 3 deletions
|
@ -30,6 +30,7 @@ fn basic() {
|
||||||
.arg("--allow-read")
|
.arg("--allow-read")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
|
.arg(r#"--v8-flags=--allow-natives-syntax"#)
|
||||||
.arg("tests/test.js")
|
.arg("tests/test.js")
|
||||||
.env("NO_COLOR", "1")
|
.env("NO_COLOR", "1")
|
||||||
.output()
|
.output()
|
||||||
|
@ -62,6 +63,7 @@ fn basic() {
|
||||||
true\n\
|
true\n\
|
||||||
579\n\
|
579\n\
|
||||||
579\n\
|
579\n\
|
||||||
|
579\n\
|
||||||
8589934590n\n\
|
8589934590n\n\
|
||||||
-8589934590n\n\
|
-8589934590n\n\
|
||||||
8589934590n\n\
|
8589934590n\n\
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// 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 targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
|
||||||
|
@ -182,8 +184,9 @@ const dylib = Deno.dlopen(libPath, {
|
||||||
type: "pointer",
|
type: "pointer",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { symbols } = dylib;
|
||||||
|
|
||||||
dylib.symbols.printSomething();
|
symbols.printSomething();
|
||||||
const buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
const buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
||||||
const buffer2 = new Uint8Array([9, 10]);
|
const buffer2 = new Uint8Array([9, 10]);
|
||||||
dylib.symbols.print_buffer(buffer, buffer.length);
|
dylib.symbols.print_buffer(buffer, buffer.length);
|
||||||
|
@ -238,7 +241,15 @@ const before = performance.now();
|
||||||
await sleepNonBlocking.call(100);
|
await sleepNonBlocking.call(100);
|
||||||
console.log(performance.now() - before >= 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_i32(123, 456));
|
||||||
console.log(dylib.symbols.add_u64(0xffffffffn, 0xffffffffn));
|
console.log(dylib.symbols.add_u64(0xffffffffn, 0xffffffffn));
|
||||||
|
|
Loading…
Reference in a new issue