Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "nbind", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Embind-style bindings generator for Node.js", | ||
@@ -13,3 +13,3 @@ "homepage": "https://github.com/charto/nbind", | ||
"scripts": { | ||
"test": "cd test && autogypi && node-gyp configure && node-gyp build && tap test.js" | ||
"test": "cd test && autogypi && node-gyp configure && node-gyp build && tap --gc test.js" | ||
}, | ||
@@ -25,3 +25,3 @@ "repository": { | ||
"dependencies": { | ||
"nan": "~1.7.0" | ||
"nan": "~1.8.4" | ||
}, | ||
@@ -32,4 +32,4 @@ "devDependencies": { | ||
"node-gyp": "~1.0.3", | ||
"tap": "~0.7.1" | ||
"tap": "~1.2.1" | ||
} | ||
} |
nbind | ||
===== | ||
[![build status](http://img.shields.io/travis/charto/nbind.svg)](http://travis-ci.org/charto/nbind) [![npm version](https://img.shields.io/npm/v/nbind.svg)](https://www.npmjs.com/package/nbind) | ||
[![build status](https://travis-ci.org/charto/nbind.svg?branch=master)](http://travis-ci.org/charto/nbind) [![npm version](https://img.shields.io/npm/v/nbind.svg)](https://www.npmjs.com/package/nbind) | ||
@@ -6,0 +6,0 @@ nbind is a bindings generator for Node.js plugins inspired by [embind](http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html) from [emscripten](http://emscripten.org). The bindings are built along with your C++ library without requiring any generated code, using C++11 templates and simple declarations. |
@@ -9,18 +9,41 @@ var test = require('tap').test; | ||
var Type = testModule.PrimitiveMethods; | ||
var obj = new Type(); | ||
t.strictEqual(Type.negateStatic(false), true); | ||
t.strictEqual(obj.negate(false), true); | ||
(function() { | ||
var obj = new Type(); | ||
t.strictEqual(Type.incrementIntStatic(1), 2); | ||
t.strictEqual(obj.incrementInt(1), 2); | ||
t.strictEqual(Type.negateStatic(false), true); | ||
t.strictEqual(obj.negate(false), true); | ||
t.type(Type.incrementStateStatic(), 'undefined'); | ||
t.strictEqual(Type.getStateStatic(), 1); | ||
t.type(obj.incrementState(), 'undefined'); | ||
t.strictEqual(obj.getState(), 2); | ||
t.strictEqual(Type.incrementIntStatic(1), 2); | ||
t.strictEqual(obj.incrementInt(1), 2); | ||
t.strictEqual(Type.strLengthStatic('foo'), 3); | ||
t.strictEqual(obj.strLength('foobar'), 6); | ||
t.type(Type.incrementStateStatic(), 'undefined'); | ||
t.strictEqual(Type.getStateStatic(), 1); | ||
t.type(obj.incrementState(), 'undefined'); | ||
t.strictEqual(obj.getState(), 2); | ||
t.strictEqual(Type.strLengthStatic('foo'), 3); | ||
t.strictEqual(obj.strLength('foobar'), 6); | ||
t.strictEqual(Type.catenateStatic('foo', 'bar'), 'foobar'); | ||
t.strictEqual(obj.catenate('Java', 'Script'), 'JavaScript'); | ||
t.throws(function() { | ||
Type.strLengthStatic({}); | ||
}, {message: 'Type mismatch'}); | ||
// Constructing with or without "new" operator should work identically. | ||
obj = Type(); | ||
gc(); | ||
// Destructor should have incremented state. | ||
t.strictEqual(Type.getStateStatic(), 3); | ||
t.strictEqual(obj.negate(false), true); | ||
})(); | ||
gc(); | ||
// Destructor should have incremented state again. | ||
t.strictEqual(Type.getStateStatic(), 4); | ||
t.end(); | ||
@@ -36,10 +59,57 @@ }); | ||
t.strictEqual(obj.z, 3); | ||
t.strictEqual(obj.t, 'foobar'); | ||
obj.y = 4; | ||
obj.z = 5; | ||
obj.t = 'foo'; | ||
t.strictEqual(obj.y, 4); | ||
t.strictEqual(obj.z, 5); | ||
t.strictEqual(obj.t, 'foo'); | ||
t.throws(function() { | ||
obj.t = 0; | ||
}, {message: 'Type mismatch'}); | ||
t.end(); | ||
}); | ||
test('Callbacks', function(t) { | ||
var Type = testModule.Callback; | ||
t.strictEqual(Type.callNegate(function(x) {return(!x);}, false), true); | ||
t.strictEqual(Type.callIncrementInt(function(x) {return(x + 1);}, 1), 2); | ||
t.throws(function() { | ||
Type.callNegate({}, true); | ||
}, {message: 'Type mismatch'}); | ||
t.end(); | ||
}); | ||
test('Value objects', function(t) { | ||
var Type = testModule.Value; | ||
t.type(Type.getCoord(), 'undefined'); | ||
function Coord(x, y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
Coord.prototype.fromJS = function(output) { | ||
output(this.x, this.y); | ||
} | ||
testModule.NBind.bind('Coord', Coord); | ||
var xy = Type.getCoord(); | ||
t.strictEqual(xy.x, 1); | ||
t.strictEqual(xy.y, 2); | ||
xy.fromJS(function() {}); | ||
Type.foo(xy); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71320
31
102
+ Addednan@1.8.4(transitive)
- Removednan@1.7.0(transitive)
Updatednan@~1.8.4