equals.js 955 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. function equals(t, actual, expected) {
  3. t.strictEqual(actual.valid(), expected.valid, 'valid result match');
  4. t.equal(actual.freedom(), expected.freedom, 'degree of freedom match');
  5. match(t, actual.testValue(), expected.testValue, 'test value');
  6. match(t, actual.pValue(), expected.pValue, 'p-value');
  7. if (Number.isFinite(expected.confidence[0])) {
  8. match(t, actual.confidence()[0], expected.confidence[0], 'left confidence');
  9. } else {
  10. t.equal(actual.confidence()[0], expected.confidence[0], 'left confidence match');
  11. }
  12. if (Number.isFinite(expected.confidence[1])) {
  13. match(t, actual.confidence()[1], expected.confidence[1], 'right confidence');
  14. } else {
  15. t.equal(actual.confidence()[1], expected.confidence[1], 'right confidence match');
  16. }
  17. }
  18. module.exports = equals;
  19. function match(t, actual, expected, name) {
  20. t.ok(Math.abs(actual - expected) <= 0.0000005, `${name} ${actual} match ${expected}`);
  21. }