#you wouldn't put this part in example tests, just in the hidden tests solution <- function(x){ x**2 } test_that("example", { expect_equal(func(2), 4) expect_equal(func(3), 9) #etc. #or expect_equal(func(c(1:100)), solution(c(1:100))) })
- #you wouldn't put this part in example tests, just in the hidden tests
- solution <- function(x){
- x**2
- }
- test_that("example", {
- expect_equal(func(2), 4)
- expect_equal(func(3), 9)
- #etc.
- #or
- expect_equal(func(c(1:100)), solution(c(1:100)))
- })
#problem with asking to plot something is that all plot() functions will return the same thing, so all you'd need to do would be plot([anything]) # a better test would be asking to write a function that just returned the square of what was given func <- function(x){ x**2 }
#??????func <- function(){x <- c(1:10)plot(x,x**2)- #problem with asking to plot something is that all plot() functions will return the same thing, so all you'd need to do would be plot([anything])
- # a better test would be asking to write a function that just returned the square of what was given
- func <- function(x){
- x**2
- }
test_that("example", { expect_equal(func(2), 4) expect_equal(func(3), 9) #etc. })
- test_that("example", {
expect_equal(func(), plot(c(1:10),c(1:10)**2))- expect_equal(func(2), 4)
- expect_equal(func(3), 9)
- #etc.
- })
#?????? func <- function(){ x <- c(1:10) plot(x,x**2) }
print("Hellow")#THis doesnt work becasue R is not supported yet- #??????
- func <- function(){
- x <- c(1:10)
- plot(x,x**2)
- }
test_that("example", { expect_equal(func(), plot(c(1:10),c(1:10)**2)) })
- test_that("example", {
- expect_equal(func(), plot(c(1:10),c(1:10)**2))
- })