library(testthat)
test_that("strings",
{
q <- mathml("text")
expect_equal(q, "")
})
test_that("atoms",
{
q <- mathml(as.symbol("atom"))
expect_equal(q, "")
})
test_that("greek",
{
q <- mathml(as.symbol("pi"))
expect_equal(q, "")
})
test_that("calligraphy",
{
q <- mathml(quote(K %in% cal(K)))
expect_equal(q, "")
})
test_that("calligraphy",
{
q <- mathml(call("%in%", as.symbol("K"), call("cal", as.symbol("K"))))
expect_equal(q, "")
})
test_that("absx",
{
q <- mathml(quote(abs(x)))
expect_equal(q, "")
})
test_that("absgreek",
{
q <- mathml(quote(abs(alpha)))
expect_equal(q, "")
})
test_that("signx",
{
q <- mathml(quote(sign(x)))
expect_equal(q, "")
})
test_that("signgreek",
{
q <- mathml(quote(sign(alpha)))
expect_equal(q, "")
})
test_that("sqrtnum",
{
q <- mathml(quote(sqrt(2L)))
expect_equal(q, "")
})
test_that("sqrtalpha",
{
q <- mathml(quote(sqrt(alpha)))
expect_equal(q, "")
})
test_that("sin(pi/2)",
{
q <- mathml(quote(sin(pi/2L)))
expect_equal(q, "")
})
test_that("cos(pi/2)",
{
q <- mathml(quote(cos(pi/2L)))
expect_equal(q, "")
})
test_that("tan(pi/2)",
{
q <- mathml(quote(tan(pi/2L)))
expect_equal(q, "")
})
test_that("asin(1/2*sqrt2)",
{
q <- mathml(quote(asin(1L/2L * sqrt(2L))))
expect_equal(q, "")
})
test_that("acos(1/2*sqrt2)",
{
q <- mathml(quote(acos(1L/2L * sqrt(2L))))
expect_equal(q, "")
})
test_that("atan(1/2*sqrt2)",
{
q <- mathml(quote(atan(1L/2L * sqrt(2L))))
expect_equal(q, "")
})
test_that("atan(1/2*sqrt3)",
{
q <- mathml(quote(atan(1L/2L * sqrt(3L))))
expect_equal(q, "")
})
test_that("singreek(num)",
{
q <- mathml(quote(sinpi(2L)))
expect_equal(q, "")
})
test_that("cosgreek(num)",
{
q <- mathml(quote(cospi(2L)))
expect_equal(q, "")
})
test_that("tangreek(num)",
{
q <- mathml(quote(tanpi(2L)))
expect_equal(q, "")
})
test_that("sinhx",
{
q <- mathml(quote(sinh(x)))
expect_equal(q, "")
})
test_that("coshx",
{
q <- mathml(quote(cosh(x)))
expect_equal(q, "")
})
test_that("tanhx",
{
q <- mathml(quote(tanh(x)))
expect_equal(q, "")
})
test_that("asinhx",
{
q <- mathml(quote(asinh(x)))
expect_equal(q, "")
})
test_that("acoshx",
{
q <- mathml(quote(acosh(x)))
expect_equal(q, "")
})
test_that("atanhx",
{
q <- mathml(quote(atanh(x)))
expect_equal(q, "")
})
test_that("allx",
{
q <- mathml(quote(all(x)))
expect_equal(q, "")
})
test_that("anyx",
{
q <- mathml(quote(any(x)))
expect_equal(q, "")
})
test_that("besselInu(x)",
{
q <- mathml(quote(besselI(x, nu)))
expect_equal(q, "")
})
test_that("besselKnu(x)",
{
q <- mathml(quote(besselK(x, nu)))
expect_equal(q, "")
})
test_that("besselKnu(x)",
{
q <- mathml(quote(besselK(x, nu)))
expect_equal(q, "")
})
test_that("besselJnu(x)",
{
q <- mathml(quote(besselJ(x, nu)))
expect_equal(q, "")
})
test_that("besselYnu(x)",
{
q <- mathml(quote(besselY(x, nu)))
expect_equal(q, "")
})
test_that("beta(a,b)",
{
q <- mathml(quote(beta(a, b)))
expect_equal(q, "")
})
test_that("lbeta(a,b)",
{
q <- mathml(quote(lbeta(a, b)))
expect_equal(q, "")
})
test_that("gammax",
{
q <- mathml(quote(gamma(x)))
expect_equal(q, "")
})
test_that("lgammax",
{
q <- mathml(quote(lgamma(x)))
expect_equal(q, "")
})
test_that("digammax",
{
q <- mathml(quote(digamma(x)))
expect_equal(q, "")
})
test_that("psigammax",
{
q <- mathml(quote(psigamma(x, deriv=psi)))
expect_equal(q, "")
})
test_that("alogb",
{
q <- mathml(quote(a*log(b)))
expect_equal(q, "")
})
test_that("bloga",
{
q <- mathml(quote(log(b)*a))
expect_equal(q, "")
})
test_that("sumab",
{
q <- mathml(quote(a*sum(b)))
expect_equal(q, "")
})
test_that("sumba",
{
q <- mathml(quote(sum(b)*a))
expect_equal(q, "")
})
test_that("digammax",
{
q <- mathml(quote(digamma(x)))
expect_equal(q, "")
})
test_that("trigammax",
{
q <- mathml(quote(trigamma(x)))
expect_equal(q, "")
})
test_that("bincoef",
{
q <- mathml(quote(choose(n, k)))
expect_equal(q, "")
})
test_that("BinCoef",
{
q <- mathml(quote(choose(k=K, n=N)))
expect_equal(q, "")
})
test_that("logbincoef",
{
q <- mathml(quote(lchoose(n, k)))
expect_equal(q, "")
})
test_that("factorial",
{
q <- mathml(quote(factorial(x)))
expect_equal(q, "")
})
test_that("lfactorial",
{
q <- mathml(quote(lfactorial(x)))
expect_equal(q, "")
})
test_that("AND",
{
q <- mathml(quote(A & B))
expect_equal(q, "")
})
test_that("OR",
{
q <- mathml(quote(A | B))
expect_equal(q, "")
})
test_that("!A",
{
q <- mathml(quote(!A))
expect_equal(q, "")
})
test_that("xor",
{
q <- mathml(quote(xor(A, B)))
expect_equal(q, "")
})
test_that("expnumgreeki",
{
q <- mathml(quote(exp(2L*pi*i)))
expect_equal(q, "")
})
test_that("expm1numgreeki",
{
q <- mathml(quote(expm1(2L*pi*i)))
expect_equal(q, "")
})
test_that("logx",
{
q <- mathml(quote(log(x)))
expect_equal(q, "")
})
test_that("log10x",
{
q <- mathml(quote(log10(x)))
expect_equal(q, "")
})
test_that("log2x",
{
q <- mathml(quote(log2(x)))
expect_equal(q, "")
})
test_that("logex",
{
q <- mathml(quote(logb(x, e)))
expect_equal(q, "")
})
test_that("log1px",
{
q <- mathml(quote(log1p(x)))
expect_equal(q, "")
})
test_that("ceilingpi",
{
q <- mathml(quote(ceiling(pi)))
expect_equal(q, "")
})
test_that("floorpi",
{
q <- mathml(quote(floor(pi)))
expect_equal(q, "")
})
f <- as.function(alist(a=, b=2, a+b))
test_that("function",
{
q <- mathml(canonical(f))
expect_equal(q, "")
})
f <- function(x) sin(x)
test_that("functionsin",
{
q <- mathml(canonical(f))
expect_equal(q,"")
})
f <- function(x) { sin(x) ; tan(x)}
test_that("functionsintan",
{
q <- mathml(canonical(f))
expect_equal(q,"")
})
f <- function(x) {sin(x) ; cos(x)}
test_that("functionsincos",
{
q <- mathml(canonical(f))
expect_equal(q,"")
})
test_that("identical",
{
q <- mathml(quote(identical(1L, 2L)))
expect_equal(q,"")
})
test_that("ifelse",
{
q <- mathml(quote(ifelse(a > b, a, b)))
expect_equal(q,"")
})
test_that("in",
{
q <- mathml(quote(a %in% A))
expect_equal(q,"")
})
test_that("intersect",
{
q <- mathml(quote(intersect(A, B)))
expect_equal(q,"")
})
test_that("union",
{
q <- mathml(quote(union(A, B)))
expect_equal(q,"")
})
test_that("null",
{
q <- mathml(quote(is.null(intersect(A, B))))
expect_equal(q,"")
})
test_that("column",
{
q <- mathml(quote(a:b))
expect_equal(q,"")
})
test_that("diff",
{
q <- mathml(quote(setdiff(A, B)))
expect_equal(q,"")
})
test_that("x",
{
q <- mathml(quote(X %x% Y))
expect_equal(q,"")
})
test_that("expr",
{
q <- mathml(quote(a*b + c/d - e %*% f))
expect_equal(q,"")
})
test_that("crossprod",
{
q <- mathml(quote(crossprod(A, B)))
expect_equal(q,"")
})
test_that("tcrossprod",
{
q <- mathml(quote(tcrossprod(A, B)))
expect_equal(q, "")
})
test_that("tilde",
{
q <- mathml(quote(A ~ B))
expect_equal(q,"")
})
test_that("expx",
{
q <- mathml(quote(exp(x)))
expect_equal(q,"")
})
test_that("expm1x",
{
q <- mathml(quote(expm1(x)))
expect_equal(q,"")
})
test_that("dbinom",
{
q <- mathml(quote(dbinom(k, N, pi)))
expect_equal(q,"")
})
test_that("pbinom",
{
q <- mathml(quote(pbinom(k, N, pi)))
expect_equal(q,"")
})
test_that("qbinom",
{
q <- mathml(quote(qbinom(k, N, pi)))
expect_equal(q,"")
})
test_that("dpois",
{
q <- mathml(quote(dpois(k, lambda)))
expect_equal(q,"")
})
test_that("ppois",
{
q <- mathml(quote(ppois(k, lambda)))
expect_equal(q,"")
})
test_that("qpois",
{
q <- mathml(quote(qpois(k, lambda)))
expect_equal(q,"")
})
test_that("dexp",
{
q <- mathml(quote(dexp(x, lambda)))
expect_equal(q,"")
})
test_that("pexp",
{
q <- mathml(quote(pexp(x, lambda)))
expect_equal(q,"")
})
test_that("qexp",
{
q <- mathml(quote(qexp(x, lambda)))
expect_equal(q,"")
})
test_that("dnorm",
{
q <- mathml(quote(dnorm(x, mu, sigma)))
expect_equal(q,"")
})
test_that("pnorm",
{
q <- mathml(quote(pnorm(x, mu, sigma)))
expect_equal(q,"")
})
test_that("qnorm",
{
q <- mathml(quote(qnorm(alpha/2)))
expect_equal(q, sprintf("", format(2, nsmall=getOption("digits"))))
})
test_that("1mpchisq",
{
q <- mathml(quote(1 - pchisq(x, 1)))
expect_equal(q, sprintf("",
format(1, nsmall=getOption("digits")), format(1, nsmall=getOption("digits"))))
})
test_that("pchisq1malpha",
{
q <- mathml(quote(qchisq(1 - alpha, 1)))
expect_equal(q, sprintf("",
format(1, nsmall=getOption("digits")), format(1, nsmall=getOption("digits"))))
})
test_that("ptnm1",
{
q <- mathml(quote(pt(t, N - 1)))
expect_equal(q, sprintf("",
format(1, nsmall=getOption("digits"))))
})
test_that("qtalpha2nm1",
{
q <- mathml(quote(qt(alpha/2, N - 1)))
expect_equal(q, sprintf("",
format(2, nsmall=getOption("digits")), format(1, nsmall=getOption("digits"))))
})
test_that("AXB",
{
q <- mathml(quote(A %*% B))
expect_equal(q, "")
})
test_that("AdotB",
{
q <- mathml(quote(A %.% B))
expect_equal(q, "")
})
test_that("AxB",
{
q <- mathml(quote(A %x% B))
expect_equal(q, "")
})
test_that("A/B",
{
q <- mathml(quote(A %/% B))
expect_equal(q, "")
})
test_that("A mod B",
{
q <- mathml(quote(A %% B))
expect_equal(q, "")
})
test_that("A&B",
{
q <- mathml(quote(A & B))
expect_equal(q, "")
})
test_that("AvelB",
{
q <- mathml(quote(A | B))
expect_equal(q, "")
})
test_that("AeqeqB",
{
q <- mathml(quote(A == B))
expect_equal(q, "")
})
test_that("AarroweqB",
{
q <- mathml(quote(A <- B))
expect_equal(q, "")
})
test_that("AdiffB",
{
q <- mathml(quote(A != B))
expect_equal(q, "")
})
test_that("AtildetildeB",
{
q <- mathml(quote(A %~~% B))
expect_equal(q, "")
})
test_that("AequivB",
{
q <- mathml(quote(A %==% B))
expect_equal(q, "")
})
test_that("AcongB",
{
q <- mathml(quote(A %=~% B))
expect_equal(q, "")
})
test_that("ApropB",
{
q <- mathml(quote(A %prop% B))
expect_equal(q, "")
})
test_that("AisinB",
{
q <- mathml(quote(A %in% B))
expect_equal(q, "")
})
test_that("AlrarrowB",
{
q <- mathml(quote(A %<->% B))
expect_equal(q, "")
})
test_that("ArarrowB",
{
q <- mathml(quote(A %->% B))
expect_equal(q, "")
})
test_that("AlarrowB",
{
q <- mathml(quote(A %<-% B))
expect_equal(q, "")
})
test_that("AuparrowB",
{
q <- mathml(quote(A %up% B))
expect_equal(q, "")
})
test_that("AdownarrowB",
{
q <- mathml(quote(A %down% B))
expect_equal(q, "")
})
test_that("AlrdoublearrowB",
{
q <- mathml(quote(A %<=>% B))
expect_equal(q, "")
})
test_that("AldoublearrowB",
{
q <- mathml(quote(A %<=% B))
expect_equal(q, "")
})
test_that("ArdoublearrowB",
{
q <- mathml(quote(A %=>% B))
expect_equal(q, "")
})
test_that("AupdoublearrowB",
{
q <- mathml(quote(A %dblup% B))
expect_equal(q, "")
})
test_that("AdowndoublearrowB",
{
q <- mathml(quote(A %dbldown% B))
expect_equal(q, "")
})
test_that("meanx",
{
q <- mathml(quote(mean(X)))
expect_equal(q, "")
})
test_that("AplusminusB",
{
q <- mathml(quote(A %+-% B))
expect_equal(q, "")
})
f <- function(x)
{
if(x == 0L) return(0L)
if(x < 0L) return(-1L)
if(x > 0L) return(1L)
}
test_that("functionifelse",
{
q <- mathml(canonical(f))
expect_equal(q,"")
})
test_that("integrate",
{
q <- mathml(canonical(integrate(lower=0L, upper=2L*pi, sin)))
expect_equal(q, sprintf("",
format(0, nsmall=getOption("digits")), format(0, nsmall=getOption("digits"))))
})
v <- 1:3
test_that("vector",
{
q <- mathml(call("t", v))
expect_equal(q, "")
})
A <- matrix(data=11:16, nrow=2, ncol=3)
B <- matrix(data=21:26, nrow=2, ncol=3)
test_that("summatrix",
{
q <- mathml(call("+", A, B))
expect_equal(q, "")
})
z <- function(m, s, n, tau, c, mu_A, sigma_A, mu_B, sigma_B, mu_M)
dfrac(m - denote(E, ET(tau, c, mu_A, sigma_A, mu_B, sigma_B, mu_M),
"the expected mean response time"), s / sqrt(n))
test_that("denoting",
{
q <- mathml(call("=", quote(z[tau]), z))
expect_equal(q, ", with denoting the expected mean response time")
})
term <- quote(dot(a, b) + frac(1L, nodot(c, d + e)) + dfrac(1L, times(g, h)))
test_that("expressionmolt",
{
q <- mathml(term)
expect_equal(q, "")
})
t <- quote(omit_left(a + b))
test_that("omitleft",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- quote(omit_right(a + b))
test_that("omitright",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- list(quote(a), quote(b), quote(omit(c)))
test_that("omit",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- quote(add_left(a + b))
test_that("addleft",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- quote(add_right(a + b))
test_that("addright",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- list(quote(a), quote(b), quote(add(c)))
test_that("add",
{
q <- mathml(t)
expect_equal(q, "")
})
t <- quote(instead(a, b) + c)
test_that("instead",
{
q <- mathml(t)
expect_equal(q, "")
})
test_that("Tdiamond",
{
q <- mathml(quote(T^diamond))
expect_equal(q, "")
})
test_that("digits",
{
q <- mathml(quote(3.14159265), flags=list(quote(digits(4L))))
expect_equal(q, "")
})