Files
mongo/jstests/core/eval9.js
Max Hirschhorn 35b5b72146 SERVER-32522 Clean up {read,write}Concern and readPreference overrides.
Introduces OverrideHelpers object with convenience methods for
inspecting certain aggregation and map-reduce commands, as well as
overriding startParallelShell(), Mongo.prototype.runCommand(), and
Mongo.prototype.runCommandWithMetadata().

Also removes a number of tests that were incorrectly blacklisted from
the read_concern_majority_passthrough.yml and
read_concern_linearizable_passthrough.yml test suites.
2018-01-30 19:45:42 -05:00

34 lines
1011 B
JavaScript

// @tags: [
// # Cannot implicitly shard accessed collections because unsupported use of sharded collection
// # from db.eval.
// assumes_unsharded_collection,
// requires_eval_command,
// requires_non_retryable_commands,
// ]
assert.writeOK(db.evalprep.insert({}), "db must exist for eval to succeed");
db.evalprep.drop();
a = [1, "asd", null, [2, 3], new Date(), {x: 1}];
for (var i = 0; i < a.length; i++) {
var ret = db.eval("function( a , i ){ return a[i]; }", a, i);
assert.eq(typeof(a[i]), typeof(ret), "type test");
assert.eq(a[i], ret, "val test: " + typeof(a[i]));
}
db.eval9.drop();
db.eval9.save({a: 17});
assert.eq(1, db.eval("return db.eval9.find().toArray()").length, "A");
assert.eq(17, db.eval("return db.eval9.find().toArray()")[0].a, "B");
// just to make sure these things don't crash (but may throw an exception)
try {
db.eval("return db.eval9.find()");
db.eval("return db.eval9");
db.eval("return db");
db.eval("return print");
} catch (ex) {
}