Skip to content

Commit

Permalink
Add test for Object::Object empty constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseExposito committed Mar 5, 2021
1 parent cdd5c9f commit 785c38f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/object/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Value TestFunctionWithUserData(const CallbackInfo& info) {
return Number::New(info.Env(), holder->value);
}

Value GetEmptyConstructor(const CallbackInfo& /*info*/) {
return Object();
}

Array GetPropertyNames(const CallbackInfo& info) {
Object obj = info[0].As<Object>();
Array arr = obj.GetPropertyNames();
Expand Down Expand Up @@ -237,6 +241,8 @@ Value InstanceOf(const CallbackInfo& info) {
Object InitObject(Env env) {
Object exports = Object::New(env);

exports["getEmptyConstructor"] = Function::New(env, GetEmptyConstructor);

exports["GetPropertyNames"] = Function::New(env, GetPropertyNames);
exports["defineProperties"] = Function::New(env, DefineProperties);
exports["defineValueProperty"] = Function::New(env, DefineValueProperty);
Expand Down
6 changes: 6 additions & 0 deletions test/object/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ function test(binding) {
testDefineProperties('string');
testDefineProperties('value');

{
const expected = undefined;
const actual = binding.object.getEmptyConstructor();
assert.strictEqual(actual, expected);
}

{
const obj = {};
const testSym = Symbol();
Expand Down

0 comments on commit 785c38f

Please sign in to comment.