2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2021-11-08 11:22:58 -08:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn single_quotes_are_prepended_and_appended() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
x := quote('abc')
|
|
|
|
",
|
|
|
|
)
|
2023-01-03 22:31:56 -08:00
|
|
|
.args(["--evaluate", "x"])
|
2021-11-08 11:22:58 -08:00
|
|
|
.stdout("'abc'")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn quotes_are_escaped() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
r#"
|
|
|
|
x := quote("'")
|
|
|
|
"#,
|
|
|
|
)
|
2023-01-03 22:31:56 -08:00
|
|
|
.args(["--evaluate", "x"])
|
2021-11-08 11:22:58 -08:00
|
|
|
.stdout(r"''\'''")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn quoted_strings_can_be_used_as_arguments() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
r#"
|
|
|
|
file := quote("foo ' bar")
|
|
|
|
|
|
|
|
@foo:
|
|
|
|
touch {{ file }}
|
|
|
|
ls -1
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.stdout("foo ' bar\njustfile\n")
|
|
|
|
.run();
|
|
|
|
}
|