From d456bc2aa90195a29a08605ed9139afd6879c8aa Mon Sep 17 00:00:00 2001 From: chainsawriot Date: Tue, 11 Jun 2024 16:49:53 +0200 Subject: [PATCH] Remove all partial matching cases in test fix #165 --- tests/testthat/test-tk_index.R | 4 ++-- tests/testthat/test-tk_ts.R | 4 ++-- tests/testthat/test-tk_zooreg.R | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/testthat/test-tk_index.R b/tests/testthat/test-tk_index.R index 66884764..77e841d4 100644 --- a/tests/testthat/test-tk_index.R +++ b/tests/testthat/test-tk_index.R @@ -3,8 +3,8 @@ library(dplyr) FB_tbl <- FANG %>% dplyr::filter(symbol == "FB") FB_xts <- FB_tbl %>% tk_xts(silent = TRUE) FB_zoo <- FB_tbl %>% tk_zoo(silent = TRUE) -FB_zooreg <- FB_tbl %>% tk_zooreg(start = 2015, freq = 252, silent = TRUE) -FB_ts <- FB_tbl %>% tk_ts(start = 2015, freq = 252, silent = TRUE) +FB_zooreg <- FB_tbl %>% tk_zooreg(start = 2015, frequency = 252, silent = TRUE) +FB_ts <- FB_tbl %>% tk_ts(start = 2015, frequency = 252, silent = TRUE) # FUNCTION tk_index ----- diff --git a/tests/testthat/test-tk_ts.R b/tests/testthat/test-tk_ts.R index a47735e5..18413d1c 100644 --- a/tests/testthat/test-tk_ts.R +++ b/tests/testthat/test-tk_ts.R @@ -45,7 +45,7 @@ test_that("xts to ts test returns ts with correct rows and columns.", { # Error if using date_var field expect_error(tk_ts(FB_xts, date_var = date, - freq = 252, start = 2015)) # date_var not used + frequency = 252, start = 2015)) # date_var not used }) @@ -67,6 +67,6 @@ test_that("zoo to ts test returns ts with correct rows and columns.", { # Warning if using date_var field expect_error(tk_ts(FB_xts, date_var = date, - freq = 252, start = 2015)) # date_var not used + frequency = 252, start = 2015)) # date_var not used }) diff --git a/tests/testthat/test-tk_zooreg.R b/tests/testthat/test-tk_zooreg.R index ecd7c8c5..a4b25e0b 100644 --- a/tests/testthat/test-tk_zooreg.R +++ b/tests/testthat/test-tk_zooreg.R @@ -8,30 +8,30 @@ FB_xts <- FB_tbl %>% tk_xts(silent = TRUE) # tbl to zooreg ----- test_that("tbl to zooreg test returns zooreg with correct rows and columns.", { # Use date column to specify order - test_zooreg_1 <- tk_zooreg(FB_tbl, freq = 252, start = 2015, silent = TRUE) + test_zooreg_1 <- tk_zooreg(FB_tbl, frequency = 252, start = 2015, silent = TRUE) expect_equal(nrow(test_zooreg_1), 1008) expect_equal(ncol(test_zooreg_1), 6) expect_equal(rownames(test_zooreg_1), as.character(FB_tbl$date)) # Use order.by to specify order - test_zooreg_2 <- tk_zooreg(FB_tbl, order.by = FB_tbl$date, freq = 252, start = 2015, silent = TRUE) + test_zooreg_2 <- tk_zooreg(FB_tbl, order.by = FB_tbl$date, frequency = 252, start = 2015, silent = TRUE) expect_equal(nrow(test_zooreg_2), 1008) expect_equal(ncol(test_zooreg_2), 6) # # Auto-index date - # expect_message(tk_zooreg(FB_tbl, freq = 252, start = 2015)) # using `date` column as date + # expect_message(tk_zooreg(FB_tbl, frequency = 252, start = 2015)) # using `date` column as date # Auto-drop columns - expect_warning(tk_zooreg(FB_tbl, freq = 252, start = 2015)) # dropping date column + expect_warning(tk_zooreg(FB_tbl, frequency = 252, start = 2015)) # dropping date column # # Auto-index and auto-drop columns - # expect_message(expect_warning(tk_zooreg(FB_tbl, freq = 252, start = 2015))) # using `date` column as date, dropping date column + # expect_message(expect_warning(tk_zooreg(FB_tbl, frequency = 252, start = 2015))) # using `date` column as date, dropping date column # NSE select <- "adjusted" date_var <- "date" test_zooreg_3 <- tk_zooreg_(FB_tbl, select = select, date_var = date_var, - freq = 252, start = 2015) + frequency = 252, start = 2015) expect_equal(nrow(test_zooreg_3), 1008) expect_equal(ncol(test_zooreg_3), 1) expect_equal(colnames(test_zooreg_3), select) @@ -42,7 +42,7 @@ test_that("tbl to zooreg test returns zooreg with correct rows and columns.", { # Default is xts::xts() for other objects; only test zoo test_that("xts to zooreg test returns zooreg with correct rows and columns.", { # Use date column to specify order - test_zooreg_4 <- tk_zooreg(FB_xts, freq = 252, start = 2015, silent = TRUE) + test_zooreg_4 <- tk_zooreg(FB_xts, frequency = 252, start = 2015, silent = TRUE) expect_equal(nrow(test_zooreg_4), 1008) expect_equal(ncol(test_zooreg_4), 6) @@ -53,14 +53,14 @@ test_that("xts to zooreg test returns zooreg with correct rows and columns.", { # Warning if using select field expect_warning(tk_zooreg(FB_xts, select = -date, - freq = 252, start = 2015)) # only for use with data.frames + frequency = 252, start = 2015)) # only for use with data.frames # Warning if using date_var field expect_warning(tk_zooreg(FB_xts, date_var = date, - freq = 252, start = 2015)) # only for use with data.frames + frequency = 252, start = 2015)) # only for use with data.frames # Two warnings: select and date_var args only applicable to data.frames expect_warning(tk_zooreg(FB_xts, select = -date, date_var = date, - freq = 252, start = 2015)) + frequency = 252, start = 2015)) })