Skip to content

Commit

Permalink
Fix bugs in indexed interceptor test.
Browse files Browse the repository at this point in the history
Returning a string in the enumerator was never allowed but wasn't
enforced until recently.  In Node.js 10, it hits a CHECK in V8.
  • Loading branch information
bnoordhuis authored and kkoopa committed May 11, 2018
1 parent b8e259a commit 946377f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion test/cpp/indexedinterceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) {

NAN_INDEX_ENUMERATOR(IndexedInterceptor::PropertyEnumerator) {
v8::Local<v8::Array> arr = Nan::New<v8::Array>();
Set(arr, 0, Nan::New("whee").ToLocalChecked());
Set(arr, 0, Nan::New(42));
info.GetReturnValue().Set(arr);
}

Expand All @@ -111,6 +111,9 @@ NAN_INDEX_QUERY(IndexedInterceptor::PropertyQuery) {
if (index == 1) {
info.GetReturnValue().Set(Nan::New<v8::Integer>(v8::DontEnum));
}
if (index == 42) {
info.GetReturnValue().Set(Nan::New(0));
}
}

NODE_MODULE(indexedinterceptors, IndexedInterceptor::Init)
2 changes: 1 addition & 1 deletion test/js/indexedinterceptors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ test('indexedinterceptors', function (t) {
delete interceptor[0];
t.equal(interceptor[0], 'goober');
t.ok(Object.prototype.hasOwnProperty.call(interceptor, 1));
t.equal(Object.keys(interceptor)[0], 'whee');
t.equal(Object.keys(interceptor)[0], '42');
});

0 comments on commit 946377f

Please sign in to comment.