Skip to content

Commit 4e12f65

Browse files
committed
test reporting
1 parent 1eaef62 commit 4e12f65

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

devel/realtest.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,27 @@ realtest_report <- function(r, context="", ...)
5959
)
6060
cat("\n")
6161

62+
63+
if (context != "base") {
64+
ugly <- c("bad", "worse", "worst")
65+
fails <- x[x[["match"]] %in% ugly, , drop=FALSE]
66+
if (nrow(fails) != 0) {
67+
cat(sprintf("*** realtest [%s]: the following expectations are ugly:\n", context))
68+
69+
fails2 <- as.data.frame(fails[,
70+
!(names(fails) %in% ".expr") & !sapply(fails, function(x) all(is.na(x))),
71+
drop=FALSE])
72+
for (i in row.names(fails2)) {
73+
print(fails2[i, , drop=FALSE])
74+
cat(" value: "); str(r[[i]][["object"]][["value"]], indent.str=" ")
75+
cat(" sides: "); str(r[[i]][["object"]][["sides"]], indent.str=" ")
76+
cat("\n")
77+
}
78+
cat("\n")
79+
}
80+
}
81+
82+
6283
fails <- x[x[["match"]] == "fail", , drop=FALSE]
6384
if (nrow(fails) == 0) return(invisible(x))
6485

inst/realtest/strptime-stringx.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,33 +79,33 @@ get_test_times <- function() {
7979

8080
stringi::stri_timezone_set("Etc/GMT-14")
8181
times <- get_test_times()
82-
for (time in times)
83-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
82+
for (i in seq_along(times))
83+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
8484

8585
stringi::stri_timezone_set("Etc/GMT+12")
8686
times <- get_test_times()
87-
for (time in times)
88-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
87+
for (i in seq_along(times))
88+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
8989

9090
stringi::stri_timezone_set("UTC")
9191
times <- get_test_times()
92-
for (time in times)
93-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
92+
for (i in seq_along(times))
93+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
9494

9595
stringi::stri_timezone_set("Australia/Melbourne")
9696
times <- get_test_times()
97-
for (time in times)
98-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
97+
for (i in seq_along(times))
98+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
9999

100100
stringi::stri_timezone_set("Europe/Warsaw")
101101
times <- get_test_times()
102-
for (time in times)
103-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
102+
for (i in seq_along(times))
103+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
104104

105105
stringi::stri_timezone_set("America/Montreal")
106106
times <- get_test_times()
107-
for (time in times)
108-
E(strftime(time, "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31")
107+
for (i in seq_along(times))
108+
E(strftime(times[[i]], "%Y-%m-%d"), "1970-01-01", bad="1970-01-02", bad="1969-12-31", .comment=i)
109109

110110

111111
stringi::stri_timezone_set(oldtz)

0 commit comments

Comments
 (0)