mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
feat(repl): add global clear() function (#14332)
This commit adds a clear() function in the REPL which works similar to console.clear().
This commit is contained in:
parent
f785ecee1a
commit
2a93c134dc
2 changed files with 20 additions and 0 deletions
|
@ -761,3 +761,21 @@ fn eval_file_flag_multiple_files() {
|
||||||
assert!(out.contains("helloFOO"));
|
assert!(out.contains("helloFOO"));
|
||||||
assert!(err.contains("Download"));
|
assert!(err.contains("Download"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pty_clear_function() {
|
||||||
|
util::with_pty(&["repl"], |mut console| {
|
||||||
|
console.write_line("console.log('hello');");
|
||||||
|
console.write_line("clear();");
|
||||||
|
console.write_line("const clear = 1 + 2;");
|
||||||
|
console.write_line("clear;");
|
||||||
|
console.write_line("close();");
|
||||||
|
|
||||||
|
let output = console.read_all_output();
|
||||||
|
assert!(output.contains("hello"));
|
||||||
|
assert!(output.contains("[1;1H"));
|
||||||
|
assert!(output.contains("undefined"));
|
||||||
|
assert!(output.contains("const clear = 1 + 2;"));
|
||||||
|
assert!(output.contains('3'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ Object.defineProperty(globalThis, "_error", {
|
||||||
console.log("Last thrown error is no longer saved to _error.");
|
console.log("Last thrown error is no longer saved to _error.");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
globalThis.clear = console.clear.bind(console);
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
pub enum EvaluationOutput {
|
pub enum EvaluationOutput {
|
||||||
|
|
Loading…
Reference in a new issue