@@ -128,6 +128,8 @@ test_that("set_units default enforces NSE", {
128128
129129expect_symbolic <- function (u , n , d )
130130 expect_equal(units(as_units(u )), units ::: .symbolic_units(n , d ))
131+ expect_symbolic_nocheck <- function (u , n , d )
132+ expect_equal(units(as_units(u , check_is_valid = FALSE )), units ::: .symbolic_units(n , d ))
131133
132134test_that(" exotic units work" , {
133135 # check what udunits support
@@ -138,6 +140,7 @@ test_that("exotic units work", {
138140 # expect_symbolic("2.2.m.s", c("2.2", "m", "s"), character(0))
139141
140142 expect_symbolic(" m2/s" , c(" m" , " m" ), " s" )
143+ expect_symbolic(" m20/s" , rep(" m" , 20 ), " s" )
141144 expect_symbolic(" m^2/s" , c(" m" , " m" ), " s" )
142145 expect_symbolic(" m 2/s" , c(" m" , " 2" ), " s" )
143146 expect_symbolic(" m-2/s" , character (0 ), c(" m" , " m" , " s" ))
@@ -154,7 +157,14 @@ test_that("exotic units work", {
154157 expect_symbolic(" ml/min/1.73m-2" , c(" ml" , " m" , " m" ), c(" min" , " 1.73" ))
155158
156159 old <- unlist(units_options(strict_tokenizer = TRUE ))
157- on.exit(units_options(strict_tokenizer = old ))
158160 expect_symbolic(" ml/min/1.73m^2" , c(" ml" , " m" , " m" ), c(" min" , " 1.73" ))
159161 expect_symbolic(" ml/min/1.73m-2" , " ml" , c(" min" , " 1.73" , " m" , " m" ))
162+ units_options(strict_tokenizer = old )
163+
164+ expect_symbolic_nocheck(" inH2O" , " inH2O" , character (0 ))
165+ expect_symbolic_nocheck(" inH2O2" , c(" inH2O" , " inH2O" ), character (0 ))
166+
167+ expect_symbolic(" m/(g/(s/L))" , c(" m" , " s" ), c(" g" , " L" ))
168+ expect_error(expect_warning(as_units(" m/(g/s" )))
169+ expect_error(expect_warning(as_units(" m^m" )))
160170})
0 commit comments