MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / ReferenceResetTests

Function ReferenceResetTests

test/reference.cc:40–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40static void ReferenceResetTests(const Napi::CallbackInfo& info) {
41 Napi::Object obj = Napi::Object::New(info.Env());
42 Napi::Reference<Napi::Object> ref = Napi::Reference<Napi::Object>::New(obj);
43 assert(!ref.IsEmpty());
44
45 ref.Reset();
46 assert(ref.IsEmpty());
47
48 Napi::Object newObject = Napi::Object::New(info.Env());
49 newObject.Set("n-api", "node");
50
51 ref.Reset(newObject, 1);
52 assert(!ref.IsEmpty());
53
54 std::string val = MaybeUnwrap(ref.Value().Get("n-api")).As<Napi::String>();
55 assert(val == "node");
56}
57
58void CreateWeakArray(const CallbackInfo& info) {
59 weak = Weak(Buffer<uint8_t>::New(info.Env(), 1));

Callers

nothing calls this directly

Calls 7

MaybeUnwrapFunction · 0.85
EnvMethod · 0.80
IsEmptyMethod · 0.80
ResetMethod · 0.80
SetMethod · 0.80
GetMethod · 0.80
ValueMethod · 0.80

Tested by

no test coverage detected