Nothing
# Parsing and printing of the messages X-13 writes to its .err file
html_err <- c(
"<p><strong>ERROR:</strong>",
"Something went wrong.",
"</p>",
"<p><strong>WARNING:</strong>",
"Something is odd.",
"</p>",
"<p><strong>note:</strong>",
"Just so you know.",
"</p>"
)
plain_err <- c(
" ERROR: Something went wrong.",
"",
" WARNING: Something is odd.",
"",
" note: Just so you know.",
""
)
test_that("detect_error() splits html output into errors, warnings and notes", {
z <- seasonal:::detect_error(html_err, htmlmode = 1)
expect_s3_class(z, "x13messages")
expect_match(z$error, "Something went wrong")
expect_match(z$warning, "Something is odd")
expect_match(z$note, "Just so you know")
})
test_that("detect_error() splits plain output into errors, warnings and notes", {
z <- seasonal:::detect_error(plain_err, htmlmode = 0)
expect_match(z$error, "Something went wrong")
expect_match(z$warning, "Something is odd")
expect_match(z$note, "Just so you know")
})
test_that("detect_error() drops the monthly spectrum warning", {
err <- c(
"<p><strong>WARNING:</strong>",
"Spectrums are only generated for monthly series.",
"</p>"
)
z <- seasonal:::detect_error(err, htmlmode = 1)
expect_length(z$warning, 0)
})
test_that("a failed spectral plot is a warning, not an error (#337)", {
err <- c(
"<p><strong>ERROR:</strong>",
"Spectral plot for the logged original series cannot be done.",
"</p>"
)
z <- seasonal:::detect_error(err, htmlmode = 1)
expect_length(z$error, 0)
expect_match(z$warning, "Spectral plot")
})
test_that("x13messages print as a report", {
z <- seasonal:::detect_error(html_err, htmlmode = 1)
out <- capture.output(print(z))
expect_match(out, "Messages generated by X-13", all = FALSE)
expect_match(out, "Errors:", all = FALSE)
expect_match(out, "Warnings:", all = FALSE)
expect_match(out, "Notes:", all = FALSE)
})
test_that("empty x13messages print nothing", {
z <- seasonal:::detect_error(character(0), htmlmode = 1)
expect_null(seasonal:::print_x13messages(z))
})
test_that("drop_x13messages() stays quiet when there is nothing of that type", {
z <- seasonal:::detect_error(character(0), htmlmode = 1)
expect_equal(seasonal:::drop_x13messages(z), "")
})
test_that("drop_x13messages() raises what it finds", {
z <- seasonal:::detect_error(html_err, htmlmode = 1)
expect_error(seasonal:::drop_x13messages(z), "X-13 run failed")
expect_error(seasonal:::drop_x13messages(z), "Something went wrong")
expect_warning(
seasonal:::drop_x13messages(z, msg = "careful\n\n", msgfun = warning),
"careful"
)
})
test_that("a series X-13 cannot handle produces a readable error", {
skip_if_no_x13()
# X-13 terminates on a constant series
expect_error(seas(ts(0, start = 2000, end = 2010, frequency = 4)))
# and on absurd magnitudes
expect_error(
seas(ts(9999999999999999, start = 2000, end = 2010, frequency = 4))
)
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.