Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add new.target add-on regression test #9689

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/addons/new-target/binding.cc
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
9 changes: 9 additions & 0 deletions test/addons/new-target/binding.gyp
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' ]
}
]
}
18 changes: 18 additions & 0 deletions test/addons/new-target/test.js
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);