tests/testthat/test-parser2.R

varnames<-c("a1","b1","a2","b2")
hypotheses31 <-
  "0.20 *a1 = 0.20 *a2&
0.20 *b1 = 0.20 *b2 &"
x1<-bain:::parse_hypothesis(varnames, hypotheses31)

varnames<-c("a1","b1","a2","b2")
hypotheses31 <-
  ".20 *a1 = .20 *a2&
.20 *b1 = .20 *b2 &";
x2<-bain:::parse_hypothesis(varnames, hypotheses31)

test_that("parser", {expect_equal(as.vector(t(do.call(rbind, x1$hyp_mat))),
                                  as.vector(t(do.call(rbind, x2$hyp_mat))))})


varnames<-c("a1","b1","c1","d1","e1","f1","a2","b2","c2","d2","e2","f2")
hypotheses31 <-
  "a1 = a2 - 0.2&
b1 = b2 + .2 &
0.2*c1 -.3 = c2 +.3&
d1 + .3= 3*d2 + .3&
e1 -.3= e2 + .3&
4*f1 -0.3 = 3.2*f2"
x3<-bain:::parse_hypothesis(varnames, hypotheses31)

test_that("parser", {expect_equal(as.vector(t(do.call(rbind, x3$hyp_mat))),
                                  c(1 , 0, 0.0 , 0, 0 , 0 ,-1 ,0 , 0 , 0, 0 , 0.0, -0.2,
                                    0 , 1, 0.0, 0, 0 , 0 ,0, -1 ,0 ,0 , 0, 0.0, 0.2,
                                    0 , 0, 0.2, 0, 0 , 0 , 0 ,0, -1, 0 , 0 , 0.0 , 0.6,
                                    0 ,0, 0.0 , 1 , 0, 0 , 0 ,0 , 0, -3, 0 ,0.0 , 0.0,
                                    0, 0, 0.0, 0, 1 , 0, 0, 0 , 0, 0 ,-1 , 0.0 , 0.6,
                                    0, 0, 0.0, 0, 0, 4, 0 , 0, 0, 0 , 0 ,-3.2, 0.3)
)})

Try the bain package in your browser

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

bain documentation built on Sept. 27, 2023, 5:06 p.m.