From 68bf43fca7990d4e623b66243c2840ca7f0c3628 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 17 May 2022 20:49:55 +0530 Subject: feat(core): deterministic snapshots (#14037) --- cli/tests/integration/eval_tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cli/tests/integration/eval_tests.rs') diff --git a/cli/tests/integration/eval_tests.rs b/cli/tests/integration/eval_tests.rs index d7586e919..d7503ca80 100644 --- a/cli/tests/integration/eval_tests.rs +++ b/cli/tests/integration/eval_tests.rs @@ -20,6 +20,30 @@ fn eval_p() { assert_eq!("3", stdout_str); } +// Make sure that snapshot flags don't affect runtime. +#[test] +fn eval_randomness() { + let mut numbers = Vec::with_capacity(10); + for _ in 0..10 { + let output = util::deno_cmd() + .arg("eval") + .arg("-p") + .arg("Math.random()") + .stdout(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + assert!(output.status.success()); + let stdout_str = util::strip_ansi_codes( + std::str::from_utf8(&output.stdout).unwrap().trim(), + ); + numbers.push(stdout_str.to_string()); + } + numbers.dedup(); + assert!(numbers.len() > 1); +} + itest!(_029_eval { args: "eval console.log(\"hello\")", output: "029_eval.out", -- cgit v1.2.3