From 3cfa7bf8bc23c41ff61a95dcc8648fcf06556164 Mon Sep 17 00:00:00 2001 From: Jonathon Love Date: Tue, 17 Jan 2017 12:35:40 +1100 Subject: [PATCH] Added travis-ci support --- .travis.yml | 6 +++++ README.md | 1 + pkg/BayesFactor/inst/tests/test-anovaBF.R | 7 ++--- .../inst/tests/test-generalTestBF.R | 8 ++++++ pkg/BayesFactor/inst/tests/test-ttest.R | 27 +++++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 pkg/BayesFactor/inst/tests/test-generalTestBF.R create mode 100644 pkg/BayesFactor/inst/tests/test-ttest.R diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1370912 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ + +language: r +cache: packages +warnings_are_errors: false +before_install: + - cd pkg/BayesFactor diff --git a/README.md b/README.md index ad1e87a..7f23bf2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![DOI](https://zenodo.org/badge/6098/richarddmorey/BayesFactor.svg)](https://zenodo.org/badge/latestdoi/6098/richarddmorey/BayesFactor) +[![Build Status](https://travis-ci.org/richarddmorey/BayesFactor.svg)](https://travis-ci.org/richarddmorey/BayesFactor) `BayesFactor` is an R package that enables the computation of Bayes factors in standard designs, such as one- and two- sample designs, ANOVA designs, regression, and analysis of contingency tables and proportions. diff --git a/pkg/BayesFactor/inst/tests/test-anovaBF.R b/pkg/BayesFactor/inst/tests/test-anovaBF.R index 9aa0a3c..24c1f1f 100644 --- a/pkg/BayesFactor/inst/tests/test-anovaBF.R +++ b/pkg/BayesFactor/inst/tests/test-anovaBF.R @@ -1,11 +1,12 @@ + context("anovaBF") test_that("Puzzles example works", { data(puzzles) - + bf = anovaBF(RT ~ shape*color + ID, data = puzzles, whichRandom = "ID", iterations=1000, progress = FALSE) - + expect_that(bf, is_a("BFBayesFactor")) expect_that(length(bf), is_equivalent_to(4)) -}) \ No newline at end of file +}) diff --git a/pkg/BayesFactor/inst/tests/test-generalTestBF.R b/pkg/BayesFactor/inst/tests/test-generalTestBF.R new file mode 100644 index 0000000..c100cba --- /dev/null +++ b/pkg/BayesFactor/inst/tests/test-generalTestBF.R @@ -0,0 +1,8 @@ + +context('generalTestBF') + +data(puzzles) + +test_that('generalTestBF works', { + generalTestBF(RT ~ shape*color*ID, whichRandom="ID", data = puzzles) +}) diff --git a/pkg/BayesFactor/inst/tests/test-ttest.R b/pkg/BayesFactor/inst/tests/test-ttest.R new file mode 100644 index 0000000..60ff8b3 --- /dev/null +++ b/pkg/BayesFactor/inst/tests/test-ttest.R @@ -0,0 +1,27 @@ + +context('t-test') + +data('ToothGrowth') + +test_that('ttest works', { + ttestBF(ToothGrowth$len, ToothGrowth$dose) + ttestBF(formula=len~supp, data=ToothGrowth) +}) + +test_that('rejects bad input', { + expect_error( + ttestBF(formula=len~dose, data=ToothGrowth), + 'Indep. groups t test requires a factor with exactly 2 levels.', + fixed=TRUE + ) + expect_error( + ttestBF(formula=len~dose+supp, data=ToothGrowth), + 'Indep. groups t test can only support 1 factor as predictor.', + fixed=TRUE + ) + expect_error( + ttestBF(formula=len~dose:supp, data=ToothGrowth), + 'Interaction terms are not allowed in t test.', + fixed=TRUE + ) +})