| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5869f2b commit c40e242
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,17 +28,22 @@ const o = vm.createContext({ console }); | |||
| 28 | 28 | ||
| 29 | 29 | // Function declaration and expression should both be copied to the | |
| 30 | 30 | // sandboxed context. | |
| 31 | - let code = 'var a = function() {};\n'; | ||
| 31 | + let code = 'let a = function() {};\n'; | ||
| 32 | 32 | code += 'function b(){}\n'; | |
| 33 | + code += 'var c = function() {};\n'; | ||
| 34 | + code += 'var d = () => {};\n'; | ||
| 35 | + code += 'let e = () => {};\n'; | ||
| 33 | 36 | ||
| 34 | 37 | // Grab the global b function as the completion value, to ensure that | |
| 35 | 38 | // we are getting the global function, and not some other thing | |
| 36 | 39 | code += '(function(){return this})().b;\n'; | |
| 37 | 40 | ||
| 38 | 41 | const res = vm.runInContext(code, o, 'test'); | |
| 39 | - | ||
| 40 | 42 | assert.strictEqual(typeof res, 'function'); | |
| 41 | 43 | assert.strictEqual(res.name, 'b'); | |
| 42 | - assert.strictEqual(typeof o.a, 'function'); | ||
| 44 | + assert.strictEqual(typeof o.a, 'undefined'); | ||
| 43 | 45 | assert.strictEqual(typeof o.b, 'function'); | |
| 46 | + assert.strictEqual(typeof o.c, 'function'); | ||
| 47 | + assert.strictEqual(typeof o.d, 'function'); | ||
| 48 | + assert.strictEqual(typeof o.e, 'undefined'); | ||
| 44 | 49 | assert.strictEqual(res, o.b); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments