diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-05-29 20:24:06 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 12:24:06 +0200 |
commit | 2668637e9bad75bef016e7f8a5f481b3c6221891 (patch) | |
tree | 5c3d2801e7de03e14f6896db402941dc3f2846d2 /cli/tests/integration_tests.rs | |
parent | 958f21e7abc36f0a5abaa381ed8d7f94c723f3fb (diff) |
fix: REPL evaluates in strict mode (#5565)
Since everything that Deno loads is treated as an ES Module,
it means that all code is treated as "use strict" except for
when using the REPL. This PR changes that so code in the
REPL is also always evaluated with "use strict". There are
also a couple other places where we load code as scripts
which should also use "use strict" just in case.
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r-- | cli/tests/integration_tests.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 606a40516..f892b9a87 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -693,6 +693,24 @@ fn repl_test_eof() { assert!(err.is_empty()); } +#[test] +fn repl_test_strict() { + let (_, err) = util::run_and_collect_output( + true, + "repl", + Some(vec![ + "let a = {};", + "Object.preventExtensions(a);", + "a.c = 1;", + ]), + None, + false, + ); + assert!(err.contains( + "Uncaught TypeError: Cannot add property c, object is not extensible" + )); +} + const REPL_MSG: &str = "exit using ctrl+d or close()\n"; #[test] |