1.0.20 • Published 7 years ago
@kingjs/assert-theory v1.0.20
@kingjs/assert-theory
Assert that a theory is true for a combination of observations.
Usage
Assert that addition and multiplication are commutative operations for a combination of 3 whole numbers and 3 fractions like this:
var testTheory = require('@kingjs/assert-theory');
var assert = require('@kingjs/assert');
var id = 0;
testTheory(function(o, i) {
assert(id++ == i);
var naturalFirst = eval(o.natural + o.op + o.fraction);
var fractionFirst = eval(o.fraction + o.op + o.natural);
assert(naturalFirst == fractionFirst);
}, {
op: [ '+', '*' ],
natural: [1, 2, 3],
fraction: [.1, .2, .3],
});
assert(id == 3 * 3 * 2); // = 18API
declare function testTheory(
theory: (
this,
observation,
i
) => void,
observations: { [index: string]: any },
runId?: number
);Parameters
theory: A function that tests a set of observations.this: Theobservations.observation: The observation generated fromdata.id: The number identifyingobservation.
observations: A descriptor whose every property contains either an array, primitive, or object from which a sequence of similar descriptors is generated where each property is replaced with an array element, the primitive, or a property value respectively.runId: If present, runs only the observation with the givenid.
Remarks
If an observation fails then it can be easily debugged by supplying runId. If runId is specified an exception is still thrown after the test pass to ensure that the runId is removed.
Install
With npm installed, run
$ npm install @kingjs/assert-theoryAcknowledgments
Like nUnit TheoryAttribute.
License
MIT
1.0.20
7 years ago
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago