Permalink
Browse files

Fixed but with child object/arrays

  • Loading branch information...
MattTuttle committed May 21, 2012
1 parent ab70a74 commit 3d09a8f8dafa33efde7d0b096e7b975f20a8eeb1
Showing with 9 additions and 20 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 org/bsonspec/BSONEncoder.hx
  3. +6 −18 test/MongoTest.hx
View
@@ -1,4 +1,5 @@
*.n
*.swf
*.zip
+*.bson
.DS_Store
@@ -77,7 +77,7 @@ class BSONEncoder
{
writeHeader(out, key, 0x04);
bytes = arrayToBytes(value);
- out.writeInt32(Int32.ofInt(bytes.length));
+ out.writeInt32(Int32.ofInt(bytes.length + 4));
out.writeBytes(bytes, 0, bytes.length);
}
else if (Std.is(value, ObjectID))
@@ -89,7 +89,7 @@ class BSONEncoder
{
writeHeader(out, key, 0x03);
bytes = objectToBytes(value);
- out.writeInt32(Int32.ofInt(bytes.length));
+ out.writeInt32(Int32.ofInt(bytes.length + 4));
out.writeBytes(bytes, 0, bytes.length);
}
else
View
@@ -20,11 +20,11 @@ class MongoTest extends TestCase
data.push({
title: 'My awesome post',
body: 'More awesome content',
-// thing: ['first', 2, Date.now()]
- // dates: {
- // updated: Date.now(),
- // created: Date.fromString("2012-05-05")
- // }
+ thing: ['first', 5, 25.5],
+ dates: {
+ updated: Date.now(),
+ created: Date.fromString("2012-05-05")
+ }
});
}
posts.insert(data);
@@ -50,18 +50,6 @@ class MongoTest extends TestCase
assertTrue(count == NUM_POSTS);
}
- public function testQuery()
- {
- /*
- var result = posts.find({
- "$query": {
- title: 'My awesome post'
- }
- });
- */
- assertTrue(true);
- }
-
public function testData()
{
var obj = posts.findOne();
@@ -80,7 +68,7 @@ class MongoTest extends TestCase
#if (neko || cpp || php)
r.add(new BSONTest());
#end
- //r.add(new MongoTest());
+ r.add(new MongoTest());
r.run();
}

0 comments on commit 3d09a8f

Please sign in to comment.