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 11"use strict" ;
22
33exports . intDegree = function ( x ) {
4- return Math . abs ( x ) ;
4+ return Math . min ( Math . abs ( x ) , 2147483647 ) ;
55} ;
66
77exports . intDiv = function ( x ) {
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ main :: AlmostEff
88main = do
99 testNumberShow show
1010 testOrderings
11+ testIntDegree
1112
1213foreign import testNumberShow :: (Number -> String ) -> AlmostEff
1314foreign import throwErr :: String -> AlmostEff
@@ -71,3 +72,10 @@ testOrderings = do
7172 testOrd [1 , 1 ] [1 , 0 ] GT
7273 testOrd [1 , -1 ] [1 , 0 ] LT
7374
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