Skip to content

Commit 0f12ee9

Browse files
Codecov is 100%
1 parent 2a78f2c commit 0f12ee9

11 files changed

+93
-14
lines changed

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Newest versions at top.
1313

1414
## MINOR IMPROVEMENTS
1515

16-
- None
16+
- Code coverage is 100.00%
1717

1818
## BUG FIXES
1919

20-
- None
20+
- `s_parameter_to_xml` can handle an upper value of infinity
2121

2222
## DEPRECATED AND DEFUNCT
2323

R/check_empty_beautier_folder.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ check_empty_beautier_folder <- function(
5151
paste(utils::head(filenames), collapse = ",")
5252
)
5353
}
54-
if (dir.exists(beautier_folder)) {
55-
stop("'beautier' folder found at ", beautier_folder)
56-
}
57-
invisible(beautier_folder)
54+
# Last possible cause for an error
55+
testthat::expect_true(dir.exists(beautier_folder))
56+
stop("'beautier' folder found at ", beautier_folder)
5857
}

R/get_n_taxa.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ get_n_taxa <- function(filename) {
2727
)
2828
}
2929
)
30-
invisible(filename)
30+
# Will never get here
3131
}

R/s_parameter_to_xml.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ s_parameter_to_xml <- function(
5252
if (!beautier::is_one_na(upper)) {
5353
if (!is.infinite(upper)) {
5454
upper_txt <- upper
55-
if (is.infinite(upper)) {
56-
upper_txt <- "Infinity"
57-
}
58-
text <- paste0(text, " upper=\"", upper_txt, "\"")
5955
}
56+
else {
57+
testthat::expect_true(is.infinite(upper))
58+
upper_txt <- "Infinity"
59+
}
60+
text <- paste0(text, " upper=\"", upper_txt, "\"")
6061
}
6162
text <- paste0(text, ">", value, "</parameter>")
6263
text

tests/testthat/test-check_clock_model.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@ test_that("abuse, general clock model", {
3030
"'id' must be an element of 'clock_model'"
3131
)
3232

33-
# Break clock name
33+
# Invalid clock name
3434
clock_model <- create_strict_clock_model()
3535
clock_model$name <- "nonsense"
3636
expect_error(
3737
check_clock_model(clock_model),
3838
"'clock_model\\$name' must be one of the clock model names"
3939
)
40+
41+
# Invalid rate_scaler_factor
42+
clock_model <- create_strict_clock_model()
43+
clock_model$rate_scaler_factor <- "nonsense"
44+
expect_error(
45+
check_clock_model(clock_model),
46+
"'rate_scaler_factor' must be a number or a string that can be converted to a number or an empty string"
47+
)
48+
4049
})
4150

4251
test_that("abuse, rln clock model", {

tests/testthat/test-check_clock_models.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
context("test-check_clock_models")
2-
31
test_that("use", {
42
expect_silent(
53
check_clock_models(

tests/testthat/test-create_site_model.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ test_that("abuse", {
3535

3636
})
3737

38+
test_that("create_gtr_site_model: devious", {
39+
40+
expect_error(
41+
create_gtr_site_model(
42+
freq_param = "nonsense"
43+
)
44+
)
45+
46+
})
47+
3848
test_that("create_gtr_site_model: new interface", {
3949

4050
# Old interface

tests/testthat/test-is_param.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ test_that("is_alpha_param", {
5656

5757
})
5858

59+
60+
test_that("is_b_pop_sizes_param", {
61+
62+
expect_true(is_b_pop_sizes_param(create_b_pop_sizes_param()))
63+
expect_false(is_b_pop_sizes_param("nonsense"))
64+
65+
})
66+
67+
5968
test_that("is_beta_param", {
6069

6170
expect_true(is_beta_param(create_beta_param()))
@@ -74,6 +83,7 @@ test_that("is_freq_param", {
7483

7584
expect_true(is_freq_param(create_freq_param()))
7685
expect_false(is_freq_param("nonsense"))
86+
expect_false(is_freq_param(create_b_pop_sizes_param()))
7787
})
7888

7989
test_that("is_freq_param, devious", {
@@ -85,6 +95,14 @@ test_that("is_freq_param, devious", {
8595
h <- g[names(g) != "lower"]
8696
expect_false(is_freq_param(h))
8797

98+
# No 'upper'
99+
h <- g[names(g) != "upper"]
100+
expect_false(is_freq_param(h))
101+
102+
# No 'value'
103+
h <- g[names(g) != "value"]
104+
expect_false(is_freq_param(h))
105+
88106
# No 'estimate'
89107
h <- g[names(g) != "estimate"]
90108
expect_false(is_freq_param(h))
@@ -94,6 +112,25 @@ test_that("is_freq_param, devious", {
94112
expect_false(is_freq_param(h))
95113
})
96114

115+
test_that("is_kappa_param", {
116+
117+
expect_true(is_kappa_param(create_kappa_param()))
118+
expect_false(is_kappa_param("nonsense"))
119+
})
120+
121+
test_that("is_kappa_param, devious", {
122+
123+
g <- create_kappa_param()
124+
expect_true(is_kappa_param(g))
125+
126+
# No 'lower'
127+
h <- g[names(g) != "lower"]
128+
expect_false(is_kappa_param(h))
129+
130+
# No 'estimate'
131+
h <- g[names(g) != "estimate"]
132+
expect_false(is_kappa_param(h))
133+
})
97134

98135
test_that("is_kappa_1_param", {
99136

tests/testthat/test-is_site_model.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ test_that("is_hky_site_model: devious", {
206206
h <- g
207207
h$freq_equilibrium <- "nonsense"
208208
expect_false(is_hky_site_model(h))
209+
210+
# Invalid 'kappa_param'
211+
h <- g
212+
h$kappa_param <- "nonsense"
213+
expect_false(is_hky_site_model(h))
214+
209215
})
210216

211217
test_that("is_tn93_site_model: devious", {

tests/testthat/test-is_tree_prior.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ test_that("is_cbs_tree_prior, devious", {
8181
# No 'group_sizes_dimension'
8282
h <- g[names(g) != "group_sizes_dimension"]
8383
expect_false(is_cbs_tree_prior(h))
84+
85+
# No 'b_pop_sizes_param'
86+
h <- g[names(g) != "b_pop_sizes_param"]
87+
expect_false(is_cbs_tree_prior(h))
88+
89+
# No 'pop_sizes_scaler_scale_factor'
90+
h <- g[names(g) != "pop_sizes_scaler_scale_factor"]
91+
expect_false(is_cbs_tree_prior(h))
92+
8493
})
8594

8695
test_that("is_ccp_tree_prior, devious", {

0 commit comments

Comments
 (0)