Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

View file

@ -0,0 +1,14 @@
import Math.{addExact => ++, multiplyExact => **, negateExact => ~~, subtractExact => --}
def requireOverflow(f: => Unit) =
try {f; println("Undetected overflow")} catch{case e: Exception => /* caught */}
println("Testing overflow detection for 32-bit unsigned integers")
requireOverflow(~~(--(~~(2147483647), 1))) // -(-2147483647-1)
requireOverflow(++(2000000000, 2000000000)) // 2000000000 + 2000000000
requireOverflow(--(~~(2147483647), 2147483647)) // -2147483647 + 2147483647
requireOverflow(**(46341, 46341)) // 46341 * 46341
requireOverflow(**(--(~~(2147483647),1), -1)) // same as (-2147483647-1) / -1
println("Test - Expect Undetected overflow:")
requireOverflow(++(1,1)) // Undetected overflow