Skip to content

Commit

Permalink
Added more tests for SaveToPersistent and GetFromPersistent
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoopa committed May 9, 2015
1 parent 47ff8e3 commit 3c98eb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 9 additions & 0 deletions test/cpp/bufferworkerpersistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class BufferWorker : public NanAsyncWorker {

NanScope();

/* test them all */
SaveToPersistent("buffer", bufferHandle);
SaveToPersistent(NanNew("puffer"), bufferHandle);
SaveToPersistent(0u, bufferHandle);
}

~BufferWorker() {}
Expand All @@ -37,6 +40,12 @@ class BufferWorker : public NanAsyncWorker {

v8::Local<v8::Value> handle = GetFromPersistent("buffer");
callback->Call(1, &handle);

handle = GetFromPersistent(NanNew("puffer"));
callback->Call(1, &handle);

handle = GetFromPersistent(0u);
callback->Call(1, &handle);
}

private:
Expand Down
10 changes: 3 additions & 7 deletions test/js/bufferworkerpersistent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@ const test = require('tap').test

test('bufferworkerpersistent', function (t) {
var worker = bindings.a
, called = false
, called = 0
, buf = crypto.randomBytes(256)
, bufHex = buf.toString('hex')

t.type(worker, 'function')
t.plan(7);

setTimeout(function () {
t.ok(called, 'callback fired')
t.end()
}, 500)
t.type(worker, 'function')

worker(200, buf, function (_buf) {
called = true
t.ok(Buffer.isBuffer(_buf), 'is buffer arg')
t.equal(_buf.toString('hex'), bufHex)
})
Expand Down

0 comments on commit 3c98eb2

Please sign in to comment.