From e9fc46ab7d8cfe96454067036f0d272b61c7ab0a Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Fri, 13 Jun 2014 18:17:32 -0400 Subject: SERVER-14254 added jstest for _v8_function.toString() --- jstests/core/where5.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 jstests/core/where5.js diff --git a/jstests/core/where5.js b/jstests/core/where5.js new file mode 100644 index 00000000000..e4a5f353ec8 --- /dev/null +++ b/jstests/core/where5.js @@ -0,0 +1,28 @@ +// Tests toString() on _v8_function in object constructor. + +var t = db.where5; + +t.drop(); + +t.save({a: 1}); + +// Prints information on the document's _id field. +function printIdConstructor(doc) { + // If doc is undefined, this function is running inside server. + if (!doc) { + doc = this; + } + + // This used to crash. + doc._id.constructor._v8_function.toString(); + + // Predicate for matching document in collection. + return true; +} + +print('Running JS function in server...'); +assert.eq(t.find({$where: printIdConstructor}).itcount(), 1); + +print('Running JS function in client...'); +var doc = t.findOne(); +printIdConstructor(doc); -- cgit v1.2.1