From b24110a78152d34fe7f2b0452c4dd78a659be519 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 29 Sep 2017 12:26:07 +0200 Subject: [PATCH] test: check that this != new.target in addon Add two checks that are there for expository reasons as much as they are sanity checks. Refs: https://github.com/nodejs/node-addon-api/issues/142 --- test/addons/new-target/binding.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/addons/new-target/binding.cc b/test/addons/new-target/binding.cc index 5491c18c6e99af..3ae2aca7c2ef95 100644 --- a/test/addons/new-target/binding.cc +++ b/test/addons/new-target/binding.cc @@ -3,7 +3,11 @@ namespace { -inline void NewClass(const v8::FunctionCallbackInfo&) {} +inline void NewClass(const v8::FunctionCallbackInfo& args) { + // this != new.target since we are being invoked through super(). + assert(args.IsConstructCall()); + assert(!args.This()->StrictEquals(args.NewTarget())); +} inline void Initialize(v8::Local binding) { auto isolate = binding->GetIsolate();