Skip to content

Commit bc143c3

Browse files
committed
Revert formatting changes
1 parent f9bfb44 commit bc143c3

File tree

1 file changed

+16
-49
lines changed

1 file changed

+16
-49
lines changed

tests/testthat/test-layer.R

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,8 @@ test_that("layer() checks its input", {
55
expect_snapshot_error(layer(geom = "point", position = "identity"))
66
expect_snapshot_error(layer(geom = "point", stat = "identity"))
77

8-
expect_snapshot_error(layer(
9-
"point",
10-
"identity",
11-
mapping = 1:4,
12-
position = "identity"
13-
))
14-
expect_snapshot_error(layer(
15-
"point",
16-
"identity",
17-
mapping = ggplot(),
18-
position = "identity"
19-
))
8+
expect_snapshot_error(layer("point", "identity", mapping = 1:4, position = "identity"))
9+
expect_snapshot_error(layer("point", "identity", mapping = ggplot(), position = "identity"))
2010

2111
expect_snapshot_error(validate_subclass("test", "geom"))
2212
expect_snapshot_error(validate_subclass(environment(), "geom"))
@@ -39,8 +29,7 @@ test_that("unknown aesthetics create warning", {
3929
})
4030

4131
test_that("empty aesthetics create warning", {
42-
p <- ggplot(mtcars) +
43-
geom_point(aes(disp, mpg), fill = NULL, shape = character())
32+
p <- ggplot(mtcars) + geom_point(aes(disp, mpg), fill = NULL, shape = character())
4433
expect_snapshot_warning(ggplot_build(p))
4534
})
4635

@@ -91,13 +80,7 @@ test_that("function aesthetics are wrapped with after_stat()", {
9180
test_that("computed stats are in appropriate layer", {
9281
df <- data_frame(x = 1:10)
9382
expect_snapshot_error(
94-
ggplot_build(
95-
ggplot(
96-
df,
97-
aes(colour = after_stat(density), fill = after_stat(density))
98-
) +
99-
geom_point()
100-
)
83+
ggplot_build(ggplot(df, aes(colour = after_stat(density), fill = after_stat(density))) + geom_point())
10184
)
10285
})
10386

@@ -113,15 +96,9 @@ test_that("layers are stateless except for the computed params", {
11396
p <- ggplot(df) +
11497
geom_col(aes(x = x, y = y), width = 0.8, fill = "red")
11598
col_layer <- as.list(p@layers[[1]])
116-
stateless_names <- setdiff(
117-
names(col_layer),
118-
c("computed_geom_params", "computed_stat_params", "computed_mapping")
119-
)
99+
stateless_names <- setdiff(names(col_layer), c("computed_geom_params", "computed_stat_params", "computed_mapping"))
120100
invisible(ggplotGrob(p))
121-
expect_identical(
122-
as.list(p@layers[[1]])[stateless_names],
123-
col_layer[stateless_names]
124-
)
101+
expect_identical(as.list(p@layers[[1]])[stateless_names], col_layer[stateless_names])
125102
})
126103

127104
test_that("inherit.aes works", {
@@ -132,14 +109,11 @@ test_that("inherit.aes works", {
132109
geom_col(aes(x = x, y = y), inherit.aes = FALSE)
133110
invisible(ggplotGrob(p1))
134111
invisible(ggplotGrob(p2))
135-
expect_identical(
136-
p1@layers[[1]]$computed_mapping,
137-
p2@layers[[1]]$computed_mapping
138-
)
112+
expect_identical(p1@layers[[1]]$computed_mapping, p2@layers[[1]]$computed_mapping)
139113
})
140114

141115
test_that("retransform works on computed aesthetics in `map_statistic`", {
142-
df <- data.frame(x = rep(c(1, 2), c(9, 25)))
116+
df <- data.frame(x = rep(c(1,2), c(9, 25)))
143117
p <- ggplot(df, aes(x)) + geom_bar() + scale_y_sqrt()
144118
expect_equal(get_layer_data(p)$y, c(3, 5))
145119

@@ -173,6 +147,7 @@ test_that("layer warns for constant aesthetics", {
173147
})
174148

175149
test_that("layer names can be resolved", {
150+
176151
p <- ggplot() + geom_point() + geom_point()
177152
expect_named(p@layers, c("geom_point", "geom_point...2"))
178153

@@ -184,6 +159,7 @@ test_that("layer names can be resolved", {
184159
})
185160

186161
test_that("validate_subclass can resolve classes via constructors", {
162+
187163
env <- new_environment(list(
188164
geom_foobar = geom_point,
189165
stat_foobar = stat_boxplot,
@@ -193,14 +169,9 @@ test_that("validate_subclass can resolve classes via constructors", {
193169

194170
expect_s3_class(validate_subclass("foobar", "Geom", env = env), "GeomPoint")
195171
expect_s3_class(validate_subclass("foobar", "Stat", env = env), "StatBoxplot")
196-
expect_s3_class(
197-
validate_subclass("foobar", "Position", env = env),
198-
"PositionNudge"
199-
)
200-
expect_s3_class(
201-
validate_subclass("foobar", "Guide", env = env),
202-
"GuideAxisTheta"
203-
)
172+
expect_s3_class(validate_subclass("foobar", "Position", env = env), "PositionNudge")
173+
expect_s3_class(validate_subclass("foobar", "Guide", env = env), "GuideAxisTheta")
174+
204175
})
205176

206177
test_that("attributes on layer data are preserved", {
@@ -211,9 +182,7 @@ test_that("attributes on layer data are preserved", {
211182
# * It has an `after_stat()` so it enters the map_statistic method
212183
old <- stat_summary(
213184
aes(fill = after_stat(y)),
214-
fun = mean,
215-
geom = "col",
216-
position = "dodge"
185+
fun = mean, geom = "col", position = "dodge"
217186
)
218187
# We modify the compute aesthetics method to append a test attribute
219188
new <- ggproto(NULL, old, compute_aesthetics = function(self, data, plot) {
@@ -223,9 +192,7 @@ test_that("attributes on layer data are preserved", {
223192
})
224193
# At the end of plot building, we want to retrieve that metric
225194
ld <- layer_data(
226-
ggplot(mpg, aes(drv, hwy, colour = factor(year))) +
227-
new +
228-
facet_grid(~year) +
195+
ggplot(mpg, aes(drv, hwy, colour = factor(year))) + new + facet_grid(~year) +
229196
scale_y_sqrt()
230197
)
231198
expect_equal(attr(ld, "test"), "preserve me")
@@ -303,5 +270,5 @@ test_that("data.frames and matrix aesthetics survive the build stage", {
303270
scale_shape_identity()
304271
)
305272
expect_vector(p$colour, matrix(NA_integer_, nrow = 0, ncol = 2), size = 2)
306-
expect_vector(p$shape, data_frame0(a = integer(), b = character()), size = 2)
273+
expect_vector(p$shape, data_frame0(a = integer(), b = character()), size = 2)
307274
})

0 commit comments

Comments
 (0)