diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2015-09-09 15:53:45 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2015-09-17 13:26:57 -0400 |
commit | 4ea1fa9899eb5d8f2d529fd4344c628f4792e4de (patch) | |
tree | 7ceb23de86b50634c42fe84b72efa77cf5b1c9ec /jstests/core | |
parent | 46e120855cc02c6db99ab42fe4e9b6d2e1ac9198 (diff) | |
download | mongo-4ea1fa9899eb5d8f2d529fd4344c628f4792e4de.tar.gz |
SERVER-9739 db.loadServerScripts shouldn't use eval
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/loadserverscripts.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/jstests/core/loadserverscripts.js b/jstests/core/loadserverscripts.js index aa8d1dea486..c0b5a4065a1 100644 --- a/jstests/core/loadserverscripts.js +++ b/jstests/core/loadserverscripts.js @@ -20,12 +20,20 @@ assert.eq( typeof myfunc2, "undefined", "Checking that myfunc2() is undefined" ) // Insert a function in the context of this process: make sure it's in the collection testdb.system.js.insert( { _id: "myfunc", "value": function(){ return "myfunc"; } } ); +testdb.system.js.insert( { _id: "mystring", "value": "var root = this;" } ); +testdb.system.js.insert( { _id: "changeme", "value": false }); + x = testdb.system.js.count(); -assert.eq( x, 1, "Should now be one function in the system.js collection"); +assert.eq( x, 3, "Should now be one function in the system.js collection"); + +// Set a global variable that will be over-written +var changeme = true // Load that function testdb.loadServerScripts(); assert.eq( typeof myfunc, "function", "Checking that myfunc() loaded correctly" ); +assert.eq( typeof mystring, "string", "Checking that mystring round-tripped correctly" ); +assert.eq( changeme, false, "Checking that global var was overwritten" ); // Make sure it works x = myfunc(); @@ -41,7 +49,7 @@ coproc(); // Make sure the collection's been updated x = testdb.system.js.count(); -assert.eq( x, 2, "Should now be two functions in the system.js collection"); +assert.eq( x, 4, "Should now be two functions in the system.js collection"); // Load the new functions: test them as above |