From bb7356a468ed155a244f7fcf39aa3a72de399ed7 Mon Sep 17 00:00:00 2001 From: Andrea Ranzato Date: Sun, 9 Jun 2024 18:13:06 +0200 Subject: [PATCH 1/4] tolower arg names --- R/parse_spc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/parse_spc.R b/R/parse_spc.R index d16dfa5..be942bb 100644 --- a/R/parse_spc.R +++ b/R/parse_spc.R @@ -140,7 +140,7 @@ parse_singlespc <- function(txt){ nam <- sapply(snamarg, function(e) e[[1]]) # nam <- spltxt[-length(spltxt)] - nam <- gsub("( +$)|(^ +)", "", nam) + nam <- tolower(gsub("( +$)|(^ +)", "", nam)) # nam <- gsub(".* ([A-Za-z0-9]+$)", "\\1", nam) From 6bf9b61e559d60a3a2d7b8551f173c864fe2e3bb Mon Sep 17 00:00:00 2001 From: Andrea Ranzato Date: Sun, 9 Jun 2024 18:18:31 +0200 Subject: [PATCH 2/4] tolower spec names --- R/parse_spc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/parse_spc.R b/R/parse_spc.R index be942bb..2d76817 100644 --- a/R/parse_spc.R +++ b/R/parse_spc.R @@ -42,7 +42,7 @@ parse_spc <- function(txt){ stopifnot(length(z0) == length(nam)) - names(z0) <- nam + names(z0) <- tolower(nam) # # separate individual specs # z0 <- list() From db231d7889757d953cb5fdfebada3c9e69ef6da1 Mon Sep 17 00:00:00 2001 From: Andrea Ranzato Date: Sun, 9 Jun 2024 18:31:50 +0200 Subject: [PATCH 3/4] add parse_spc test --- tests/testthat/_snaps/parse_spc.md | 15 +++++++++++++++ tests/testthat/test-parse_spc.R | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/testthat/_snaps/parse_spc.md create mode 100644 tests/testthat/test-parse_spc.R diff --git a/tests/testthat/_snaps/parse_spc.md b/tests/testthat/_snaps/parse_spc.md new file mode 100644 index 0000000..905c39e --- /dev/null +++ b/tests/testthat/_snaps/parse_spc.md @@ -0,0 +1,15 @@ +# parse_spc accounts for uppercase arguments and spec + + Code + parse_spc(text) + Output + series{ + title = "xyz" + start = 2014.01 + period = 12 + save = (A1 B1) + print = BRIEF + name = "abc" + file = "path/to/file.dat" + } + diff --git a/tests/testthat/test-parse_spc.R b/tests/testthat/test-parse_spc.R new file mode 100644 index 0000000..7de7f7b --- /dev/null +++ b/tests/testthat/test-parse_spc.R @@ -0,0 +1,16 @@ +test_that("parse_spc accounts for uppercase arguments and spec", { + + text <- ' + SERIES{ + TITLE = "xyz" + START = 2014.01 + PERIOD = 12 + SAVE = (A1 B1) + PRINT = BRIEF + NAME = "abc" + FILE = "path/to/file.dat" + }' + + expect_snapshot(parse_spc(text)) + +}) From 9e7fa685a816f8e0e9fbad64405667dc4f9fdea5 Mon Sep 17 00:00:00 2001 From: Andrea Ranzato Date: Sun, 9 Jun 2024 18:38:00 +0200 Subject: [PATCH 4/4] test not null --- tests/testthat/test-parse_spc.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-parse_spc.R b/tests/testthat/test-parse_spc.R index 7de7f7b..ccb08c2 100644 --- a/tests/testthat/test-parse_spc.R +++ b/tests/testthat/test-parse_spc.R @@ -13,4 +13,7 @@ test_that("parse_spc accounts for uppercase arguments and spec", { expect_snapshot(parse_spc(text)) + pp.cap <- parse_spc(text) + expect_false(is.null(pp.cap[['series']][['file']])) + })