← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-power-withnegative-number into lp:ubuntu-calculator-app

 

Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-power-withnegative-number into lp:ubuntu-calculator-app.

Commit message:
Allow use power function with negative numbers.


Requested reviews:
  Ubuntu Calculator Developers (ubuntu-calculator-dev)

For more details, see:
https://code.launchpad.net/~gang65/ubuntu-calculator-app/ubuntu-calculator-app-power-withnegative-number/+merge/278082

Allow use power function with negative numbers.

-- 
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-power-withnegative-number into lp:ubuntu-calculator-app.
=== modified file 'app/engine/formula.js'
--- app/engine/formula.js	2015-06-21 15:57:45 +0000
+++ app/engine/formula.js	2015-11-19 21:57:26 +0000
@@ -202,9 +202,10 @@
 function couldAddOperator(formulaToCheck, operatorToAdd) {
     // No two operators one after other, except factorial operator
     if (isOperator(formulaToCheck.slice(-1)) && formulaToCheck.slice(-1) !== "!") {
-        // But a minus after a * or a / is allowed
-        if (!(operatorToAdd === "-" && (formulaToCheck.slice(-1) === "*" ||
-                                        formulaToCheck.slice(-1) === "/"))) {
+        // But a minus after every operator except + and - is allowed
+        if (!(operatorToAdd === "-" && 
+              formulaToCheck.slice(-1) !== "+" &&
+              formulaToCheck.slice(-1) !== "-")) {
             return false;
         }
     }

=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
--- tests/autopilot/ubuntu_calculator_app/tests/test_main.py	2015-07-10 21:07:19 +0000
+++ tests/autopilot/ubuntu_calculator_app/tests/test_main.py	2015-11-19 21:57:26 +0000
@@ -272,10 +272,10 @@
         self.app.main_view.show_scientific_keyboard()
         self.app.main_view.press('power')
         self.app.main_view.hide_scientific_keyboard()
-        self.app.main_view.insert('4=')
+        self.app.main_view.insert('-4=')
 
-        self._assert_result_is(u'16')
-        self._assert_history_contains(u'2^4=16')
+        self._assert_result_is(u'0.0625')
+        self._assert_history_contains(u'2^−4=0.0625')
 
     def test_loge(self):
         self.app.main_view.show_scientific_keyboard()


Follow ups