tests/testthat/test-parse_beast_trees.R

context("parse_beast_trees")

test_that("use", {

  filename <- get_tracerer_path("beast2_example_output.trees")
  posterior <- parse_beast_trees(filename)
  expect_true(is_trees_posterior(posterior))
  expect_equal(length(posterior), 11)
})


test_that("issue 4", {

  filename <- get_tracerer_path("unplottable_anthus_aco.trees")
  trees <- parse_beast_trees(filename)
  expect_silent(
    phangorn::densiTree(trees)
  )
})


test_that("get_tracerer_path returns multiPhlo with 'STATE_'s", {

  # Must be a clean multiPhylo
  # https://github.com/ropensci/babette/issues/10

  filename <- get_tracerer_path("unplottable_anthus_aco.trees")
  trees <- parse_beast_trees(filename)
  testit::assert(
    all(grepl(pattern = "STATE_", x = names(trees)) == FALSE)
  )
})



test_that("abuse", {

  expect_error(
    parse_beast_trees(filename = "inva.lid"),
    "'filename' is the name of an absent file"
  )

  expect_error(
    parse_beast_trees(
      filename = get_tracerer_path("beast2_example_output.log")
    ),
    "invalid file"
  )

})
ropensci/tracerer documentation built on March 12, 2019, 8:30 p.m.