Permalink
Browse files

Validate correct serialization of regexp with /gi by adding test

  • Loading branch information...
1 parent 0fc7f85 commit cc4e76cda5bd6ef4eaa8d5d33fc4d8dd13a68a5e @christkv christkv committed Feb 24, 2014
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/node/bson_parser_comparision_test.js
@@ -586,6 +586,25 @@ exports['Should correctly serialize prototype fields'] = function(test) {
/**
* @ignore
*/
+exports['Should correctly serialize regexp'] = function(test) {
+ // Create doc to serialize
+ var doc = {regexp: /<[^>]>/gi}
+
+ // Serialize using both
+ var simple_string_serialized = bsonJS.serialize(doc, false, true, true);
+ var simple_string_serialized_2 = bsonC.serialize(doc, false, true, true);
+
+ // Deserialize the string
+ var doc1 = bsonJS.deserialize(simple_string_serialized);
+ var doc2 = bsonC.deserialize(simple_string_serialized_2);
+ assert.equal("/<[^>]>/gi", doc1.regexp.toString());
+ assert.equal("/<[^>]>/gi", doc2.regexp.toString());
+ test.done();
+}
+
+/**
+ * @ignore
+ */
exports.noGlobalsLeaked = function(test) {
var leaks = gleak.detectNew();
test.equal(0, leaks.length, "global var leak detected: " + leaks.join(', '));

0 comments on commit cc4e76c

Please sign in to comment.