Skip to content

Commit

Permalink
Made test/struct.js work on 32-bit platforms; Bump to version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rbranson committed Sep 7, 2011
1 parent b77dbe7 commit 45d4073
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-ffi",
"version": "0.2.2",
"version": "0.3.0",
"author": "Rick Branson",
"description": "A foreign function interface (FFI) for Node.js",
"homepage": "http://github.com/rbranson/node-ffi",
Expand Down
17 changes: 13 additions & 4 deletions test/struct.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var ffi = require('../')
, assert = require('assert')

// These expected alignments and offsets are from a compiled C program run on
// 64-bit Mac OS X darwin
// TODO: build struct examples statically as part of the build and expose
// via the bindings interface.

var test1 = ffi.Struct([
['int32', 'a']
Expand Down Expand Up @@ -82,8 +82,15 @@ var ffi_type = ffi.Struct([
, ['ushort','type']
, ['pointer','elements']
])
inspect(ffi_type, 24, [0,8,10,16])

if (ffi.Bindings.POINTER_SIZE == 4) {
inspect(ffi_type, 12, [0,4,6,8])
}
else if (ffi.Bindings.POINTER_SIZE == 8) {
inspect(ffi_type, 24, [0,8,10,16])
}
else {
console.log("Bad platform pointer size: %d bytes", PSZ);
}

function inspect (s, expectedSize, expectedOffsets) {
var info = s.__structInfo__
Expand All @@ -107,3 +114,5 @@ function inspect (s, expectedSize, expectedOffsets) {
assert.equal(expectedOffsets[i], props[p].offset)
})
}

console.log("All tests passed!");
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ if (FFI.Bindings.HAS_OBJC) {
var pool = objcLib.objc_msgSend(objcLib.objc_getClass('NSAutoreleasePool'), objcLib.sel_registerName('new'))
var NSObject = objcLib.objc_getClass('NSObject');
var badSel = objcLib.sel_registerName('badSelector');
util.log("=== 'NSObject badSelector' Exception log on next line is OK ===");
assert.throws(function () {
objcLib.objc_msgSend(NSObject, badSel);
});
Expand Down

0 comments on commit 45d4073

Please sign in to comment.