diff options
-rw-r--r-- | cli/repl.rs | 9 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 49 |
2 files changed, 53 insertions, 5 deletions
diff --git a/cli/repl.rs b/cli/repl.rs index 1cc866a6f..b2ea32670 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -171,11 +171,10 @@ impl Validator for Helper { left )))) } - (None, c) => { - return Ok(ValidationResult::Invalid(Some(format!( - "Mismatched pairs: {:?} is unpaired", - c - )))) + (None, _) => { + // While technically invalid when unpaired, it should be V8's task to output error instead. + // Thus marked as valid with no info. + return Ok(ValidationResult::Valid(None)); } }, _ => {} diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index da0a311bb..f7b4c345a 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1268,6 +1268,40 @@ fn repl_test_pty_multiline() { } } +#[cfg(unix)] +#[test] +fn repl_test_pty_unpaired_braces() { + use std::io::Read; + use util::pty::fork::*; + + let tests_path = util::tests_path(); + let fork = Fork::from_ptmx().unwrap(); + if let Ok(mut master) = fork.is_parent() { + master.write_all(b")\n").unwrap(); + master.write_all(b"]\n").unwrap(); + master.write_all(b"}\n").unwrap(); + master.write_all(b"close();\n").unwrap(); + + let mut output = String::new(); + master.read_to_string(&mut output).unwrap(); + + assert!(output.contains("Unexpected token ')'")); + assert!(output.contains("Unexpected token ']'")); + assert!(output.contains("Unexpected token '}'")); + + fork.wait().unwrap(); + } else { + util::deno_cmd() + .current_dir(tests_path) + .env("NO_COLOR", "1") + .arg("repl") + .spawn() + .unwrap() + .wait() + .unwrap(); + } +} + #[test] fn run_watch_with_importmap_and_relative_paths() { fn create_relative_tmp_file( @@ -1517,6 +1551,21 @@ fn repl_test_eval_unterminated() { } #[test] +fn repl_test_unpaired_braces() { + for right_brace in &[")", "]", "}"] { + let (out, err) = util::run_and_collect_output( + true, + "repl", + Some(vec![right_brace]), + None, + false, + ); + assert!(out.contains("Unexpected token")); + assert!(err.is_empty()); + } +} + +#[test] fn repl_test_reference_error() { let (out, err) = util::run_and_collect_output( true, |