Skip to content

Commit c207765

Browse files
test: format in files with air and write them to out files so you can see how formatting differs between air and styler
1 parent 8b43fe2 commit c207765

File tree

202 files changed

+1693
-1831
lines changed

Some content is hidden

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

202 files changed

+1693
-1831
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# List all input files recursively that end with "-in.R"
2+
input_files <- list.files(
3+
path = "tests/testthat",
4+
pattern = "-in\\.R$",
5+
recursive = TRUE,
6+
full.names = TRUE
7+
)
8+
9+
# Function to generate output filename by replacing -in.R with -out.R
10+
get_output_filename <- function(input_file) {
11+
gsub("-in\\.R$", "-out.R", input_file)
12+
}
13+
14+
# Process each file
15+
for (input_file in input_files) {
16+
output_file <- get_output_filename(input_file)
17+
18+
# Create directory for output file if it doesn't exist
19+
output_dir <- dirname(output_file)
20+
if (!dir.exists(output_dir)) {
21+
dir.create(output_dir, recursive = TRUE)
22+
}
23+
24+
# Read input file and write to output file
25+
file.copy(input_file, output_file, overwrite = TRUE)
26+
27+
# Print status
28+
cat(sprintf("Processed: %s -> %s\n", input_file, output_file))
29+
}
30+
31+
cat(sprintf("\nProcessed %d files\n", length(input_files)))

