| 1 |
test_that("Code diagnostics", { |
| 2 |
suppressMessages({ |
| 3 |
expect_false(diagnoseCode(text = "div(,)")) |
| 4 |
expect_false(diagnoseCode(text = "div(a,)")) |
| 5 |
expect_false(diagnoseCode(text = "div(,a)")) |
| 6 |
expect_false(diagnoseCode(text = "div(a,,b)")) |
| 7 |
expect_false(diagnoseCode(text = "div(a,\n,b)")) |
| 8 |
expect_false(diagnoseCode(text = "div(a,,b,)")) |
| 9 |
expect_false(diagnoseCode(text = "div(a,b))")) |
| 10 |
expect_false(diagnoseCode(text = "div()}")) |
| 11 |
expect_false(diagnoseCode(text = "div())")) |
| 12 |
expect_false(diagnoseCode(text = "div()]")) |
| 13 |
}) |
| 14 |
|
| 15 |
|
| 16 |
# Ambiguous - these aren't valid R code, but they're outside the scope of |
| 17 |
# diagnoseCode, at least for now. |
| 18 |
# expect_false(diagnoseCode(text = "a,,b")) |
| 19 |
# expect_false(diagnoseCode(text = "div(a, ==2 )")) |
| 20 |
# expect_false(diagnoseCode(text = "div(a,!,b)")) |
| 21 |
# expect_false(diagnoseCode(text = "1 2")) |
| 22 |
|
| 23 |
# Should not error |
| 24 |
expect_true(diagnoseCode(text = "div()")) |
| 25 |
expect_true(diagnoseCode(text = "div(a)")) |
| 26 |
expect_true(diagnoseCode(text = "div(a,b)")) |
| 27 |
expect_true(diagnoseCode(text = "div(1,'b')")) |
| 28 |
expect_true(diagnoseCode(text = "div(a,~b)")) |
| 29 |
expect_true(diagnoseCode(text = "div([mtcars,,FALSE])")) |
| 30 |
expect_true(diagnoseCode(text = "div(a, 1==2)")) |
| 31 |
|
| 32 |
# Outside of () scope |
| 33 |
expect_true(diagnoseCode(text = "1\n2")) |
| 34 |
}) |