summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar qunyanm <unknown>2016-04-01 14:36:56 -0700
committerGravatar qunyanm <unknown>2016-04-01 14:36:56 -0700
commit074172a069d77888f232d44660b72e07579296ae (patch)
tree168f2f345b4844c87a6d5bdfba39a3d6cc7a0fca
parent31b0c4345b02b2314ca92a032ce90fbfdf66d1e8 (diff)
Fix issue 148. The results for sign comparison for BigRational.CompareTo was
wrong.
-rw-r--r--Binaries/DafnyRuntime.cs8
-rw-r--r--Test/dafny4/Bug148.dfy25
-rw-r--r--Test/dafny4/Bug148.dfy.expect17
3 files changed, 46 insertions, 4 deletions
diff --git a/Binaries/DafnyRuntime.cs b/Binaries/DafnyRuntime.cs
index 3002d832..587d5159 100644
--- a/Binaries/DafnyRuntime.cs
+++ b/Binaries/DafnyRuntime.cs
@@ -1253,13 +1253,13 @@ namespace Dafny
int asign = this.num.Sign;
int bsign = that.num.Sign;
if (asign < 0 && 0 <= bsign) {
- return 1;
+ return -1;
} else if (asign <= 0 && 0 < bsign) {
- return 1;
- } else if (bsign < 0 && 0 <= asign) {
return -1;
+ } else if (bsign < 0 && 0 <= asign) {
+ return 1;
} else if (bsign <= 0 && 0 < asign) {
- return -1;
+ return 1;
}
BigInteger aa, bb, dd;
Normalize(this, that, out aa, out bb, out dd);
diff --git a/Test/dafny4/Bug148.dfy b/Test/dafny4/Bug148.dfy
new file mode 100644
index 00000000..b7a08952
--- /dev/null
+++ b/Test/dafny4/Bug148.dfy
@@ -0,0 +1,25 @@
+// RUN: %dafny /compile:3 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+method Main()
+{
+ var zero : real := 0.0;
+ var three : real := 3.0;
+ var fifteen : real := 15.0;
+ var negone : real := -1.0;
+ var negthree : real := -3.0;
+
+ print zero <= fifteen, "\n"; // true
+ print fifteen <= zero, "\n"; // false
+ print negone <= zero, "\n"; // true
+ print zero <= negone, "\n"; // false
+ print negone <= fifteen, "\n"; // true
+ print fifteen <= negone, "\n"; // false
+
+ print zero >= fifteen, "\n"; // false
+ print fifteen >= zero, "\n"; // true
+ print negone >= zero, "\n"; // false
+ print zero >= negone, "\n"; // true
+ print negone >= fifteen, "\n"; // false
+ print fifteen >= negone, "\n"; // true
+}
diff --git a/Test/dafny4/Bug148.dfy.expect b/Test/dafny4/Bug148.dfy.expect
new file mode 100644
index 00000000..7acfb169
--- /dev/null
+++ b/Test/dafny4/Bug148.dfy.expect
@@ -0,0 +1,17 @@
+
+Dafny program verifier finished with 2 verified, 0 errors
+Program compiled successfully
+Running...
+
+True
+False
+True
+False
+True
+False
+False
+True
+False
+True
+False
+True