errors.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. const test = require('tap').test;
  3. const ttest = require('../../hypothesis.js');
  4. test('throws if left value is not compatible', function (t) {
  5. t.throws(() => ttest('string'), {
  6. message: 'left value in hypothesis test must be an array or data summary'
  7. });
  8. t.end();
  9. });
  10. test('throws if mu is not a number', function (t) {
  11. t.throws(() => ttest([0, 1, 2], { mu: 'string' }), {
  12. message: 'mu option must be a number'
  13. });
  14. t.end();
  15. });
  16. test('throws if varEqual is not a boolean', function (t) {
  17. t.throws(() => ttest([0, 1, 2], { varEqual: 'string' }), {
  18. message: 'varEqual option must be a boolean'
  19. });
  20. t.end();
  21. });
  22. test('throws if alpha is not a number or out of range', function (t) {
  23. t.throws(() => ttest([0, 1, 2], { alpha: 'string' }), {
  24. message: 'alpha option must be a number'
  25. });
  26. t.throws(() => ttest([0, 1, 2], { alpha: 1 }), {
  27. message: 'alpha must be below 1.0'
  28. });
  29. t.end();
  30. });
  31. test('throws if alternative is wrong', function (t) {
  32. t.throws(() => ttest([0, 1, 2], { alternative: 'bigger' }), {
  33. message: 'alternative must be either "not equal", "less" or "greater"'
  34. });
  35. t.end();
  36. });