diff options
author | Benety Goh <benety@mongodb.com> | 2014-06-13 18:17:32 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2014-07-02 20:47:05 -0400 |
commit | e9fc46ab7d8cfe96454067036f0d272b61c7ab0a (patch) | |
tree | 75cc28c4ee94d07757009d3432728d8aca031637 | |
parent | 9353eeba86181872722385f95c013b5b5b98f367 (diff) | |
download | mongo-e9fc46ab7d8cfe96454067036f0d272b61c7ab0a.tar.gz |
SERVER-14254 added jstest for _v8_function.toString()
-rw-r--r-- | jstests/core/where5.js | 28 |
1 files changed, 28 insertions, 0 deletions
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); |