tests/testthat/test-calc.R

# test for issues #22 and #31 (constructs were missing after align)
test_that("align()", {
  sorted_poles <- function(x) {
    df_con <- constructs(x)
    l <- as.list(as.data.frame(t(df_con))) # df rows as list
    vapply(l, function(x) paste(sort(x), collapse = " "), character(1))
  }

  file <- testthat::test_path("testdata/issue_22.txt")
  x <- importTxt(file)
  x_aligned <- align(x)
  d <- setdiff(sorted_poles(x), sorted_poles(x_aligned))
  expect_length(d, 0)

  file <- testthat::test_path("testdata/issue_31.txt")
  x <- importTxt(file)
  x_aligned <- align(x)
  d <- setdiff(sorted_poles(x), sorted_poles(x_aligned))
  expect_length(d, 0)
})

Try the OpenRepGrid package in your browser

Any scripts or data that you put into this service are public.

OpenRepGrid documentation built on Aug. 10, 2025, 5:06 p.m.