//! `--check` proves the committed files match a fresh generation; it cannot //! prove the generation is RIGHT, because it compares the generator with //! itself. These are the judgements inside it that a rewrite could get wrong //! while every byte still matched. use super::*; #[test] fn a_string_literal_escapes_what_swift_cannot_carry_raw() { assert_eq!(swift_str("Photos & videos"), "\"Photos & videos\""); assert_eq!(swift_str("a \"quote\""), "\"a \\\"quote\\\"\""); assert_eq!(swift_str("a\\b"), "\"a\\\\b\""); assert_eq!(swift_str("one\ntwo"), "\"one\\ntwo\""); assert_eq!(swift_str("one\ttwo"), "\"one\\ttwo\""); // ⌘ and — travel as themselves: Swift source is UTF-8. assert_eq!(swift_str("To decide"), "\"To decide\""); } #[test] fn a_raw_literal_wraps_a_pattern_whose_backslashes_are_its_own() { assert_eq!( swift_raw(r"\bthe box(es)?\b").expect("a raw literal"), "#\"\\bthe box(es)?\\b\"#" ); } #[test] fn a_raw_literal_refuses_a_pattern_that_would_end_it_early() { // `"#` closes a `#"…"#` literal, so a pattern containing it emits Swift // that does not compile — better to fail here, where the message says why. let refused = swift_raw("a \"# b").expect_err("refused"); assert!(refused.contains("cannot be a raw literal"), "{refused}"); }