diff --git a/R/import.spc.R b/R/import.spc.R index 9537455..f9cc87e 100644 --- a/R/import.spc.R +++ b/R/import.spc.R @@ -178,6 +178,10 @@ print.import.spc <- function(x, ...){ ext_ser_call <- function(spc, vname){ if (is.null(spc)) return(NULL) + + # the default data format for X-13 is "free" + fformat <- ifelse(is.null(spc$format), "free", spc$format) + frm <- rem_quotes(fformat) # analyze series spec if ("data" %in% names(spc)){ @@ -190,9 +194,7 @@ ext_ser_call <- function(spc, vname){ ", start = ", deparse(start), ", frequency = ", f, ")") } else if ("file" %in% names(spc)){ - - frm <- rem_quotes(spc$format) - + # fragment for name, for fortran and x11 series if (!is.null(spc$name)) { nm <- rem_quotes(spc$name) diff --git a/tests/testthat/_snaps/ext_ser_call.md b/tests/testthat/_snaps/ext_ser_call.md new file mode 100644 index 0000000..4ead03e --- /dev/null +++ b/tests/testthat/_snaps/ext_ser_call.md @@ -0,0 +1,14 @@ +# ext_ser_call() + + Code + ext_ser_call(pp, "x") + Output + [1] "x <- import.ts(file.dat)" + +# ext_ser_call() defaults to format "free" + + Code + ext_ser_call(pp, "x") + Output + [1] "x <- import.ts(file.dat, format = \"free\", start = c(2014, 1), frequency = 12, name = \"xyz\")" + diff --git a/tests/testthat/test-ext_ser_call.R b/tests/testthat/test-ext_ser_call.R new file mode 100644 index 0000000..9829d65 --- /dev/null +++ b/tests/testthat/test-ext_ser_call.R @@ -0,0 +1,32 @@ +test_that("ext_ser_call()", { + + pp <- list( + title = "abc", + start = 2014.01, + period = 12, + save = c("a1", "b1"), + print = "brief", + format = "datevalue", + name = "xyz", + file = "file.dat" + ) + + expect_snapshot(ext_ser_call(pp, "x")) + +}) + +test_that("ext_ser_call() defaults to format \"free\"", { + + pp <- list( + title = "abc", + start = 2014.01, + period = 12, + save = c("a1", "b1"), + print = "brief", + name = "xyz", + file = "file.dat" + ) + + expect_snapshot(ext_ser_call(pp, "x")) + +})