summaryrefslogtreecommitdiff
path: root/jstests/regex2.js
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2009-10-19 12:59:42 -0400
committerMathias Stearn <mathias@10gen.com>2009-10-19 14:30:46 -0400
commit8190d8db538c629973a3a581a97251b22b668c7a (patch)
tree799da8624790a0dc4f6c2d314ea095a5bd2f0aec /jstests/regex2.js
parent4f83c02fcc30972f8ec0487bbb870635e49ff2ec (diff)
downloadmongo-8190d8db538c629973a3a581a97251b22b668c7a.tar.gz
Support {:'foo', :'bar'} syntax in queries. SERVER-275
Diffstat (limited to 'jstests/regex2.js')
-rw-r--r--jstests/regex2.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/regex2.js b/jstests/regex2.js
index 9e69a5ab9d1..b6a21f5bc4e 100644
--- a/jstests/regex2.js
+++ b/jstests/regex2.js
@@ -34,5 +34,29 @@ assert.eq( 1 , t.find( { a : new RegExp( b ) } ).count() , "C E" );
assert.eq( 2 , t.find( { a : new RegExp( a , "i" ) } ).count() , "C F is spidermonkey built with UTF-8 support?" );
+// same tests as above but using {$regex: "a|b", $options: "imx"} syntax.
+t.drop();
+
+t.save( { a : "test" } );
+t.save( { a : "Test" } );
+
+assert.eq( 2 , t.find().count() , "obj A" );
+assert.eq( 1 , t.find( { a : {$regex:"Test"} } ).count() , "obj D" );
+assert.eq( 1 , t.find( { a : {$regex:"test"} } ).count() , "obj E" );
+assert.eq( 2 , t.find( { a : {$regex:"test", $options:"i"} } ).count() , "obj F" );
+assert.eq( 2 , t.find( { a : {$options:"i", $regex:"test"} } ).count() , "obj F rev" ); // both orders should work
+
+
+t.drop();
+
+a = "\u0442\u0435\u0441\u0442";
+b = "\u0422\u0435\u0441\u0442";
+
+t.save( { a : a } );
+t.save( { a : b } );
+
+assert.eq( 1 , t.find( { a : {$regex: a} } ).count() , "obj C D" );
+assert.eq( 1 , t.find( { a : {$regex: b} } ).count() , "obj C E" );
+assert.eq( 2 , t.find( { a : {$regex: a , $options: "i" } } ).count() , "obj C F is spidermonkey built with UTF-8 support?" );