ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #00658
[Merge] lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-complex-number-validation into lp:ubuntu-calculator-app/reboot
Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-complex-number-validation into lp:ubuntu-calculator-app/reboot.
Commit message:
Add complex numbers validation
Requested reviews:
Ubuntu Calculator Developers (ubuntu-calculator-dev)
For more details, see:
https://code.launchpad.net/~gang65/ubuntu-calculator-app/ubuntu-calculator-complex-number-validation/+merge/252824
Add complex numbers validation
--
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-complex-number-validation into lp:ubuntu-calculator-app/reboot.
=== modified file 'app/engine/formula.js'
--- app/engine/formula.js 2015-03-06 21:13:52 +0000
+++ app/engine/formula.js 2015-03-12 21:23:49 +0000
@@ -96,6 +96,12 @@
return couldAddCloseBracket(formula);
}
+ // Validate complex numbers
+ if ((stringToAddToFormula === "i") || (!isNaN(stringToAddToFormula))){
+ if (formula.slice(-1) === "i") {
+ return false;
+ }
+ }
return true;
}
@@ -159,7 +165,8 @@
'NaN': i18n.tr("NaN"),
'E': 'ℯ',
'Infinity': '∞',
- '"': ''
+ '"': '',
+ ' ': ''
}
if (engineFormulaToConvert !== undefined) {
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/__init__.py'
--- app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-03-03 20:31:14 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-03-12 21:23:49 +0000
@@ -75,7 +75,7 @@
'9': 'nineButton', 'bracket': 'universalBracketButton',
'square': 'squareButton', 'cube': 'cubeButton',
'power': 'powerButton', 'log': 'logarithmButton',
- 'e': 'eNumberButton', '!': 'factorialNumberButton',
+ 'i': 'iButton', 'e': 'eNumberButton', '!': 'factorialNumberButton',
'sin': 'sinusButton', 'cos': 'cosButton'}
def __init__(self, *args):
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
--- app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-03-09 19:52:25 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-03-12 21:23:49 +0000
@@ -242,6 +242,25 @@
self._assert_result_is(u'1')
self._assert_history_contains(u'cos(0)=1')
+
+ def test_complex_numbers(self):
+ self.app.main_view.insert('66')
+ self.app.main_view.show_scientific_keyboard()
+ self.app.main_view.press('i')
+ self.app.main_view.hide_scientific_keyboard()
+ self.app.main_view.insert('*')
+ self.app.main_view.show_scientific_keyboard()
+ self.app.main_view.press('i')
+ self.app.main_view.press('i')
+ self.app.main_view.press('i')
+ self._assert_result_is(u'66i×i')
+ self.app.main_view.hide_scientific_keyboard()
+ self.app.main_view.insert('33=')
+ self._assert_result_is(u'−66')
+ self._assert_history_contains(u'66i×i=−66')
+
+
+
def _assert_result_is(self, value):
self.assertThat(self.app.main_view.get_result,
Eventually(Equals(value)))
=== modified file 'app/ui/LandscapeKeyboard.qml'
--- app/ui/LandscapeKeyboard.qml 2015-03-06 21:13:52 +0000
+++ app/ui/LandscapeKeyboard.qml 2015-03-12 21:23:49 +0000
@@ -45,7 +45,7 @@
{ number: 0, name: "zero", textColor: "#DD4814", forceNumber: true },
{ text: "( )", name: "universalBracket", pushText: "()", textColor: "#DD4814" },
{ text: "=", name: "equals", action: "calculate", kbdKeys: [Qt.Key_Enter, Qt.Key_Return] },
- { text: "abs", name: "abs", pushText: "abs(", kbdKeys: [Qt.Key_A] },
+ { text: "|x|", name: "abs", pushText: "abs(", kbdKeys: [Qt.Key_A] },
{ text: "sin⁻¹", name: "arcsinus", pushText: "asin(" },
{ text: "cos⁻¹", name: "arccos", pushText: "acos(" },
{ text: "tan⁻¹", name: "arctangens", pushText: "atan(" }
=== modified file 'app/ui/PortraitKeyboard.qml'
--- app/ui/PortraitKeyboard.qml 2015-03-06 21:13:52 +0000
+++ app/ui/PortraitKeyboard.qml 2015-03-12 21:23:49 +0000
@@ -52,7 +52,7 @@
{ text: "sin", name: "sinus", pushText: "sin(", kbdKeys: [Qt.Key_S] },
{ text: "cos", name: "cos", pushText: "cos(", kbdKeys: [Qt.Key_C] },
{ text: "tan", name: "tangens", pushText: "tan(", kbdKeys: [Qt.Key_T] },
- { text: "abs", name: "abs", pushText: "abs(", kbdKeys: [Qt.Key_A] },
+ { text: "|x|", name: "abs", pushText: "abs(", kbdKeys: [Qt.Key_A] },
{ text: "sin⁻¹", name: "arcsinus", pushText: "asin(" },
{ text: "cos⁻¹", name: "arccos", pushText: "acos(" },
{ text: "tan⁻¹", name: "arctangens", pushText: "atan(" }
=== modified file 'app/ui/Screen.qml'
--- app/ui/Screen.qml 2015-03-06 21:13:52 +0000
+++ app/ui/Screen.qml 2015-03-12 21:23:49 +0000
@@ -102,7 +102,7 @@
anchors.bottom: formula.bottom
color: UbuntuColors.darkGrey
- text: Formula.returnFormulaToDisplay((mathJs.format(model.result)))
+ text: isNaN(model.result) ? Formula.returnFormulaToDisplay(model.result) : Formula.returnFormulaToDisplay(mathJs.format(model.result))
font.pixelSize: units.gu(3.5)
lineHeight: units.gu(2)
lineHeightMode: Text.FixedHeight
=== modified file 'po/com.ubuntu.calculator.pot'
--- po/com.ubuntu.calculator.pot 2015-03-06 21:13:52 +0000
+++ po/com.ubuntu.calculator.pot 2015-03-12 21:23:49 +0000
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-03-06 22:13+0100\n"
+"POT-Creation-Date: 2015-03-12 22:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -17,7 +17,7 @@
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../app/engine/formula.js:159
+#: ../app/engine/formula.js:165
msgid "NaN"
msgstr ""
@@ -91,14 +91,14 @@
msgid "Yesterday"
msgstr ""
-#: /tmp/tmp.UV9NB7uRBM/po/ubuntu-calculator-app.desktop.in.in.h:1
+#: /tmp/tmp.7jdJ8Z0KGE/po/ubuntu-calculator-app.desktop.in.in.h:1
msgid "Calculator"
msgstr ""
-#: /tmp/tmp.UV9NB7uRBM/po/ubuntu-calculator-app.desktop.in.in.h:2
+#: /tmp/tmp.7jdJ8Z0KGE/po/ubuntu-calculator-app.desktop.in.in.h:2
msgid "A calculator for Ubuntu."
msgstr ""
-#: /tmp/tmp.UV9NB7uRBM/po/ubuntu-calculator-app.desktop.in.in.h:3
+#: /tmp/tmp.7jdJ8Z0KGE/po/ubuntu-calculator-app.desktop.in.in.h:3
msgid "math;addition;subtraction;multiplication;division;"
msgstr ""
Follow ups