[svn] r6595: nemerle/trunk: macros/Util.n
ncc/testsuite/positive/list-compr.n
dragonfox
svnadmin at nemerle.org
Wed Aug 30 18:45:45 CEST 2006
Log:
Fix list comprehension for floats: $[1.0 .. 2.9]
Author: dragonfox
Date: Wed Aug 30 18:45:31 2006
New Revision: 6595
Modified:
nemerle/trunk/macros/Util.n
nemerle/trunk/ncc/testsuite/positive/list-compr.n
Modified: nemerle/trunk/macros/Util.n
==============================================================================
--- nemerle/trunk/macros/Util.n (original)
+++ nemerle/trunk/macros/Util.n Wed Aug 30 18:45:31 2006
@@ -313,9 +313,15 @@
mutable i = $first;
def last = $last;
mutable cond = i <= last;
+ mutable pre_last = last;
+ unchecked (pre_last--); // can't use (last - 1) since 1 might change/widen type
+ def overflowed = pre_last > last;
while (cond) {
def $pat = i;
- cond = i < last;
+ if (overflowed)
+ cond = i >= pre_last;
+ else
+ cond = i <= pre_last;
unchecked (i++);
$acc;
}
Modified: nemerle/trunk/ncc/testsuite/positive/list-compr.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/list-compr.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/list-compr.n Wed Aug 30 18:45:31 2006
@@ -57,6 +57,13 @@
foreach (i in $[int.MinValue,int.MinValue+1 .. int.MinValue])
System.Console.WriteLine (i);
+// because we deal with floats it should not depend on national formatting
+System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+
+System.Console.WriteLine ("--");
+foreach (f in $[1.0 .. 2.9])
+ System.Console.WriteLine (f);
+
/*
BEGIN-OUTPUT
[(2, 1), (3, 1), (3, 2)]
@@ -116,5 +123,8 @@
2147483646
--
-2147483648
+--
+1
+2
END-OUTPUT
*/
More information about the svn
mailing list