Permalink
Browse files

Regex tests with \Q...\E SERVER-2862

  • Loading branch information...
1 parent 1963944 commit ccd42395d9d18229fd4e399e870d251159a1efb7 @RedBeard0531 RedBeard0531 committed Mar 29, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 jstests/regex6.js
View
11 jstests/regex6.js
@@ -6,6 +6,7 @@ t.save( { name : "eliot" } );
t.save( { name : "emily" } );
t.save( { name : "bob" } );
t.save( { name : "aaron" } );
+t.save( { name : "[with]some?symbols" } );
t.ensureIndex( { name : 1 } );
@@ -14,9 +15,15 @@ assert.eq( 1 , t.find( { name : /^\// } ).explain().nscanned , "index explain 1"
assert.eq( 0 , t.find( { name : /^é/ } ).explain().nscanned , "index explain 2" );
assert.eq( 0 , t.find( { name : /^/ } ).explain().nscanned , "index explain 3" );
assert.eq( 1 , t.find( { name : /^\./ } ).explain().nscanned , "index explain 4" );
-assert.eq( 4 , t.find( { name : /^./ } ).explain().nscanned , "index explain 5" );
+assert.eq( 5 , t.find( { name : /^./ } ).explain().nscanned , "index explain 5" );
-assert.eq( 4 , t.find( { name : /^\Qblah\E/ } ).explain().nscanned , "index explain 6" );
+// SERVER-2862
+assert.eq( 0 , t.find( { name : /^\Qblah\E/ } ).count() , "index explain 6" );
+assert.eq( 1 , t.find( { name : /^\Qblah\E/ } ).explain().nscanned , "index explain 6" );
+assert.eq( 1 , t.find( { name : /^blah/ } ).explain().nscanned , "index explain 6" );
+assert.eq( 1 , t.find( { name : /^\Q[\Ewi\Qth]some?s\Eym/ } ).count() , "index explain 6" );
+assert.eq( 2 , t.find( { name : /^\Q[\Ewi\Qth]some?s\Eym/ } ).explain().nscanned , "index explain 6" );
+assert.eq( 2 , t.find( { name : /^bob/ } ).explain().nscanned , "index explain 6" ); // proof nscanned == count+1
assert.eq( 1, t.find( { name : { $regex : "^e", $gte: "emily" } } ).explain().nscanned , "ie7" );
assert.eq( 1, t.find( { name : { $gt : "a", $regex: "^emily" } } ).explain().nscanned , "ie7" );

0 comments on commit ccd4239

Please sign in to comment.