From 643752e282be822f3e5fab7153f7ae4c5b352e15 Mon Sep 17 00:00:00 2001 From: Jean-Sebastien Gelinas Date: Tue, 7 Jul 2009 15:24:56 -0400 Subject: [PATCH] tests: change 'rand' test for better portability Signed-off-by: Jean-Sebastien Gelinas Signed-off-by: Jean Privat --- tests/sav/test_math.sav | 1 - tests/test_math.nit | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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 -- 1.7.9.5