1context("Informative messages")
2
3test_that(".inform parameter works for all l?ply functions", {
4  funcnames <- ls(name = asNamespace("plyr"), pattern = "^l[^i]ply$")
5
6  old_options <- options(show.error.messages = FALSE)
7  on.exit(options(old_options), add = TRUE)
8
9  input <- 1:10
10  for (funcname in funcnames) {
11    func <- get(funcname, asNamespace("plyr"))
12    expect_error(func(input, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
13  }
14})
15
16test_that(".inform parameter works for all d?ply functions", {
17  funcnames <- ls(name = asNamespace("plyr"), pattern = "^d[^i]ply$")
18
19  old_options <- options(show.error.messages = FALSE)
20  on.exit(options(old_options), add = TRUE)
21
22  input <- data.frame(a = 1:10)
23  for (funcname in funcnames) {
24    func <- get(funcname, asNamespace("plyr"))
25    expect_error(func(input, .(), function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
26  }
27})
28
29test_that(".inform parameter works for all a?ply functions", {
30  funcnames <- ls(name = asNamespace("plyr"), pattern = "^a[^i]ply$")
31
32  old_options <- options(show.error.messages = FALSE)
33  on.exit(options(old_options), add = TRUE)
34
35  input <- data.frame(a = 1:10)
36  for (funcname in funcnames) {
37    func <- get(funcname, asNamespace("plyr"))
38    expect_error(func(input, 1, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
39  }
40})
41
42test_that(".inform parameter works for all m?ply functions", {
43  funcnames <- ls(name = asNamespace("plyr"), pattern = "^m[^i]ply$")
44
45  old_options <- options(show.error.messages = FALSE)
46  on.exit(options(old_options), add = TRUE)
47
48  input <- data.frame(a = 1:10)
49  for (funcname in funcnames) {
50    func <- get(funcname, asNamespace("plyr"))
51    expect_error(func(input, function(...) stop("qq"), .inform = TRUE), "piece 1", info = funcname)
52  }
53})
54