mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
@@ -107,11 +107,26 @@ test_napi_get_value_string_utf8_with_buffer(const Napi::CallbackInfo &info) {
|
||||
return ok(env);
|
||||
}
|
||||
|
||||
Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
|
||||
Napi::Value RunCallback(const Napi::CallbackInfo &info) {
|
||||
Napi::Env env = info.Env();
|
||||
Napi::Function cb = info[0].As<Napi::Function>();
|
||||
return cb.Call(env.Global(), {Napi::String::New(env, "hello world")});
|
||||
}
|
||||
|
||||
Napi::Object Init2(Napi::Env env, Napi::Object exports) {
|
||||
return Napi::Function::New(env, RunCallback);
|
||||
}
|
||||
|
||||
Napi::Object InitAll(Napi::Env env, Napi::Object exports1) {
|
||||
// check that these symbols are defined
|
||||
auto *isolate = v8::Isolate::GetCurrent();
|
||||
node::AddEnvironmentCleanupHook(isolate, [](void *) {}, isolate);
|
||||
node::RemoveEnvironmentCleanupHook(isolate, [](void *) {}, isolate);
|
||||
|
||||
Napi::Object exports = Init2(env, exports1);
|
||||
|
||||
node::AddEnvironmentCleanupHook(
|
||||
isolate, [](void *) {}, isolate);
|
||||
node::RemoveEnvironmentCleanupHook(
|
||||
isolate, [](void *) {}, isolate);
|
||||
|
||||
exports.Set("test_issue_7685", Napi::Function::New(env, test_issue_7685));
|
||||
exports.Set("test_issue_11949", Napi::Function::New(env, test_issue_11949));
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
const tests = require("./build/Release/napitests.node");
|
||||
if (process.argv[2] === "self") {
|
||||
console.log(
|
||||
tests(function (str) {
|
||||
return str + "!";
|
||||
}),
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
const fn = tests[process.argv[2]];
|
||||
if (typeof fn !== "function") {
|
||||
throw new Error("Unknown test:", process.argv[2]);
|
||||
|
||||
@@ -58,6 +58,11 @@ describe("napi", () => {
|
||||
expect(result).toEndWith("str:");
|
||||
});
|
||||
});
|
||||
|
||||
it("#1288", async () => {
|
||||
const result = checkSameOutput("self", []);
|
||||
expect(result).toBe("hello world!");
|
||||
});
|
||||
});
|
||||
|
||||
function checkSameOutput(test: string, args: any[]) {
|
||||
|
||||
Reference in New Issue
Block a user