Number asserter.
Assert that the actual value is a number (using .isNumber() assertion).
The number() asserter provides adapted assertions for works on a number.
See also the spec of "number" asserter for more examples.
Example
test.number(actual);
Methods
-
is(expected)
-
Assert
actualnumber equality.For most parts it asserts strict equality (
===), but:- Number value are compared to number literals.
ParametersName Type Description expected mixedExpected number
ExampleReturnsType Description ObjectThe current instance
test.number(2).is(2);
See also -
isNot(expected)
-
Assert
actualnumber to the negative equality.Also handles circular and self-referential objects.
ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test .number(2) .isNot(3) .isNot('2') .isNot(2.1) ;
See also -
isIdenticalTo(expected)
-
Assert that the
actualnumber is identical to (===)expectednumber.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.number(1).isIdenticalTo(1);
See also -
isNotIdenticalTo(expected)
-
Assert that the
actualnumber is not identical to (!==)expectednumber.ParametersName Type Description expected mixedExpected number
ExampleReturnsType Description ObjectThe current instance
test .number(2) .isNotIdenticalTo(3) .isNotIdenticalTo('2') .isNotIdenticalTo(2.1) .isNotIdenticalTo(0.2) ;
See also -
isEqualTo(expected)
-
Assert that the
actualnumber is equal to (==) theexpectednumber.ParametersName Type Description expected mixedExpected number
ExampleReturnsType Description ObjectThe current instance
test .number(1) .isEqualTo(1) .isEqualTo('1') ;
See also -
isNotEqualTo(expected)
-
Assert that the
actualnumber is not equal to (!=) theexpectednumber.ParametersName Type Description expected mixedExpected number
ExampleReturnsType Description ObjectThe current instance
test.number(2).isNotEqualTo(3);
See also -
match(expected)
-
Assert
actualnumber to match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test // Assert with a RegExp .number(2014).match(/20+[1-4]/) // Assert with a number converted to RegExp .number(2014).match(201) // Assert with a function .number(2014).match(function(it){ return it === 2014; }) ;
See also -
notMatch(expected)
-
Assert
actualnumber to not match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected value that must not match
ExampleReturnsType Description ObjectThe current instance
test // Assert with a RegExp .number(2014) .notMatch(/20+[5-6]/) .notMatch(/[a-z]/) // Assert with a number converted to RegExp .number(10) .notMatch(8) // Assert with a function .number(10) .notMatch(function(it){ return it === 42; }) ;
See also -
isValid(expected)
-
Alias of
match().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test // Assert with a RegExp .number(2014).isValid(/20+[1-4]/) // Assert with a number converted to RegExp .number(2014).isValid(201) // Assert with a function .number(2014).isValid(function(it){ return it === 2014; }) ;
See also -
isNotValid(expected)
-
Alias of
notMatch().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test // Assert with a RegExp .number(2014) .isNotValid(/20+[5-6]/) .isNotValid(/[a-z]/) // Assert with a number converted to RegExp .number(10) .isNotValid(8) // Assert with a function .number(10) .isNotValid(function(it){ return it === 42; }) ;
See also -
matchEach(expected)
-
Assert
actualnumber to match eachexpectedvalue.ParametersName Type Description expected ArrayStringNumberRegExpfunctionExpected matches for each
ExampleReturnsType Description ObjectThe current instance
test .number(2014) .matchEach([2, 4, 1, 0]) .matchEach([2014, function(it){ return it === 2014; }]) ;
See also -
notMatchEach(expected)
-
Assert
actualnumber to not match one or severalexpectedvalue.ParametersName Type Description expected ArrayStringNumberRegExpfunctionExpected value that must not match
ExampleReturnsType Description ObjectThe current instance
test .number(2014) .notMatchEach([3, 200]) .notMatchEach([2012, function(it){ return it !== 2014; }]) ;
See also -
isBetween(begin, end)
-
Assert that the
actualnumber is betweenbeginandend(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ExampleReturnsType Description ObjectThe current instance
test .number(2) .isBetween(2, 4) .number(3) .isBetween(2, 4) .number(4) .isBetween(2, 4) ;
See also -
isNotBetween(begin, end)
-
Assert that the
actualnumber is not betweenbeginandend(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ExampleReturnsType Description ObjectThe current instance
test .number(1) .isNotBetween(2, 4) .number(5) .isNotBetween(2, 4) ;
See also -
isBefore(expected)
-
Alias of
isLessThan().Assert that the
actualnumber is before theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.number(1).isBefore(2);
See also -
isAfter(expected)
-
Alias of
isGreaterThan().Assert that the
actualnumber is after theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.number(2).isAfter(1);
See also -
isLessThan(expected)
-
Assert that the
actualnumber is lesser than theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.number(1).isLessThan(2);
See also -
isGreaterThan(expected)
-
Assert that the
actualnumber is greater than theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.number(2).isGreaterThan(1);
See also -
isApprox(num, delta)
-
Assert that the
actualnumber (floating point number) nearnumwithindeltamargin.ParametersName Type Description num numberExpected number
delta numberMargin accepted around
numExampleReturnsType Description ObjectThe current instance
test.number(99.98).isApprox(100, 0.02);
See also -
isInfinite()
-
Assert that the
actualnumber isinfinite.ExampleReturnsType Description ObjectThe current instance
test.number(1/0).isInfinite();
See also -
isNotInfinite()
-
Assert that the
actualnumber is notinfinite.ExampleReturnsType Description ObjectThe current instance
test.number(1.33333).isNotInfinite();
See also -
isNaN()
-
Assert that the
actualnumber isNaN.ExampleReturnsType Description ObjectThe current instance
test.number(0/0).isNaN(); test.number(parseInt('foo', 10)).isNaN(); test.number(NaN).isNaN();
See also -
isNotNaN()
-
Assert that the
actualnumber is notNaN.ExampleReturnsType Description ObjectThe current instance
test.number(0).isNotNaN();
See also

