diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-02-09 13:55:40 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-09 16:55:40 -0500 |
commit | 1d36eb47eb882cb9305a6338019fa2a2b375d7b1 (patch) | |
tree | 4584aff9da784f3e05c4fb5314d5911772b4d655 /tools/repl_test.py | |
parent | 1502051453bf16787a59f43004b24d553d39bd26 (diff) |
Support scoped variables, unblock REPL async op, and REPL error colors (#1721)
Diffstat (limited to 'tools/repl_test.py')
-rw-r--r-- | tools/repl_test.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/repl_test.py b/tools/repl_test.py index 1b589de67..2ce692b99 100644 --- a/tools/repl_test.py +++ b/tools/repl_test.py @@ -19,7 +19,7 @@ class Repl(object): def input(self, *lines, **kwargs): exit_ = kwargs.pop("exit", True) sleep_ = kwargs.pop("sleep", 0) - p = Popen([self.deno_exe], stdout=PIPE, stderr=PIPE, stdin=PIPE) + p = Popen([self.deno_exe, "-A"], stdout=PIPE, stderr=PIPE, stdin=PIPE) try: # Note: The repl takes a >100ms until it's ready. time.sleep(sleep_) @@ -87,7 +87,7 @@ class Repl(object): def test_reference_error(self): out, err, code = self.input("not_a_variable") assertEqual(out, '') - assertEqual(err, 'ReferenceError: not_a_variable is not defined\n') + assert "not_a_variable is not defined" in err assertEqual(code, 0) def test_set_timeout(self): @@ -108,16 +108,25 @@ class Repl(object): assertEqual(err, '') assertEqual(code, 0) + def test_async_op(self): + out, err, code = self.input( + "fetch('http://localhost:4545/tests/001_hello.js')" + + ".then(res => res.text()).then(console.log)", + sleep=1) + assertEqual(out, 'Promise {}\nconsole.log("Hello World");\n\n') + assertEqual(err, '') + assertEqual(code, 0) + def test_syntax_error(self): out, err, code = self.input("syntax error") assertEqual(out, '') - assertEqual(err, "SyntaxError: Unexpected identifier\n") + assert "Unexpected identifier" in err assertEqual(code, 0) def test_type_error(self): out, err, code = self.input("console()") assertEqual(out, '') - assertEqual(err, 'TypeError: console is not a function\n') + assert "console is not a function" in err assertEqual(code, 0) def test_variable(self): @@ -126,6 +135,12 @@ class Repl(object): assertEqual(err, '') assertEqual(code, 0) + def test_lexical_scoped_variable(self): + out, err, code = self.input("let a = 123;", "a") + assertEqual(out, 'undefined\n123\n') + assertEqual(err, '') + assertEqual(code, 0) + def assertEqual(left, right): if left != right: |