-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add new.target add-on regression test
Add a test that checks that new.target inheritance works when inheriting from a constructor defined in C++. PR-URL: #9689 Refs: #9288 Refs: #9293 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
2e15d48
commit 87760cc
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <node.h> | ||
#include <v8.h> | ||
|
||
namespace { | ||
|
||
inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>&) {} | ||
|
||
inline void Initialize(v8::Local<v8::Object> binding) { | ||
auto isolate = binding->GetIsolate(); | ||
binding->Set(v8::String::NewFromUtf8(isolate, "Class"), | ||
v8::FunctionTemplate::New(isolate, NewClass)->GetFunction()); | ||
} | ||
|
||
NODE_MODULE(binding, Initialize) | ||
|
||
} // anonymous namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'binding', | ||
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], | ||
'sources': [ 'binding.cc' ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const common = require('../../common'); | ||
const assert = require('assert'); | ||
const binding = require(`./build/${common.buildType}/binding`); | ||
|
||
class Class extends binding.Class { | ||
constructor() { | ||
super(); | ||
this.method(); | ||
} | ||
method() { | ||
this.ok = true; | ||
} | ||
} | ||
|
||
assert.ok(new Class() instanceof binding.Class); | ||
assert.ok(new Class().ok); |