mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-06 05:53:08 -05:00
Merge main into feat/js-es2017-async-await
This commit is contained in:
commit
b0516ec95e
1167 files changed
+166346
-265568
No files matched your search
@@ -521,12 +521,15 @@ fn script_included_error_has_local_file_and_line() {
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// `$.stack`'s text with each frame's file cut to its name: `function@name:line` a line.
|
||||
/// `$.stack`'s text with each frame's file cut to its name. The first line is the run's name
|
||||
/// (`[script name]`) and is kept as written; each line after it is `function@name:line`.
|
||||
pub(crate) fn short_stack(stack: &Value) -> String {
|
||||
let stack = stack.as_str().unwrap_or_else(|| panic!("a stack: {stack}"));
|
||||
stack
|
||||
.lines()
|
||||
.map(|frame| match (frame.split_once('@'), frame.rsplit_once(':')) {
|
||||
.enumerate()
|
||||
.map(|(i, frame)| match (frame.split_once('@'), frame.rsplit_once(':')) {
|
||||
_ if i == 0 => format!("{frame}\n"),
|
||||
(Some((name, _)), Some((place, line))) => {
|
||||
let file = place.split_once('@').map_or(place, |(_, f)| f).rsplit(['/', '\\']).next().unwrap_or_default();
|
||||
format!("{name}@{file}:{line}\n")
|
||||
@@ -554,12 +557,12 @@ fn script_line_and_stack_are_at_the_line_of_each_file() {
|
||||
let log = run(&base, text).unwrap()["log"].clone();
|
||||
assert_eq!(log[0], json!([5, 3, 4]), "{log}");
|
||||
assert_eq!(log[1][0], 3, "{log}");
|
||||
assert_eq!(short_stack(&log[1][1]), "[global]@main.jsx:6\n[email protected]:3\n");
|
||||
assert_eq!(short_stack(&log[2]), "[global]@main.jsx:7\n[email protected]:5\n");
|
||||
assert_eq!(short_stack(&log[1][1]), "[main.jsx]\n[global]@main.jsx:6\n[email protected]:3\n");
|
||||
assert_eq!(short_stack(&log[2]), "[main.jsx]\n[global]@main.jsx:7\n[email protected]:5\n");
|
||||
assert_eq!(log[3][0], 4, "{log}");
|
||||
assert_eq!(short_stack(&log[3][1]), "[global]@main.jsx:8\n[global]@ev.jsx:5\n[email protected]:3\n[email protected]:4\n");
|
||||
assert_eq!(short_stack(&log[3][1]), "[main.jsx]\n[global]@main.jsx:8\n[global]@ev.jsx:5\n[email protected]:3\n[email protected]:4\n");
|
||||
// The file a frame names is the one `$.fileName` gives while that file runs.
|
||||
let log = run(&base, "vc.log($.stack.slice(9, -3) === $.fileName);").unwrap()["log"].clone();
|
||||
let log = run(&base, "vc.log($.stack.split('\\n')[1].slice(9, -2) === $.fileName);").unwrap()["log"].clone();
|
||||
assert_eq!(log, json!([true]));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user