mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
PR-URL: https://github.com/nodejs/node/pull/26618 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
#include "node_test_fixture.h"
|
|
#include "node_internals.h" // RunBootstrapping()
|
|
|
|
void InitializeBinding(v8::Local<v8::Object> exports,
|
|
v8::Local<v8::Value> module,
|
|
v8::Local<v8::Context> context) {
|
|
v8::Isolate* isolate = context->GetIsolate();
|
|
exports->Set(
|
|
context,
|
|
v8::String::NewFromOneByte(isolate,
|
|
reinterpret_cast<const uint8_t*>("key"),
|
|
v8::NewStringType::kNormal).ToLocalChecked(),
|
|
v8::String::NewFromOneByte(isolate,
|
|
reinterpret_cast<const uint8_t*>("value"),
|
|
v8::NewStringType::kNormal).ToLocalChecked())
|
|
.FromJust();
|
|
}
|
|
|
|
NODE_MODULE_LINKED(cctest_linkedbinding, InitializeBinding)
|
|
|
|
class LinkedBindingTest : public EnvironmentTestFixture {};
|
|
|
|
TEST_F(LinkedBindingTest, SimpleTest) {
|
|
const v8::HandleScope handle_scope(isolate_);
|
|
const Argv argv;
|
|
Env test_env {handle_scope, argv};
|
|
|
|
v8::Local<v8::Context> context = isolate_->GetCurrentContext();
|
|
|
|
const char* run_script =
|
|
"process._linkedBinding('cctest_linkedbinding').key";
|
|
v8::Local<v8::Script> script = v8::Script::Compile(
|
|
context,
|
|
v8::String::NewFromOneByte(isolate_,
|
|
reinterpret_cast<const uint8_t*>(run_script),
|
|
v8::NewStringType::kNormal).ToLocalChecked())
|
|
.ToLocalChecked();
|
|
v8::Local<v8::Value> completion_value = script->Run(context).ToLocalChecked();
|
|
v8::String::Utf8Value utf8val(isolate_, completion_value);
|
|
CHECK_NOT_NULL(*utf8val);
|
|
CHECK_EQ(strcmp(*utf8val, "value"), 0);
|
|
}
|