-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy paththread_args.js
42 lines (37 loc) · 1.3 KB
/
thread_args.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* This test makes makes sure Thread works with --enableJavaScriptProtection
*/
import {Thread} from "jstests/libs/parallelTester.js";
function testThread(threadType) {
function threadFn(args) {
// Ensure objects are passed through properly
assert(args instanceof Object);
// Ensure functions inside objects are still functions
assert(args.func1 instanceof Function);
assert(args.func1());
// Ensure Code objects are converted to functions
assert(args.func2 instanceof Function);
assert(args.func2());
// Ensure arrays are passed through properly
assert(args.funcArray instanceof Array);
// Ensure functions inside arrays are still functions.
assert(args.funcArray[0] instanceof Function);
assert(args.funcArray[0]());
return true;
}
function returnTrue() {
return true;
}
var args = {
func1: returnTrue,
// Pass some Code objects to simulate what happens with --enableJavaScriptProtection
func2: new Code(returnTrue.toString()),
funcArray: [new Code(returnTrue.toString())]
};
var thread = new threadType(threadFn, args);
thread.start();
thread.join();
assert(thread.returnData());
}
// Test the Thread class
testThread(Thread);