diff --git a/crates/scriptcheck/src/tests.rs b/crates/scriptcheck/src/tests.rs index 9510e29df2..9e0579ec71 100644 --- a/crates/scriptcheck/src/tests.rs +++ b/crates/scriptcheck/src/tests.rs @@ -621,6 +621,20 @@ fn closing_with_save_changes_writes_a_file() { assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[4, 5, 7][..])]); } +/// `SAVECHANGES` read as a member of anything but `SaveOptions` may still be the save option: through +/// an alias of `SaveOptions` or through an object that holds it. A key of the script's own object +/// literal is not a read, so it writes nothing. +#[test] +fn save_changes_through_another_receiver_writes_a_file() { + let r = report(concat!( + "var o = SaveOptions; app.activeDocument.close(o.SAVECHANGES);\n", + "var k = {how: SaveOptions}; documents[0].close(k.how.SAVECHANGES);\n", + "var own = {SAVECHANGES: 1};\n", + )); + assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[1, 2][..])); + assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::>(), [("filesWritten", &[1, 2][..])]); +} + /// `saveAs` and `exportFile` called with their names as string literals in brackets write the file /// too; reading the method without calling it does not. #[test]