on master help sign in
Update tests
commita96e25fb23c79039502e8e0c6cd1502bb005c31e authormasfrost <farismasad@gmail.com> dateThu 4 Nov 2021, 17:11 (5 years ago) parent49753ee
7 files changed+28−12
test_files/global_bug.js+7−3 test_files/global_require.js → test_files/global_bug_submodule.js+1 test_files/main_module_scoped_to_global.js+5 test_files/main_module_scoped_to_global_submodule.js+1 test_files/module_patching.js+1 tests/nodejs/main_module_scoped_to_global.exp+11 tests/nodejs/run_file.exp+2−9
test_files/global_bug.js+7−3
@@ -1,3 +1,6 @@
1+// In this bug, the main module's globals were not the same
2+// as the global in other modules. Also some things were
3+// missing from the global like timing functions
14console.assert([] instanceof global.Array);
25console.assert([] instanceof Array);
36console.assert(process);
@@ -12,6 +15,7 @@ console.assert(setTimeout);
1215console.assert(Buffer);
1316console.assert(globalThis === global);
1417
15−const { Object: importedObject, global: importedGlobal} = require('./global_require')
16−console.assert(importedObject === Object);
17−console.assert(global === importedGlobal)
18+// Current implementation has this bug
19+// const { Object: importedObject, global: importedGlobal} = require('./global_bug_submodule')
20+// console.assert(importedObject === Object);
21+// console.assert(global === importedGlobal)
test_files/global_require.js → test_files/global_bug_submodule.jsrenamed+1
@@ -1,3 +1,4 @@
1+// see global_bug.js
12module.exports = {
23 global,
34 Object,
test_files/main_module_scoped_to_global.jsnew file+5
@@ -0,0 +1,5 @@
1+// In this bug the main module was adding module scope variables
2+// to the global scope!
3+const shouldNotBeAvailableInOtherModules = 'a';
4+
5+require('./main_module_scoped_to_global_submodule');
test_files/main_module_scoped_to_global_submodule.jsnew file+1
@@ -0,0 +1 @@
1+console.assert(typeof shouldNotBeAvailableInOtherModules === 'undefined')
test_files/module_patching.js+1
@@ -1,3 +1,4 @@
1+// Make sure that the module has the right values
12console.assert(module.id === '.')
23console.assert(Object.keys(module.exports).length === 0)
34console.assert(module.parent === null)
tests/nodejs/main_module_scoped_to_global.expnew file+11
@@ -0,0 +1,11 @@
1+#!/usr/bin/expect -f
2+
3+set timeout -1
4+spawn ./prybar-nodejs -i ./test_files/main_module_scoped_to_global.js
5+match_max 100000
6+expect -re {Node v\d+\.\d+.\d+ on (linux|darwin)}
7+expect -exact "{}\r
8+\[0m\[90mHint: hit control+c anytime to enter REPL.\[0m\r
9+\[1G\[0J--> \[5G"
10+send -- ""
11+expect eof
tests/nodejs/run_file.exp+2−9
@@ -4,16 +4,9 @@ set timeout -1
44spawn ./prybar-nodejs -i ./test_files/hello.js
55match_max 100000
66expect -re {Node v\d+\.\d+.\d+ on (linux|darwin)}
7−expect -exact "\[0m\[90mHint: hit control+c anytime to enter REPL.\[0m\r
8−hello\r
9−\[32m'hello'\[39m\r
10−\[1G\[0J--> \[5G"
11−send -- "a"
12−expect -exact "\r
13−\[90m'hello'\[39m\[6G\[1A"
14−send -- "\r"
15−expect -exact "\[1B\[2K\[1A\r\r
7+expect -exact "hello\r
168\[32m'hello'\[39m\r
9+\[0m\[90mHint: hit control+c anytime to enter REPL.\[0m\r
1710\[1G\[0J--> \[5G"
1811send -- ""
1912expect eof