Skip to content

Commit

Permalink
Add test case for syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Oct 18, 2024
1 parent ad21719 commit a29dd67
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/_snaps/scan-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,23 @@
2 2 a "(call)\n" 1
3 3 b "(call)\n" 1

# syntax error is handled

Code
code_query("f(1); g(1,2); 1+; h(3)", "(call) @call-code")
Output
$patterns
# A data frame: 1 x 4
id name pattern match_count
<int> <chr> <chr> <int>
1 1 <NA> "(call) @call-code\n" 3
$matched_captures
# A data frame: 3 x 8
id pattern match start_byte start_row start_column name code
<int> <int> <int> <int> <int> <int> <chr> <chr>
1 1 1 1 1 1 1 call-code f(1)
2 1 1 2 7 1 7 call-code g(1,2)
3 1 1 3 19 1 19 call-code h(3)

6 changes: 6 additions & 0 deletions tests/testthat/test-scan-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ test_that("pattern names", {
code_query("f('x')", c(a = "(call) (call)", b = "(call)"))[["patterns"]]
})
})

test_that("syntax error is handled", {
expect_snapshot({
code_query("f(1); g(1,2); 1+; h(3)", "(call) @call-code")
})
})

0 comments on commit a29dd67

Please sign in to comment.