File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
3
3
exports . intDegree = function ( x ) {
4
- return Math . abs ( x ) ;
4
+ return Math . min ( Math . abs ( x ) , 2147483647 ) ;
5
5
} ;
6
6
7
7
exports . intDiv = function ( x ) {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ main :: AlmostEff
8
8
main = do
9
9
testNumberShow show
10
10
testOrderings
11
+ testIntDegree
11
12
12
13
foreign import testNumberShow :: (Number -> String ) -> AlmostEff
13
14
foreign import throwErr :: String -> AlmostEff
@@ -71,3 +72,10 @@ testOrderings = do
71
72
testOrd [1 , 1 ] [1 , 0 ] GT
72
73
testOrd [1 , -1 ] [1 , 0 ] LT
73
74
75
+ testIntDegree :: AlmostEff
76
+ testIntDegree = do
77
+ let bot = bottom :: Int
78
+ assert " degree returns absolute integers" $ degree (-4 ) == 4
79
+ assert " degree returns absolute integers" $ degree 4 == 4
80
+ assert " degree returns absolute integers" $ degree bot >= 0
81
+ assert " degree does not return out-of-bounds integers" $ degree bot <= top
You can’t perform that action at this time.
0 commit comments