Tests: name BridgeTalk where a run needs an object scripts here do not have

Window is defined now that ScriptUI dialogs run, so new Window('dialog') no longer fails with the advice that names the `vc` object. an_error_names_the_script_its_place_and_kind and failed_script_report_keeps_message_and_adds_origin use new BridgeTalk() instead, which still fails with that advice.
This commit is contained in:
dotCooCoo committed 2026-11-27 23:08:16 -08:00
1 parent f794e81014
commit 9acde80654
1 file changed
+3 -3
+3 -3
View File
@@ -165,7 +165,7 @@ fn an_error_names_the_script_its_place_and_kind() {
assert_eq!(e, "t.js: line 2, column 3: TypeError: no (thrown)");
let e = run(&mut s, "var = 1;").unwrap_err().to_string();
assert!(e.starts_with("t.js: line 1,") && e.ends_with("(syntax)"), "{e}");
assert!(run(&mut s, "new Window('dialog');").unwrap_err().to_string().contains("`vc`"));
assert!(run(&mut s, "new BridgeTalk();").unwrap_err().to_string().contains("`vc`"));
// The application's members need no `app.`, so naming one alone is not an error.
assert_eq!(run(&mut s, "activeDocument;").unwrap()["ok"], true);
assert!(run(&mut s, "#targetengine 9x\n1").unwrap_err().to_string().contains("#targetengine needs a name of letters, digits and _"));
@@ -182,7 +182,7 @@ fn failed_script_report_keeps_message_and_adds_origin() {
("throw new Error('invalid array length');", "thrown", "Error: invalid array length", "script"),
("throw new RangeError('invalid array length');", "thrown", "RangeError: invalid array length", "script"),
("throw 'invalid array length';", "thrown", "invalid array length", "script"),
("throw 'ReferenceError: Window is not defined';", "thrown", "ReferenceError: Window is not defined", "script"),
("throw 'ReferenceError: BridgeTalk is not defined';", "thrown", "ReferenceError: BridgeTalk is not defined", "script"),
("try { new Array(-1); } catch (e) { throw new Error(e.message); }", "thrown", "Error: invalid array length", "script"),
("new Array(-1);", "thrown", "RangeError: invalid array length", "built-in"),
("try { new Array(-1); } catch (e) { throw e; }", "thrown", "RangeError: invalid array length", "built-in"),
@@ -206,7 +206,7 @@ fn failed_script_report_keeps_message_and_adds_origin() {
assert_eq!(error, Some(json!(format!("t.js:{line}:{column}: {message}"))), "{source}");
}
// The app's own reference error names the `vc` object; the same text a script threw does not.
run(&mut s, "new Window('dialog');").unwrap_err();
run(&mut s, "new BridgeTalk();").unwrap_err();
assert!(s.script_report().unwrap()["message"].as_str().unwrap().contains("`vc`"));
assert_eq!(s.script_report().unwrap()["messageOrigin"], "built-in");
// An error in code `eval` compiled keeps where its message came from.