tests/testthat/test_progressivity.R

context("Progressivity")

test_that("Error handling", {
  expect_error(progressivity(measure = "Kakwani"))
  expect_error(progressivity(measure = ""))
})

test_that("Simple examples", {
  I <- c(10e3, 20e3, 50e3, 100e3, 150e3) 
  # Regressive
  expect_lt(progressivity(income = I, tax = 0.3 * I + 100), 0)
  expect_equal(progressivity(income = I, tax = 0.3 * I), 0)
  expect_gt(progressivity(income = I, tax = 0.3 * (I - 10e3)), 0)
})

Try the grattan package in your browser

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

grattan documentation built on Oct. 17, 2018, 1:05 a.m.