From 057d2992972742eaf969f1f9c7ca9b991fefe53a Mon Sep 17 00:00:00 2001 From: marceloll Date: Wed, 6 Jan 2021 12:17:21 -0300 Subject: [PATCH] Allow comments only at line start --- cli/src/test.rs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/cli/src/test.rs b/cli/src/test.rs index ca07fb07..d7bfc3b9 100644 --- a/cli/src/test.rs +++ b/cli/src/test.rs @@ -22,7 +22,7 @@ lazy_static! { .multi_line(true) .build() .unwrap(); - static ref COMMENT_REGEX: Regex = Regex::new(r";.*").unwrap(); + static ref COMMENT_REGEX: Regex = Regex::new(r"(?m)^\s*;.*$").unwrap(); static ref WHITESPACE_REGEX: Regex = Regex::new(r"\s+").unwrap(); static ref SEXP_FIELD_REGEX: Regex = Regex::new(r" \w+: \(").unwrap(); } @@ -597,7 +597,7 @@ output 2 "the-filename".to_string(), r#" ================== -Code with comment +sexp with comment ================== code --- @@ -605,13 +605,26 @@ code ; Line start comment (a (b)) +================== +sexp with comment between +================== +code +--- + +; Line start comment +(a +; ignore this + (b) + ; also ignore this +) + ========================= -Code line ending with comment +sexp with ';' ========================= code --- -(c (d)) ; Line end comment +(MISSING ";") "# .trim() .to_string(), @@ -624,17 +637,23 @@ code name: "the-filename".to_string(), children: vec![ TestEntry::Example { - name: "Code with comment".to_string(), + name: "sexp with comment".to_string(), input: "code".as_bytes().to_vec(), output: "(a (b))".to_string(), has_fields: false, }, TestEntry::Example { - name: "Code line ending with comment".to_string(), + name: "sexp with comment between".to_string(), input: "code".as_bytes().to_vec(), - output: "(c (d))".to_string(), + output: "(a (b))".to_string(), has_fields: false, }, + TestEntry::Example { + name: "sexp with ';'".to_string(), + input: "code".as_bytes().to_vec(), + output: "(MISSING \";\")".to_string(), + has_fields: false, + } ], file_path: None, }