require variable names to follow additional restrictions (#6125)

This commit is contained in:
JT
2022-07-27 14:08:54 +12:00
committed by GitHub
parent d42cfab6ef
commit 9695331eed
4 changed files with 133 additions and 19 deletions

View File

@ -67,7 +67,7 @@ fn do_rest_args() -> TestResult {
#[test]
fn custom_switch1() -> TestResult {
run_test(
r#"def florb [ --dry-run: bool ] { if ($dry-run) { "foo" } else { "bar" } }; florb --dry-run"#,
r#"def florb [ --dry-run: bool ] { if ($dry_run) { "foo" } else { "bar" } }; florb --dry-run"#,
"foo",
)
}
@ -75,7 +75,7 @@ fn custom_switch1() -> TestResult {
#[test]
fn custom_switch2() -> TestResult {
run_test(
r#"def florb [ --dry-run: bool ] { if ($dry-run) { "foo" } else { "bar" } }; florb"#,
r#"def florb [ --dry-run: bool ] { if ($dry_run) { "foo" } else { "bar" } }; florb"#,
"bar",
)
}
@ -83,7 +83,7 @@ fn custom_switch2() -> TestResult {
#[test]
fn custom_switch3() -> TestResult {
run_test(
r#"def florb [ --dry-run ] { if ($dry-run) { "foo" } else { "bar" } }; florb --dry-run"#,
r#"def florb [ --dry-run ] { if ($dry_run) { "foo" } else { "bar" } }; florb --dry-run"#,
"foo",
)
}
@ -91,7 +91,7 @@ fn custom_switch3() -> TestResult {
#[test]
fn custom_switch4() -> TestResult {
run_test(
r#"def florb [ --dry-run ] { if ($dry-run) { "foo" } else { "bar" } }; florb"#,
r#"def florb [ --dry-run ] { if ($dry_run) { "foo" } else { "bar" } }; florb"#,
"bar",
)
}

View File

@ -114,6 +114,11 @@ fn bad_var_name() -> TestResult {
fail_test(r#"let $"foo bar" = 4"#, "can't contain")
}
#[test]
fn bad_var_name2() -> TestResult {
fail_test(r#"let $foo-bar = 4"#, "valid variable")
}
#[test]
fn long_flag() -> TestResult {
run_test(