Skip to content

Commit

Permalink
Check API, not implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAndrews committed Jul 26, 2018
1 parent 9f74e20 commit 993434a
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions inst/unitTests/runit.xts.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ test..xts_dimnames_in_dots <- function() {
}

checkXtsClass <- function(xts, class) {
checkEquals(attr(xts, "tclass"), class)
checkEquals(attr(xts, ".indexCLASS"), class)
checkEquals(tclass(xts), class)
checkEquals(indexClass(xts), class)
checkEquals(attr(attr(xts, "index"), "tclass"), class)
}

Expand All @@ -71,9 +71,9 @@ test..xts_class <- function() {
checkXtsClass(.xts(1, structure(1, tzone="",tclass="yearmon"), tclass="timeDate", .indexCLASS="Date"), "Date")
}

checkXtsTz <- function(xts, tzone, .indexTZ) {
checkEquals(attr(xts, "tzone"), tzone)
checkEquals(attr(xts, ".indexTZ"), .indexTZ)
checkXtsTz <- function(xts, tzone) {
checkEquals(tzone(xts), tzone)
checkEquals(indexTZ(xts), tzone)
checkEquals(attr(attr(xts, "index"), "tzone"), tzone)
}

Expand All @@ -83,23 +83,15 @@ checkXtsTz <- function(xts, tzone, .indexTZ) {

### Check that tzone is honoured and .indexTZ ignored
test..xts_tzone <- function() {
checkXtsTz(.xts(1, 1), "UTC", "UTC")
checkXtsTz(.xts(1, 1, tzone="Europe/London"), "Europe/London", "Europe/London")
checkXtsTz(.xts(1, 1), "UTC")
checkXtsTz(.xts(1, 1, tzone="Europe/London"), "Europe/London")
## this case passes in 0.10-2 but looks wrong
checkXtsTz(.xts(1, 1, .indexTZ="America/New_York"), "UTC", "America/New_York")
## this case passes in 0.10-2 but looks wrong
checkXtsTz(.xts(1, 1, tzone="Europe/London", .indexTZ="America/New_York"),
"Europe/London", "America/New_York")
checkXtsTz(.xts(1, 1, .indexTZ="America/New_York"), "UTC")
checkXtsTz(.xts(1, 1, tzone="Europe/London", .indexTZ="America/New_York"), "Europe/London")

## Cases where tzone is specified in the index
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon")),
"Asia/Tokyo", "Asia/Tokyo")
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), tzone="Europe/London"),
"Europe/London", "Europe/London")
## this case passes in 0.10-2 but looks wrong
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), .indexTZ="America/New_York"),
"Asia/Tokyo", "America/New_York")
## this case passes in 0.10-2 but looks wrong
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), tzone="Europe/London", .indexTZ="America/New_York"),
"Europe/London", "America/New_York")
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon")), "Asia/Tokyo")
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), tzone="Europe/London"), "Europe/London")
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), .indexTZ="America/New_York"), "Asia/Tokyo")
checkXtsTz(.xts(1, structure(1, tzone="Asia/Tokyo",tclass="yearmon"), tzone="Europe/London", .indexTZ="America/New_York"), "Europe/London")
}

0 comments on commit 993434a

Please sign in to comment.