Permalink
Browse files

fix rename.js to work for both SM and v8

  • Loading branch information...
1 parent 13e7127 commit a6684a66aa6cf39f282341c4b735833a90d5d8e3 @agirbal agirbal committed May 10, 2011
Showing with 11 additions and 6 deletions.
  1. +11 −6 jstests/rename.js
View
@@ -32,18 +32,23 @@ b.drop();
c.drop();
// TODO: too many numbers hard coded here
-
+// this test depends precisely on record size and hence may not be very reliable
+// note we use floats to make sure numbers are represented as doubles for both SM and v8, since test relies on record size
db.createCollection( "jstests_rename_a", {capped:true,size:10000} );
-for( i = 0; i < 10; ++i ) {
+for( i = 0.1; i < 10; ++i ) {
a.save( { i: i } );
}
assert.commandWorked( admin.runCommand( {renameCollection:"test.jstests_rename_a", to:"test.jstests_rename_b"} ) );
-assert.eq( 1, b.count( {i:9} ) );
-for( i = 10; i < 250; ++i ) {
+assert.eq( 1, b.count( {i:9.1} ) );
+for( i = 10.1; i < 250; ++i ) {
b.save( { i: i } );
}
-assert.eq( 0, b.count( {i:9} ) );
-assert.eq( 1, b.count( {i:19} ) );
+
+//res = b.find().sort({i:1});
+//while (res.hasNext()) printjson(res.next());
+
+assert.eq( 0, b.count( {i:9.1} ) );
+assert.eq( 1, b.count( {i:19.1} ) );
assert( db.system.namespaces.findOne( {name:"test.jstests_rename_b" } ) );
assert( !db.system.namespaces.findOne( {name:"test.jstests_rename_a" } ) );

0 comments on commit a6684a6

Please sign in to comment.