diff options
| author | OpportunityLiu <[email protected]> | 2019-07-26 09:49:50 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-28 14:45:00 +0800 |
| commit | e9902d526b04319bb73dddabab17c5e339dba99a (patch) | |
| tree | 4887494a4a79c1f70fde3ed30a78624a36a40211 /tests/modules/math/test.lua | |
| parent | 6ab8bfb5c53c05ac7812efc2c8ef46f675211526 (diff) | |
add unit test for math
Diffstat (limited to 'tests/modules/math/test.lua')
| -rw-r--r-- | tests/modules/math/test.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/modules/math/test.lua b/tests/modules/math/test.lua new file mode 100644 index 000000000..3d05adb61 --- /dev/null +++ b/tests/modules/math/test.lua @@ -0,0 +1,34 @@ +function test_isinf(t) + t:will_raise(function() math.isinf(nil) end) + t:will_raise(function() math.isinf(true) end) + + t:require_not(math.isinf(0)) + t:require_not(math.isinf(math.nan)) + t:are_same(math.isinf(math.huge), 1) + t:are_same(math.isinf(-math.huge), -1) +end + +function test_isnan(t) + t:will_raise(function() math.isinf(nil) end) + t:will_raise(function() math.isinf(true) end) + + t:require_not(math.isnan(0)) + t:require(math.isnan(math.nan)) + t:require_not(math.isnan(math.huge)) + t:require_not(math.isnan(-math.huge)) +end + +function test_isint(t) + t:will_raise(function() math.isint(nil) end) + t:will_raise(function() math.isint(true) end) + + t:require(math.isint(0)) + t:require(math.isint(-10)) + t:require(math.isint(123456)) + t:require_not(math.isint(123456.1)) + t:require_not(math.isint(-9.99)) + t:require_not(math.isint(math.nan)) + t:require_not(math.isint(math.huge)) + t:require_not(math.isint(-math.huge)) +end + |
