From: Jean-Sebastien Gelinas Date: Tue, 7 Jul 2009 19:24:56 +0000 (-0400) Subject: tests: change 'rand' test for better portability X-Git-Tag: v0.3~170 X-Git-Url: http://nitlanguage.org?ds=sidebyside tests: change 'rand' test for better portability Signed-off-by: Jean-Sebastien Gelinas Signed-off-by: Jean Privat --- diff --git a/tests/sav/test_math.sav b/tests/sav/test_math.sav index 6c34cda..fca4b99 100644 --- a/tests/sav/test_math.sav +++ b/tests/sav/test_math.sav @@ -13,4 +13,3 @@ 0.100000 0.100000 0.100000 -0, 0.0, 0, 0.80030, 0, 0.159289, 0, 1.345366, 1, 3.576007, 0, 1.373251, 5, 1.327668, 2, 1.792959, 2, 2.174776, 3, 2.306186, 3, 4.612696, \ No newline at end of file diff --git a/tests/test_math.nit b/tests/test_math.nit index 3f5dac0..8b9639d 100644 --- a/tests/test_math.nit +++ b/tests/test_math.nit @@ -1,6 +1,7 @@ # This file is part of NIT ( http://www.nitlanguage.org ). # # Copyright 2005-2008 Jean Privat +# Copyright 2009 Jean-Sebastien Gelinas # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,7 +35,12 @@ print(0.1.sin.asin.sin.asin) print(0.1.tan.atan.tan.atan) print(0.1.exp.log.exp.log) -for i in [0..10] do - printn(i.rand, ", ", i.to_f.rand, ", ") +var random_int: Int +var random_float: Float +for i in [0..100] do + random_int = 1.rand + random_float = 1.0.rand + if random_int > 1 or random_int < 0 then print "Erroneous random int" + if random_float > 1.0 or random_float < 0.0 then print "Erroneous random float" end