[gnome-calculator] Fix tests for zero to the power zero.



commit 8615b38e9270fa8001fb60df49b9df7d5acffc20
Author: PioneerAxon <arth svnit gmail com>
Date:   Mon Feb 24 23:14:58 2014 +0530

    Fix tests for zero to the power zero.

 src/test-equation.vala |    3 ++-
 src/test-number.vala   |    8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/test-equation.vala b/src/test-equation.vala
index 480dbba..8ff292a 100644
--- a/src/test-equation.vala
+++ b/src/test-equation.vala
@@ -369,7 +369,8 @@ private void test_equations ()
     test ("(x)²", "4", 0);
     test ("|1−3|²", "4", 0);
     test ("|x|²", "4", 0);
-    test ("0^0", "1", 0);
+    /* Note: 0^0 is indeterminate. Hence will return 0, with error set. */
+    test ("0^0", "0", ErrorCode.MP);
     test ("0^0.5", "0", 0);
     test ("2^0", "1", 0);
     test ("2^1", "2", 0);
diff --git a/src/test-number.vala b/src/test-number.vala
index 5c5da62..b94535b 100644
--- a/src/test-number.vala
+++ b/src/test-number.vala
@@ -496,8 +496,8 @@ private void test_xpowy ()
             var expected = 1.0;
             if (a == 0)
             {
-                if (b != 0)
-                    expected = 0.0;
+                /* Note: 0^0 is indeterminate. Hence will return 0, with error set. */
+                expected = 0.0;
             }
             else
             {
@@ -530,8 +530,8 @@ private void test_xpowy_integer ()
             var expected = 1.0;
             if (a == 0)
             {
-                if (b != 0)
-                    expected = 0.0;
+                /* Note: 0^0 is indeterminate. Hence will return 0, with error set. */
+                expected = 0.0;
             }
             else
             {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]