Skip to content

Commit 0d4cc51

Browse files
Use expect_no_warning()
Instead of `expect_warning()` + `NA` combo
1 parent 4f1d0c0 commit 0d4cc51

File tree

61 files changed

+359
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+359
-363
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Suggests:
4444
roxygen2,
4545
rstudioapi (>= 0.7),
4646
tibble (>= 1.4.2),
47-
testthat (>= 3.0.0)
47+
testthat (>= 3.2.1)
4848
VignetteBuilder:
4949
knitr
5050
Encoding: UTF-8

tests/testthat/test-curly-curly.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
test_that("curly-culry", {
2-
expect_warning(test_collection("curly-curly",
2+
expect_no_warning(test_collection("curly-curly",
33
"mixed",
44
transformer = style_text
5-
), NA)
5+
))
66
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
test_that("does apply spacing rules only if not aligned", {
2-
expect_warning(test_collection("alignment",
2+
expect_no_warning(test_collection("alignment",
33
transformer = style_text
4-
), NA)
4+
))
55

66
text <- "tribble(\n ~x, ~y,\n 11, list(a = 1),\n 2, list(bjj = 2)\n)"
7-
expect_warning(style_text(text), NA)
7+
expect_no_warning(style_text(text))
88
})

tests/testthat/test-escaping.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
test_that("escaping of characters works", {
2-
expect_warning(test_collection("escaping", "basic",
2+
expect_no_warning(test_collection("escaping", "basic",
33
transformer = style_text
4-
), NA)
4+
))
55

66
expect_error(test_collection("escaping", "fail-parsing-1",
77
transformer = style_text

tests/testthat/test-fun_dec.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
test_that("reindent function declaration", {
2-
expect_warning(test_collection("fun_dec", "fun_dec_scope_spaces",
2+
expect_no_warning(test_collection("fun_dec", "fun_dec_scope_spaces",
33
transformer = style_text, scope = "spaces"
4-
), NA)
4+
))
55

6-
expect_warning(test_collection("fun_dec", "line_break_fun_dec",
6+
expect_no_warning(test_collection("fun_dec", "line_break_fun_dec",
77
transformer = style_text
8-
), NA)
8+
))
99
})

tests/testthat/test-indention_curly.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
test_that("indention on one-liner curley only is not changed", {
2-
expect_warning(test_collection("indention_curly_brackets",
2+
expect_no_warning(test_collection("indention_curly_brackets",
33
"one_line_curly",
44
transformer = style_text
5-
), NA)
5+
))
66
})
77

88
test_that("indention with multi-line curley only is correct", {
9-
expect_warning(test_collection("indention_curly_brackets",
9+
expect_no_warning(test_collection("indention_curly_brackets",
1010
"multi_line_curly_only",
1111
transformer = style_text_without_curly_curly
12-
), NA)
12+
))
1313
})
1414

1515

1616
test_that("indention with multi-line curley and round is correct", {
17-
expect_warning(test_collection("indention_curly_brackets",
17+
expect_no_warning(test_collection("indention_curly_brackets",
1818
"multi_line_curly_round_only",
1919
transformer = style_text
20-
), NA)
20+
))
2121
})
2222

2323
test_that("custom indention for curly braces is corretct ", {
24-
expect_warning(test_collection("indention_curly_brackets",
24+
expect_no_warning(test_collection("indention_curly_brackets",
2525
"custom",
2626
transformer = style_text, indent_by = 4
27-
), NA)
27+
))
2828
})
2929

3030

@@ -33,13 +33,13 @@ test_that(paste(
3333
"complete styling via top-level api is correct",
3434
"(round, curly, spacing)"
3535
), {
36-
expect_warning(test_collection("indention_curly_brackets",
36+
expect_no_warning(test_collection("indention_curly_brackets",
3737
"multi_line_curly_round_spacing",
3838
transformer = style_text
39-
), NA)
39+
))
4040

41-
expect_warning(test_collection("indention_curly_brackets",
41+
expect_no_warning(test_collection("indention_curly_brackets",
4242
"multi_line_curly_while_for_if_fun",
4343
transformer = style_text
44-
), NA)
44+
))
4545
})
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test_that("edge cases work", {
2-
expect_warning(test_collection("indention_fun_calls",
2+
expect_no_warning(test_collection("indention_fun_calls",
33
transformer = style_text, strict = FALSE
4-
), NA)
4+
))
55
})
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
test_that("multiple round brackets don't cause extraindention", {
2-
expect_warning(test_collection("indention_multiple",
2+
expect_no_warning(test_collection("indention_multiple",
33
"round_only",
44
transformer = style_text
5-
), NA)
5+
))
66

7-
expect_warning(test_collection("indention_multiple",
7+
expect_no_warning(test_collection("indention_multiple",
88
"round_closing_on_same_line",
99
transformer = style_text
10-
), NA)
10+
))
1111
})
1212

1313

1414
test_that("multiple curly brackets don't cause extraindention", {
15-
expect_warning(test_collection("indention_multiple",
15+
expect_no_warning(test_collection("indention_multiple",
1616
"curly_only",
1717
transformer = style_text_without_curly_curly
18-
), NA)
18+
))
1919
})
2020

2121

2222
test_that("multiple curly and round brackets don't cause extraindention", {
23-
expect_warning(test_collection("indention_multiple",
23+
expect_no_warning(test_collection("indention_multiple",
2424
"curly_and_round",
2525
transformer = style_text_without_curly_curly
26-
), NA)
26+
))
2727
})
2828

2929

3030

3131
test_that("multiple curly and round brackets overall test", {
32-
expect_warning(test_collection("indention_multiple",
32+
expect_no_warning(test_collection("indention_multiple",
3333
"overall",
3434
transformer = style_text
35-
), NA)
35+
))
3636
})
3737

3838
test_that("if and ifelse interacting with curly braces works", {
39-
expect_warning(test_collection("indention_multiple",
39+
expect_no_warning(test_collection("indention_multiple",
4040
"if_else_curly",
4141
transformer = style_text, strict = FALSE
42-
), NA)
42+
))
4343
})
4444

4545
test_that("edge cases work", {
46-
expect_warning(test_collection("indention_multiple",
46+
expect_no_warning(test_collection("indention_multiple",
4747
"edge_strict",
4848
transformer = style_text_without_curly_curly
49-
), NA)
49+
))
5050
})
5151

5252
test_that("token / braces interaction works", {
53-
expect_warning(test_collection("indention_multiple",
53+
expect_no_warning(test_collection("indention_multiple",
5454
"fun_for_new_line",
5555
transformer = style_text_without_curly_curly
56-
), NA)
56+
))
5757
})
Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,152 @@
11
test_that("pipe is indended correctly", {
2-
expect_warning(test_collection("indention_operators",
2+
expect_no_warning(test_collection("indention_operators",
33
"pipe",
44
transformer = style_text
5-
), NA)
5+
))
66
})
77

88
test_that("base pipe is indended correctly", {
99
skip_if(getRversion() < "4.1")
10-
expect_warning(test_collection("indention_operators",
10+
expect_no_warning(test_collection("indention_operators",
1111
"base_pipe",
1212
transformer = style_text
13-
), NA)
13+
))
1414
})
1515

1616
test_that("mathematical operators are indended correctly", {
17-
expect_warning(test_collection("indention_operators",
17+
expect_no_warning(test_collection("indention_operators",
1818
"plus_minus",
1919
transformer = style_op
20-
), NA)
20+
))
2121

22-
expect_warning(test_collection("indention_operators",
22+
expect_no_warning(test_collection("indention_operators",
2323
"multiply_divide",
2424
transformer = style_op
25-
), NA)
25+
))
2626
})
2727

2828

2929
test_that("while / for / if without curly brackets", {
30-
expect_warning(test_collection("indention_operators",
30+
expect_no_warning(test_collection("indention_operators",
3131
"while_for_if_without_curly_non_strict",
3232
transformer = style_text, strict = FALSE
33-
), NA)
34-
expect_warning(test_collection("indention_operators",
33+
))
34+
expect_no_warning(test_collection("indention_operators",
3535
"while_for_without_curly_same_line_non_strict",
3636
transformer = style_text, strict = FALSE
37-
), NA)
37+
))
3838

39-
expect_warning(test_collection("indention_operators",
39+
expect_no_warning(test_collection("indention_operators",
4040
"if-else-no-braces-not-strict",
4141
transformer = style_text, strict = FALSE
42-
), NA)
42+
))
4343
})
4444

4545
test_that("function multiline without curly brackets", {
46-
expect_warning(test_collection("indention_operators",
46+
expect_no_warning(test_collection("indention_operators",
4747
"function-multiline-no-braces-strict",
4848
transformer = style_text, strict = TRUE
49-
), NA)
50-
expect_warning(test_collection("indention_operators",
49+
))
50+
expect_no_warning(test_collection("indention_operators",
5151
"function-multiline-no-braces-non-strict",
5252
transformer = style_text, strict = FALSE
53-
), NA)
53+
))
5454
})
5555

5656
test_that("while / for / if without curly brackets", {
57-
expect_warning(test_collection("indention_operators",
57+
expect_no_warning(test_collection("indention_operators",
5858
"while_for_if_without_curly_strict",
5959
transformer = style_text, strict = TRUE
60-
), NA)
60+
))
6161
})
6262

6363

6464
test_that("nested for and indention", {
65-
expect_warning(
65+
expect_no_warning(
6666
test_collection("indention_operators",
6767
"nested-for-spacing-scope-indention",
6868
transformer = style_text, scope = "indention"
69-
),
70-
NA
69+
)
7170
)
7271

73-
expect_warning(
72+
expect_no_warning(
7473
test_collection("indention_operators",
7574
"nested-for-spacing-scope-spaces",
7675
transformer = style_text, scope = "spaces"
77-
),
78-
NA
76+
)
7977
)
8078
})
8179

8280
test_that("logical, special EQ_SUB and EQ_ASSIGN tokens are indented correctly", {
83-
expect_warning(test_collection("indention_operators",
81+
expect_no_warning(test_collection("indention_operators",
8482
"logical_special",
8583
transformer = style_text, scope = "line_breaks"
86-
), NA)
84+
))
8785

88-
expect_warning(test_collection("indention_operators",
86+
expect_no_warning(test_collection("indention_operators",
8987
"eq_assign",
9088
transformer = style_text
91-
), NA)
92-
expect_warning(test_collection("indention_operators",
89+
))
90+
expect_no_warning(test_collection("indention_operators",
9391
"eq_formal_simple",
9492
transformer = style_text
95-
), NA)
93+
))
9694
})
9795

9896
test_that("dollar is indented and spaced correctly", {
99-
expect_warning(test_collection("indention_operators",
97+
expect_no_warning(test_collection("indention_operators",
10098
"dollar",
10199
transformer = style_text
102-
), NA)
100+
))
103101
})
104102

105103
test_that(
106104
"code is indented correctly if not first pontial trigger causes indention",
107105
{
108-
expect_warning(
106+
expect_no_warning(
109107
test_collection(
110108
"indention_operators", "not_first_trigger",
111109
transformer = style_text
112-
),
113-
NA
110+
)
114111
)
115112
}
116113
)
117114

118115
test_that("indents eq_sub correctly with various levels of scope", {
119-
expect_warning(test_collection("indention_operators",
116+
expect_no_warning(test_collection("indention_operators",
120117
"eq_sub_complex_indention",
121118
transformer = style_text, scope = "indention"
122-
), NA)
119+
))
123120

124-
expect_warning(test_collection("indention_operators",
121+
expect_no_warning(test_collection("indention_operators",
125122
"eq_sub_complex_tokens",
126123
transformer = style_text, scope = "tokens"
127-
), NA)
124+
))
128125
})
129126

130127
test_that("indents eq_formals correctly with various levels of scope", {
131-
expect_warning(test_collection("indention_operators",
128+
expect_no_warning(test_collection("indention_operators",
132129
"eq_formals_complex_indention",
133130
transformer = style_text, scope = "indention"
134-
), NA)
131+
))
135132

136-
expect_warning(test_collection("indention_operators",
133+
expect_no_warning(test_collection("indention_operators",
137134
"eq_formals_complex_tokens",
138135
transformer = style_text, scope = "tokens"
139-
), NA)
136+
))
140137
})
141138

142139
test_that("tilde causes indention and is flattened out", {
143-
expect_warning(test_collection("indention_operators",
140+
expect_no_warning(test_collection("indention_operators",
144141
"tilde",
145142
transformer = style_text
146-
), NA)
143+
))
147144
})
148145

149146

150147
test_that("overall", {
151-
expect_warning(test_collection("indention_operators",
148+
expect_no_warning(test_collection("indention_operators",
152149
"overall",
153150
transformer = style_text
154-
), NA)
151+
))
155152
})

0 commit comments

Comments
 (0)