@@ -41,21 +41,21 @@ testthat::test_that("getting object from the package namespace works even if lib
4141testthat :: test_that(" eval_code works with character" , {
4242 q1 <- eval_code(qenv(), " a <- 1" )
4343
44- testthat :: expect_identical(q1 @ code , " a <- 1" )
44+ testthat :: expect_identical(unlist( q1 @ code ) , " a <- 1" )
4545 testthat :: expect_equal(q1 @ env , list2env(list (a = 1 )))
4646})
4747
4848testthat :: test_that(" eval_code works with expression" , {
4949 q1 <- eval_code(qenv(), as.expression(quote(a <- 1 )))
5050
51- testthat :: expect_identical(q1 @ code , " a <- 1" )
51+ testthat :: expect_identical(unlist( q1 @ code ) , " a <- 1" )
5252 testthat :: expect_equal(q1 @ env , list2env(list (a = 1 )))
5353})
5454
5555testthat :: test_that(" eval_code works with quoted" , {
5656 q1 <- eval_code(qenv(), quote(a <- 1 ))
5757
58- testthat :: expect_identical(q1 @ code , " a <- 1" )
58+ testthat :: expect_identical(unlist( q1 @ code ) , " a <- 1" )
5959 testthat :: expect_equal(q1 @ env , list2env(list (a = 1 )))
6060})
6161
@@ -69,7 +69,7 @@ testthat::test_that("eval_code works with quoted code block", {
6969 )
7070
7171 testthat :: expect_equal(
72- q1 @ code ,
72+ unlist( q1 @ code ) ,
7373 c(" a <- 1" , " b <- 2" )
7474 )
7575 testthat :: expect_equal(q1 @ env , list2env(list (a = 1 , b = 2 )))
@@ -96,14 +96,17 @@ testthat::test_that("a warning when calling eval_code returns a qenv object whic
9696 q <- eval_code(q , quote(" p <- hist(iris_data[, 'Sepal.Length'], ff = '')" ))
9797 testthat :: expect_s4_class(q , " qenv" )
9898 testthat :: expect_equal(
99- q @ warnings ,
100- c( " " , " > \" ff\" is not a graphical parameter\n " )
99+ lapply( q @ code , attr , " warning " ) ,
100+ list ( NULL , " > \" ff\" is not a graphical parameter\n " )
101101 )
102102})
103103
104104testthat :: test_that(" eval_code with a vector of code produces one warning element per code element" , {
105105 q <- eval_code(qenv(), c(" x <- 1" , " y <- 1" , " warning('warn1')" ))
106- testthat :: expect_equal(c(" " , " " , " > warn1\n " ), q @ warnings )
106+ testthat :: expect_equal(
107+ lapply(q @ code , attr , " warning" ),
108+ list (NULL , NULL , " > warn1\n " )
109+ )
107110})
108111
109112
@@ -112,9 +115,9 @@ testthat::test_that("a message when calling eval_code returns a qenv object whic
112115 q <- eval_code(q , quote(" message('This is a message')" ))
113116 testthat :: expect_s4_class(q , " qenv" )
114117 testthat :: expect_equal(
115- q @ messages ,
116- c (
117- " " ,
118+ lapply( q @ code , attr , " message " ) ,
119+ list (
120+ NULL ,
118121 " > This is a message\n "
119122 )
120123 )
@@ -123,6 +126,6 @@ testthat::test_that("a message when calling eval_code returns a qenv object whic
123126testthat :: test_that(" eval_code returns a qenv object with empty messages and warnings when none are returned" , {
124127 q <- eval_code(qenv(), quote(" iris_data <- head(iris)" ))
125128 testthat :: expect_s4_class(q , " qenv" )
126- testthat :: expect_equal( q @ messages , " " )
127- testthat :: expect_equal( q @ warnings , " " )
129+ testthat :: expect_null(attr( q @ code , " message " ) )
130+ testthat :: expect_null(attr( q @ code , " warning " ) )
128131})
0 commit comments