tests/testthat/test-logical.R

rxodeTest(
  {
    context("Logical expressons test")

    .rx <- loadNamespace("RxODE")

    transTo <- function(model, syntax, match = TRUE) {
      mod <- rxModelVars(model)

      if (match) {
        test_that(
          sprintf("%s includes %s", model, syntax),
          expect_true(regexpr(syntax, .rx$.rxGetParseModel(), fixed = TRUE) != -1)
        )
      } else {
        test_that(
          sprintf("%s dose not include %s", model, syntax),
          expect_false(regexpr(syntax, .rx$.rxGetParseModel(), fixed = TRUE) != -1)
        )
      }
    }

    transTo("x=1;if (t != 0 & t != 1){x=0}", "&&")
    transTo("x=1;if ((t == 0) | (t == 1)){x=0}", "||")
    transTo("x=1;if ((t == 0) & !(t == 1)){x=0}", "&&")
    transTo("x=1;if ((t == 0) & !(t == 1)){x=0}", "!(")
  },
  silent = TRUE,
  test = "parsing"
)

Try the RxODE package in your browser

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

RxODE documentation built on March 23, 2022, 9:06 a.m.