Skip to content

Commit

Permalink
fix(test seeds): add simmer:: for get_mon_arrivals() etc. as these we…
Browse files Browse the repository at this point in the history
…re not import within R/ so it can't find them (as we imported specific functions from simmer, and not whole package overall)
  • Loading branch information
amyheather committed Jan 15, 2025
1 parent d3e3ef6 commit d0293f6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/testthat/test-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ test_that("the same seed returns the same result", {

# Compare output results
expect_identical(
env1 %>% get_mon_arrivals(),
env2 %>% get_mon_arrivals())
env1 %>% simmer::get_mon_arrivals(),
env2 %>% simmer::get_mon_arrivals())
expect_identical(
env1 %>% get_mon_resources(),
env2 %>% get_mon_resources())
env1 %>% simmer::get_mon_resources(),
env2 %>% simmer::get_mon_resources())

# Conversely, if run with different run number, expect different
env1 <- model(run_number=0, param=defaults())
env2 <- model(run_number=1, param=defaults())

# Compare output results
expect_failure(expect_identical(
env1 %>% get_mon_arrivals(),
env2 %>% get_mon_arrivals()))
env1 %>% simmer::get_mon_arrivals(),
env2 %>% simmer::get_mon_arrivals()))
expect_failure(expect_identical(
env1 %>% get_mon_resources(),
env2 %>% get_mon_resources()))
env1 %>% simmer::get_mon_resources(),
env2 %>% simmer::get_mon_resources()))

# Repeat experiment, but with multiple replications
envs1 <- trial(param=defaults())
envs2 <- trial(param=defaults())

# Aggregate results from replications in each trial, then compare full trial
expect_identical(
do.call(rbind, lapply(envs1, get_mon_arrivals)),
do.call(rbind, lapply(envs2, get_mon_arrivals)))
do.call(rbind, lapply(envs1, simmer::get_mon_arrivals)),
do.call(rbind, lapply(envs2, simmer::get_mon_arrivals)))
expect_identical(
do.call(rbind, lapply(envs1, get_mon_resources)),
do.call(rbind, lapply(envs2, get_mon_resources)))
do.call(rbind, lapply(envs1, simmer::get_mon_resources)),
do.call(rbind, lapply(envs2, simmer::get_mon_resources)))
})

0 comments on commit d0293f6

Please sign in to comment.