Skip to content

Commit

Permalink
add a small test for the parser error as well
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Feb 1, 2024
1 parent 67de5ab commit cc0ebfe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions vlib/v/parser/tests/tmpl/include.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
some text

@include abc.txt

some more text
7 changes: 7 additions & 0 deletions vlib/v/parser/tests/tmpl_include_without_quotes.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vlib/v/parser/tests/tmpl/include.txt:3:10: error: path for @include must be quoted with ' or "
1 | some text
2 |
3 | @include abc.txt
| ~~~~~~~
4 |
5 | some more text
6 changes: 6 additions & 0 deletions vlib/v/parser/tests/tmpl_include_without_quotes.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
a := 'foo'
b := 'bar'
result := $tmpl('tmpl/include.txt')
assert result.trim_space() == 'foo\nbar'
}
3 changes: 2 additions & 1 deletion vlib/v/parser/tmpl.v
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ fn vweb_tmpl_${fn_name}() string {
len: s.len
line_nr: tline_number
pos: start_of_line_pos + position + s.len
last_line: lines.len
col: position + s.len
last_line: lines.len + 1
}
reporter: .parser
})
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/tests/tmpl/include.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@include "a.txt"
@include 'b.txt'
@include 'b.txt'

0 comments on commit cc0ebfe

Please sign in to comment.