Skip to content

Commit

Permalink
Remove unused test fixture compileAndInstantiateModule
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Sep 27, 2023
1 parent 1ef32fc commit 6c63cf0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 42 deletions.
21 changes: 0 additions & 21 deletions src/workerd/tests/test-fixture-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,6 @@ KJ_TEST("runInIoContext consuming ignored js exception") {
KJ_EXPECT(runCount == 1);
}

KJ_TEST("compileAndInstantiateModule") {
TestFixture fixture;
uint runCount = 0;

fixture.runInIoContext([&](const TestFixture::Environment& env) {
runCount++;
auto context = env.isolate->GetCurrentContext();

auto ns = env.compileAndInstantiateModule("testFixtureTest",
"export function init() { return 42; }"_kj);
auto fn = env.js.v8Get(ns, "init"_kj);
KJ_EXPECT(fn->IsFunction());
auto callResult = v8::Function::Cast(*fn)->
Call(context, context->Global(), 0, nullptr).ToLocalChecked();
v8::String::Utf8Value value(env.isolate, callResult);
KJ_EXPECT(*value == "42"_kj);
});

KJ_EXPECT(runCount == 1);
}

KJ_TEST("runRequest") {
TestFixture fixture({
.mainModuleSource = R"SCRIPT(
Expand Down
17 changes: 0 additions & 17 deletions src/workerd/tests/test-fixture.c++
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,4 @@ TestFixture::Response TestFixture::runRequest(
return { .statusCode = response.statusCode, .body = response.body->str() };
}

v8::Local<v8::Object> TestFixture::V8Environment::compileAndInstantiateModule(
kj::StringPtr name, kj::ArrayPtr<const char> src) const {
v8::Local<v8::Module> module;

v8::ScriptCompiler::Source source(jsg::v8Str(isolate, src),
v8::ScriptOrigin(isolate, jsg::v8StrIntern(isolate, name),
false, false, false, -1, {}, false, false, true /* is_module */));

if (!v8::ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) {
KJ_FAIL_REQUIRE("error parsing code");
}

auto& js = jsg::Lock::from(isolate);
jsg::instantiateModule(js, module);
return module->GetModuleNamespace()->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
}

} // namespace workerd
4 changes: 0 additions & 4 deletions src/workerd/tests/test-fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ struct TestFixture {

struct V8Environment {
v8::Isolate* isolate;

// Compile and instantiate esm module. Returns module namespace object.
v8::Local<v8::Object> compileAndInstantiateModule(
kj::StringPtr name, kj::ArrayPtr<const char> src) const;
};

struct Environment : public V8Environment {
Expand Down

0 comments on commit 6c63cf0

Please sign in to comment.