Avoid false positives

As written, the test for `Math.random` would pass if the runtime
erroneously produced a non-numeric value. Add the necessary assertions
to guard against this case.
This commit is contained in:
Mike Pennisi 2016-03-17 17:08:29 -04:00
parent b1c979d391
commit 6e61c27aa5
1 changed files with 6 additions and 0 deletions

View File

@ -15,6 +15,12 @@ description: >
for (var i = 0; i < 100; i++)
{
var val = Math.random();
assert.sameValue(
typeof val, 'number', 'should not produce a non-numeric value: ' + val
);
assert.notSameValue(val, NaN, 'should not produce NaN');
if (val < 0 || val >= 1)
{
$ERROR("#1: Math.random() = " + val);