summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/round_trip.js54
-rw-r--r--src/mongo/scripting/engine_v8.cpp4
2 files changed, 1 insertions, 57 deletions
diff --git a/jstests/round_trip.js b/jstests/round_trip.js
deleted file mode 100644
index 534d1075107..00000000000
--- a/jstests/round_trip.js
+++ /dev/null
@@ -1,54 +0,0 @@
-// Tests to make sure conversions back and forth from BSON to V8
-// objects round trip properly.
-
-function ensureRoundTrip(value, bsonType, inArray) {
- var coll = db.round_trip;
- coll.drop();
-
- // insert the value into the collection
- // if inArray is set, we will nest the value in an array
- var before = inArray ? { val: [ value ] } : { val: value };
- coll.insert(before);
-
- // assert number was inserted as correct bson type
- assert.eq(coll.count({ val: { '$type': bsonType } }), 1);
-
- // assert number created with the correct function template
- var after = coll.findOne();
- var newval = inArray ? after.val[0] : after.val;
- assert.eq(value.constructor, newval.constructor);
-
- // assert number is re-inserted with the correct bson type
- var copy = {};
- copy.val = after.val;
-
- // NOTE: MongoDB's shell lazily decodes BSON objects so as to
- // not incur the cost of re-encoding them if not necessary.
- //
- // We make a copy here, by creating a new object and copying
- // the data value, in order to force the shell to re-encode
- // the document when it gets serialized.
- //
- // If this step is not taken, the original BSON is used and
- // the serialization/conversion process is not fully tested.
- //
- // This is NOT true for documents that contain arrays which
- // pre-emptively unpack the BSON instead of lazily doing it
- // because it produces performance benefits in v8.
-
- coll.drop();
- coll.insert(copy);
- assert.eq(coll.count({ val: { '$type' : bsonType } }), 1);
-}
-
-// Double -- BSON Type 1
-ensureRoundTrip(Number(123), 1, false);
-ensureRoundTrip(Number(123), 1, true);
-
-// NumberInt (int32) -- BSON Type 16
-ensureRoundTrip(NumberInt(123), 16, false);
-ensureRoundTrip(NumberInt(123), 16, true);
-
-// NumberLong (int64) -- BSON Type 18
-ensureRoundTrip(NumberLong(12), 18, false);
-ensureRoundTrip(NumberLong(12), 18, true);
diff --git a/src/mongo/scripting/engine_v8.cpp b/src/mongo/scripting/engine_v8.cpp
index cf0b17e5745..b51b28a38ff 100644
--- a/src/mongo/scripting/engine_v8.cpp
+++ b/src/mongo/scripting/engine_v8.cpp
@@ -1371,10 +1371,8 @@ namespace mongo {
case mongo::jstOID:
return newId(elem.__oid());
case mongo::NumberDouble:
- return v8::Number::New(elem.number());
case mongo::NumberInt:
- argv[0] = v8::Number::New(elem.numberInt());
- return NumberIntFT()->GetFunction()->NewInstance(1, argv);
+ return v8::Number::New(elem.number());
case mongo::Array: {
// NB: This comment may no longer be accurate.
// for arrays it's better to use non lazy object because: