Skip to content

Commit

Permalink
msgpack, bugfix: new Boolean(false) encode error.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Jun 14, 2021
1 parent 5cd7e69 commit c1b8faa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fibjs/include/Isolate.h
Expand Up @@ -96,7 +96,9 @@ class Isolate : public exlib::linkitem {

bool toBoolean(v8::Local<v8::Value> v)
{
return v->BooleanValue(context()).ToChecked();
if (v->IsBooleanObject())
return v8::Local<v8::BooleanObject>::Cast(v)->ValueOf();
return v->BooleanValue(m_isolate);
}

int64_t toInteger(v8::Local<v8::Value> v)
Expand Down
2 changes: 2 additions & 0 deletions test/encoding_test.js
Expand Up @@ -357,11 +357,13 @@ describe('encoding', () => {

it('test for true', () => {
assert.deepEqual(true, msgpack.decode(msgpack.encode(true)));
assert.deepEqual(true, msgpack.decode(msgpack.encode(new Boolean(true))));
assert.isBoolean(msgpack.decode(msgpack.encode(true)));
});

it('test for false', () => {
assert.deepEqual(false, msgpack.decode(msgpack.encode(false)));
assert.deepEqual(false, msgpack.decode(msgpack.encode(new Boolean(false))));
assert.isBoolean(msgpack.decode(msgpack.encode(false)));
});

Expand Down

0 comments on commit c1b8faa

Please sign in to comment.