tests/testthat/alignment/cols-with-one-row-out.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ c(
55

66

77
c(
8-
"x", "z",
9-
"cgjhg", "thi", "z"
8+
"x", "z",
9+
"cgjhg", "thi", "z"
1010
)
1111

1212

1313
c(
14-
"x", "y", "z", "m", "n", "o", "p",
14+
"x", "y", "z", "m", "n", "o", "p",
1515
"c", "d"
1616
)

tests/testthat/alignment/fun-decs-out.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function(x = 2,
2222

2323

2424
# not aligned
25-
k <- function(x = fish,
26-
aq = 21,
25+
k <- function(x = fish,
26+
aq = 21,
2727
ayz = t(322)) {}
2828

2929
# aligned

tests/testthat/alignment/named-out.R

+19-16
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ call(
2424

2525
# algorithm: not aligned (spacing around =). human: aligned (fix: spacing around =).
2626
call(
27-
x = 1, kdd = 2,
28-
xy = 2, n = 33,
27+
x =1, kdd = 2,
28+
xy =2, n = 33,
2929
)
3030

3131
# algorithm: not aligned. human: not aligned.
3232
call(
33-
x = 1, kdd = 2,
33+
x = 1, kdd = 2,
3434
xy = 2, n = 33,
3535
)
3636

3737
# algorithm: not aligned. human: not aligned.
3838
call(
39-
x = 1, kdd = 2,
39+
x = 1, kdd = 2,
4040
xy = 22, n = 33,
4141
)
4242

4343
# algorithm: not aligned. human: not aligned.
4444
call(
45-
x = 1, d = 2,
45+
x = 1, d = 2,
4646
xy = 22, n = 33,
4747
)
4848

@@ -63,6 +63,7 @@ call(
6363
# algorithm: aligned. human: aligned.
6464
call(
6565
x = 1, n = 33, z = "333",
66+
6667
xy = 2,
6768
)
6869

@@ -102,11 +103,12 @@ call(
102103
)
103104

104105

106+
105107
# if all col1 arguments are named, col1 must also be aligned
106108
# not aligned
107109
fell(
108-
x = 1,
109-
y = 23,
110+
x = 1,
111+
y = 23,
110112
zz = NULL
111113
)
112114

@@ -120,8 +122,8 @@ fell(
120122
# aligned but comma in the wrong line
121123
call(
122124
a = 2,
123-
bb = 3,
124-
)
125+
bb = 3
126+
,)
125127

126128

127129
# aligned (comments)
@@ -153,15 +155,15 @@ call(
153155

154156
# not aligned (comments)
155157
call(
156-
a = 2, x = 111,
157-
bb = 3, # hi
158+
a = 2, x = 111,
159+
bb = 3, # hi
158160
)
159161

160162
# not aligned (comments)
161163
call(
162164
# another one
163-
a = 2, x = 111,
164-
bb = 3,
165+
a = 2, x = 111,
166+
bb = 3,
165167
# hi
166168
)
167169

@@ -171,7 +173,8 @@ call(
171173
# the extra spaces before `=` as of 29a010064257fa1a9caf32d182e7ee62008de98a.
172174
call(
173175
x = 95232,
174-
y = f(),
176+
y = f(
177+
),
175178
)
176179

177180

@@ -184,9 +187,9 @@ ca(
184187

185188
# not aligned (left after `=`)
186189
ca(
187-
x = 23200,
190+
x = 23200,
188191
y2 = "hi",
189-
m = c(rm.na = 7)
192+
m = c(rm.na = 7)
190193
)
191194

192195
# aligned =, first all named
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
foo(
22
img,
33
pkg = "abc",
4-
color = "lmn",
5-
font = "xyz"
4+
color = "lmn",
5+
font = "xyz"
66
)
77

88

99
foo(
1010
img, #
1111
pkg = "abc",
12-
color = "lmn",
13-
font = "xyz"
12+
color = "lmn",
13+
font = "xyz"
1414
)
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
df <- dplyr::rename(df,
2-
"xValues" = "Time",
2+
"xValues" = "Time",
33
"xUnit" = "TimeUnit",
4-
"yValues" = "simulationValues",
4+
"yValues" = "simulationValues",
55
"yUnit" = "unit",
6-
"yDimension" = "dimension"
6+
"yDimension" = "dimension"
77
)

tests/testthat/alignment/tribble-out.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ tribble(
55
)
66

77
tribble(
8-
~x, ~d,
8+
~x, ~d,
99
"axa'fa", 1:6,
10-
"b", 4:6
10+
"b", 4:6
1111
)
1212

1313

1414
tribble(
15-
~x, ~d,
15+
~x, ~d,
1616
"axa'fa", 1:6,
17-
"b", 4:6
17+
"b", 4:6
1818
)
1919

2020
tribble(
21-
~x, ~d,
22-
"axa'fa", 1:6,
23-
"b", 4:6
21+
~x, ~d,
22+
"axa'fa", 1:6,
23+
"b", 4:6
2424
)
2525

2626
# has EQ_SUB which don't match, not tribble-like

tests/testthat/curly-curly/mixed-out.R

+47-46
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1+
12
## ............................................................................
23
## line breaks ####
34
# not inserting line breaks
45
call({{ x }})
56

67
# removing line breaks
7-
call({{ x }})
8+
call({{
9+
x
10+
}})
811

9-
call({{ x }})
12+
call({
13+
{x
14+
}})
1015

11-
call({{ x }})
16+
call({
17+
{x}}
18+
)
1219

13-
call({{ x }})
20+
call({
21+
{x}
22+
})
1423

1524
call(
16-
{{ x }}
17-
)
25+
{
26+
{x
27+
}
28+
}
29+
)
1830

1931
## ............................................................................
2032
## spaces ####
@@ -23,37 +35,33 @@ call(
2335
call({{ x }})
2436

2537
# removing spaces between braces
26-
call({{ x }})
27-
call({{ x }})
28-
call({{ x }})
29-
call({{ x }})
38+
call({ { x }})
39+
call({ { x }} )
40+
call( { { x }})
41+
call( { { x } })
3042

3143
# inserting spaces within {{
32-
call({{ x }})
33-
call({{ x }})
34-
call({{ x }})
44+
call({{x }})
45+
call({{x}})
46+
call({{ x}})
3547

3648
# not removing spaces within {{
3749
call({{ x }})
3850

3951

4052
# combine spaces and line breaks
41-
call({{ x }})
53+
call({{ x}
54+
})
4255

43-
call({{ x }})
56+
call({
57+
{ x}})
4458

4559
# not applicable when only one curly brace
4660
{
4761
y
4862
}
49-
{
50-
1 + 1
51-
}
52-
{
53-
{
54-
1 + a
55-
} + 1
56-
} # not curly-culry!
63+
{ 1 + 1}
64+
{{1 + a} + 1} # not curly-culry!
5765

5866

5967
## ............................................................................
@@ -63,39 +71,32 @@ call("test", {
6371
})
6472

6573
call(
66-
"test",
67-
{
68-
1
69-
}
70-
)
71-
72-
call("test", {
73-
1
74-
})
75-
76-
call("test", {
74+
"test", {
7775
1
7876
})
7977

80-
call(
81-
{
78+
call("test",
79+
{
8280
1
83-
},
84-
a + b,
85-
{
86-
33 / f(c)
87-
}
81+
})
82+
83+
call("test", {
84+
1 }
8885
)
8986

90-
call({{ x }}, {{ y }})
91-
call({{ x }}, {{ y }})
87+
call({
88+
1
89+
}, a + b, { 33 / f(c)})
90+
91+
call({{ x }}, {{ y}})
92+
call({{ x }}, {{ y}
93+
})
9294
call(
93-
{{ x }}, {{ y }}
94-
)
95+
{{ x }}, {{ y}})
9596

9697
call(
9798
{{ x }},
98-
{{ y }} := 3, f(bk)
99+
{{ y}} := 3, f(bk)
99100
)
100101

101102
call({{

tests/testthat/escaping/basic-escape-out.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ NULL
2222
#' things
2323
#'
2424
#' @examples
25-
#' call("\n")
25+
#' call('\n')
2626
#' ano("\\.", further = X)
2727
NULL
2828

29-
"single quotes with
30-
embedded and \n not embedded line breaks"
29+
'single quotes with
30+
embedded and \n not embedded line breaks'
3131

32-
x <- " 2" # there is a tab emebbed (created with writeLines("x <- '\t2'"))
32+
x <- ' 2' # there is a tab emebbed (created with writeLines("x <- '\t2'"))
3333

34-
x <- "\001"
35-
"\x01"
34+
x <- '\001'
35+
'\x01'
3636

3737
"\001"
38-
"\001"
38+
'\001'
3939

4040
#' things
4141
#'

0 commit comments

Comments
 (0)