Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_spc() accounts for uppercase arguments and spec #322

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/parse_spc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)


Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/_snaps/parse_spc.md
Original file line number Diff line number Diff line change
@@ -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"
}

19 changes: 19 additions & 0 deletions tests/testthat/test-parse_spc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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))

pp.cap <- parse_spc(text)
expect_false(is.null(pp.cap[['series']][['file']]))

})
Loading