diff options
Diffstat (limited to 'cli/tests/integration/repl_tests.rs')
-rw-r--r-- | cli/tests/integration/repl_tests.rs | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index b96b398ae..7ce91d406 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -436,7 +436,7 @@ fn exports_stripped() { } #[test] -fn eval_unterminated() { +fn call_eval_unterminated() { let (out, err) = util::run_and_collect_output( true, "repl", @@ -644,3 +644,45 @@ fn custom_inspect() { assert!(out.contains("Oops custom inspect error")); assert!(err.is_empty()); } + +#[test] +fn eval_flag_valid_input() { + let (out, err) = util::run_and_collect_output_with_args( + true, + vec!["repl", "--eval", "const t = 10;"], + Some(vec!["t * 500;"]), + None, + false, + ); + assert!(out.contains("5000")); + assert!(err.is_empty()); +} + +#[test] +fn eval_flag_parse_error() { + let (out, err) = util::run_and_collect_output_with_args( + true, + vec!["repl", "--eval", "const %"], + Some(vec!["250 * 10"]), + None, + false, + ); + assert!(test_util::strip_ansi_codes(&out) + .contains("error in --eval flag. parse error: Unexpected token `%`.")); + assert!(out.contains("2500")); // should not prevent input + assert!(err.is_empty()); +} + +#[test] +fn eval_flag_runtime_error() { + let (out, err) = util::run_and_collect_output_with_args( + true, + vec!["repl", "--eval", "throw new Error('Testing')"], + Some(vec!["250 * 10"]), + None, + false, + ); + assert!(out.contains("error in --eval flag. Uncaught Error: Testing")); + assert!(out.contains("2500")); // should not prevent input + assert!(err.is_empty()); +} |