Merge lp:~f-riccardo87/ubuntu-calculator-app/calculation-results into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Riccardo Ferrazzo
Status: Merged
Approved by: Dalius
Approved revision: 38
Merged at revision: 36
Proposed branch: lp:~f-riccardo87/ubuntu-calculator-app/calculation-results
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 61 lines (+15/-4)
2 files modified
Simple/SimplePage.qml (+15/-3)
engine.js (+0/-1)
To merge this branch: bzr merge lp:~f-riccardo87/ubuntu-calculator-app/calculation-results
Reviewer Review Type Date Requested Status
Dalius (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+155003@code.launchpad.net

Commit message

Pressing equals more times repeat the last operation

Description of the change

Pressing equals more times repeat the last operation (using the result as the first operand).

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dalius (dalius-sandbox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Simple/SimplePage.qml'
2--- Simple/SimplePage.qml 2013-03-20 16:28:57 +0000
3+++ Simple/SimplePage.qml 2013-03-22 16:16:24 +0000
4@@ -16,6 +16,7 @@
5 if(engineFormula.length === 0){
6 engineFormula.push('');
7 }
8+ if(screenFormula[screenFormula.length-1]._operation === "=") return;
9 try{
10 var n_scanner = new CALC.Scanner(engineFormula.join('') + engine, context);
11 } catch(exception) {
12@@ -50,6 +51,7 @@
13 }
14
15 function changeSign(){
16+ if(screenFormula[screenFormula.length-1]._operation === "=") return;
17 var prev_tokens = [];
18 var add_minus = true;
19 screenFormula.pop();
20@@ -98,9 +100,14 @@
21 }
22
23 function calculate() {
24- var result = 0;
25+ if(screenFormula[screenFormula.length-1]._operation === "="){
26+ var lastOperation = engineFormula.pop();
27+ var previousResult = screenFormula[screenFormula.length-1]._number
28+ engineFormula = [previousResult, lastOperation];
29+ scanner = new CALC.Scanner(engineFormula.join(""), context);
30+ }
31 try{
32- result = new CALC.Parser(scanner).reduce(context);
33+ var result = new CALC.Parser(scanner).reduce(context);
34 if (result === Number.POSITIVE_INFINITY)
35 result = '∞';
36 else if (result === Number.NEGATIVE_INFINITY)
37@@ -108,7 +115,12 @@
38 } catch(exception) {
39 if(exception instanceof CALC.DivisionByZeroError){
40 result = "division by zero error";
41- } else if(exception instanceof SyntaxError){
42+ } else{
43+ console.log(screenFormula, engineFormula);
44+ screenFormula.pop();
45+ engineFormula.pop();
46+ scanner = new CALC.Scanner(engineFormula.join(''), context);
47+ calculate();
48 return;
49 }
50 }
51
52=== modified file 'engine.js'
53--- engine.js 2013-03-18 15:39:31 +0000
54+++ engine.js 2013-03-22 16:16:24 +0000
55@@ -523,7 +523,6 @@
56
57 // If there are more values in the stack
58 // (Error) The user input has too many values.
59- console.log(this.queue.length)
60 throw new Error('runtime error: too many values');
61 },
62

Subscribers

People subscribed via source and target branches