c = db.c;
|
c.drop();
|
|
Random.setRandomSeed();
|
|
// Insert some long longs requiring high precision, that may or may not round trip as doubles.
|
s = "11235399833116571";
|
for( i = 0; i < 1000; ++i ) {
|
n = NumberLong( s + Random.randInt( 10 ) );
|
// Randomly pick either the long long or its float approximation to insert.
|
c.insert( { x: ( Random.randInt( 2 ) ? n : n.floatApprox ) } );
|
}
|
|
// If both a and b cannot be represented as doubles, assert that a <= b.
|
function assertLteIfHighPrecisionLongs( a, b ) {
|
if ( !a.bottom || !b.bottom ) {
|
return;
|
}
|
assert.lte( a.top, b.top );
|
if ( a.top == b.top ) {
|
assert.lte( a.bottom, b.bottom );
|
}
|
}
|
|
// Verify sorted aggregation results are in a consistent order.
|
result = c.aggregate( { $sort:{ x:1 } } ).result;
|
assert.eq( 1000, result.length );
|
for( right = 1; right < 1000; ++right ) {
|
for( left = 0; left < right; ++left ) {
|
assertLteIfHighPrecisionLongs( result[ left ].x, result[ right ].x );
|
}
|
}
|