Stop empty comments from swallowing the next line (#247)

This commit is contained in:
Casey Rodarmor 2017-11-15 12:53:01 -08:00 committed by GitHub
parent b9e1f73919
commit 3acd56646f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -1614,3 +1614,17 @@ echo A B C:
stderr: "echo --some --awesome --flags\n",
status: EXIT_SUCCESS,
}
integration_test! {
name: comment_before_variable,
justfile: "
#
A='1'
echo:
echo {{A}}
",
args: ("echo"),
stdout: "1\n",
stderr: "echo 1\n",
status: EXIT_SUCCESS,
}

View File

@ -1528,7 +1528,7 @@ fn tokenize(text: &str) -> Result<Vec<Token>, CompileError> {
static ref BACKTICK: Regex = token(r"`[^`\n\r]*`" );
static ref COLON: Regex = token(r":" );
static ref AT: Regex = token(r"@" );
static ref COMMENT: Regex = token(r"#([^!].*)?$" );
static ref COMMENT: Regex = token(r"#([^!\n\r].*)?$" );
static ref EOF: Regex = token(r"(?-m)$" );
static ref EOL: Regex = token(r"\n|\r\n" );
static ref EQUALS: Regex = token(r"=" );

View File

@ -156,6 +156,17 @@ hello:
tokenize_success(text, "$#$N:$>^_$^_$$^_$$^_$$<#$.");
}
#[test]
fn tokenize_comment_before_variable() {
let text = "
#
A='1'
echo:
echo {{A}}
";
tokenize_success(text, "$#$N='$N:$>^_{N}$<.");
}
#[test]
fn tokenize_interpolation_backticks() {
tokenize_success(