Sha256: bc552939c43a4d872b4d9d09374b3b61e6dc49ffdec68913bd0cdadb5f4d7184

Contents?: true

Size: 1.22 KB

Versions: 47

Compression:

Stored size: 1.22 KB

Contents

source('./secret-handshake.R')
suppressPackageStartupMessages({ require(testthat) })

test_that("wink for 1", {
  expect_equal(handshake(1), c("wink"))
})

test_that("double blink for 10", {
  expect_equal(handshake(2), c("double blink"))
})

test_that("close your eyes for 100", {
  expect_equal(handshake(4), c("close your eyes"))
})

test_that("jump for 1000", {
  expect_equal(handshake(8), c("jump"))
})

test_that("combine two actions", {
  expect_equal(handshake(3), c("wink", "double blink"))
})

test_that("reverse two actions", {
  expect_equal(handshake(19), c("double blink", "wink"))
})

test_that("reversing one action gives the same action", {
  expect_equal(handshake(24), c("jump"))
})

test_that("reversing no actions still gives no actions", {
  expect_equal(handshake(16), c())
})

test_that("all possible actions", {
  expect_equal(handshake(15), c("wink", "double blink", "close your eyes", "jump"))
})

test_that("reverse all possible actions", {
  expect_equal(handshake(31), c("jump", "close your eyes", "double blink", "wink"))
})

test_that("do nothing for zero", {
  expect_equal(handshake(0), c())
})

test_that("do nothing if lower 5 bits not set", {
  expect_equal(handshake(32), c())
})

print("All tests passed!")

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
trackler-2.0.8.37 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.36 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.35 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.34 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.33 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.32 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.31 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.30 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.29 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.28 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.27 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.26 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.24 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.23 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.22 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.21 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.20 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.19 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.18 tracks/r/exercises/secret-handshake/test_secret-handshake.R
trackler-2.0.8.17 tracks/r/exercises/secret-handshake/test_secret-handshake.R