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
actual
number equality.For most parts it asserts strict equality (
===
), but:- Number value are compared to number literals.
ParametersName Type Description expected mixedExpected number
ReturnsType Description ObjectThe current instance
test.number(2).is(2);
See also -
isNot(expected)
-
Assert
actual
number to the negative equality.Also handles circular and self-referential objects.
ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test .number(2) .isNot(3) .isNot('2') .isNot(2.1) ;
See also -
isIdenticalTo(expected)
-
Assert that the
actual
number is identical to (===
)expected
number.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.number(1).isIdenticalTo(1);
See also -
isNotIdenticalTo(expected)
-
Assert that the
actual
number is not identical to (!==
)expected
number.ParametersName Type Description expected mixedExpected number
ReturnsType Description ObjectThe current instance
test .number(2) .isNotIdenticalTo(3) .isNotIdenticalTo('2') .isNotIdenticalTo(2.1) .isNotIdenticalTo(0.2) ;
See also -
isEqualTo(expected)
-
Assert that the
actual
number is equal to (==
) theexpected
number.ParametersName Type Description expected mixedExpected number
ReturnsType Description ObjectThe current instance
test .number(1) .isEqualTo(1) .isEqualTo('1') ;
See also -
isNotEqualTo(expected)
-
Assert that the
actual
number is not equal to (!=
) theexpected
number.ParametersName Type Description expected mixedExpected number
ReturnsType Description ObjectThe current instance
test.number(2).isNotEqualTo(3);
See also -
match(expected)
-
Assert
actual
number to match theexpected
value.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ReturnsType 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
actual
number to not match theexpected
value.ParametersName Type Description expected StringNumberRegExpfunctionExpected value that must not match
ReturnsType 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
ReturnsType 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
ReturnsType 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
actual
number to match eachexpected
value.ParametersName Type Description expected ArrayStringNumberRegExpfunctionExpected matches for each
ReturnsType Description ObjectThe current instance
test .number(2014) .matchEach([2, 4, 1, 0]) .matchEach([2014, function(it){ return it === 2014; }]) ;
See also -
notMatchEach(expected)
-
Assert
actual
number to not match one or severalexpected
value.ParametersName Type Description expected ArrayStringNumberRegExpfunctionExpected value that must not match
ReturnsType 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
actual
number is betweenbegin
andend
(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ReturnsType 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
actual
number is not betweenbegin
andend
(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ReturnsType 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
actual
number is before theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.number(1).isBefore(2);
See also -
isAfter(expected)
-
Alias of
isGreaterThan()
.Assert that the
actual
number is after theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.number(2).isAfter(1);
See also -
isLessThan(expected)
-
Assert that the
actual
number is lesser than theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.number(1).isLessThan(2);
See also -
isGreaterThan(expected)
-
Assert that the
actual
number is greater than theexpected
value.ParametersName Type Description expected mixedExpected value
ReturnsType Description ObjectThe current instance
test.number(2).isGreaterThan(1);
See also -
isApprox(num, delta)
-
Assert that the
actual
number (floating point number) nearnum
withindelta
margin.ParametersName Type Description num numberExpected number
delta numberMargin accepted around
num
ReturnsType Description ObjectThe current instance
test.number(99.98).isApprox(100, 0.02);
See also -
isInfinite()
-
Assert that the
actual
number isinfinite
.ReturnsType Description ObjectThe current instance
test.number(1/0).isInfinite();
See also -
isNotInfinite()
-
Assert that the
actual
number is notinfinite
.ReturnsType Description ObjectThe current instance
test.number(1.33333).isNotInfinite();
See also -
isNaN()
-
Assert that the
actual
number isNaN
.ReturnsType 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
actual
number is notNaN
.ReturnsType Description ObjectThe current instance
test.number(0).isNotNaN();
See also