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
=== modified file 'Simple/SimplePage.qml'
--- Simple/SimplePage.qml 2013-03-20 16:28:57 +0000
+++ Simple/SimplePage.qml 2013-03-22 16:16:24 +0000
@@ -16,6 +16,7 @@
16 if(engineFormula.length === 0){16 if(engineFormula.length === 0){
17 engineFormula.push('');17 engineFormula.push('');
18 }18 }
19 if(screenFormula[screenFormula.length-1]._operation === "=") return;
19 try{20 try{
20 var n_scanner = new CALC.Scanner(engineFormula.join('') + engine, context);21 var n_scanner = new CALC.Scanner(engineFormula.join('') + engine, context);
21 } catch(exception) {22 } catch(exception) {
@@ -50,6 +51,7 @@
50 }51 }
5152
52 function changeSign(){53 function changeSign(){
54 if(screenFormula[screenFormula.length-1]._operation === "=") return;
53 var prev_tokens = [];55 var prev_tokens = [];
54 var add_minus = true;56 var add_minus = true;
55 screenFormula.pop();57 screenFormula.pop();
@@ -98,9 +100,14 @@
98 }100 }
99101
100 function calculate() {102 function calculate() {
101 var result = 0;103 if(screenFormula[screenFormula.length-1]._operation === "="){
104 var lastOperation = engineFormula.pop();
105 var previousResult = screenFormula[screenFormula.length-1]._number
106 engineFormula = [previousResult, lastOperation];
107 scanner = new CALC.Scanner(engineFormula.join(""), context);
108 }
102 try{109 try{
103 result = new CALC.Parser(scanner).reduce(context);110 var result = new CALC.Parser(scanner).reduce(context);
104 if (result === Number.POSITIVE_INFINITY)111 if (result === Number.POSITIVE_INFINITY)
105 result = '∞';112 result = '∞';
106 else if (result === Number.NEGATIVE_INFINITY)113 else if (result === Number.NEGATIVE_INFINITY)
@@ -108,7 +115,12 @@
108 } catch(exception) {115 } catch(exception) {
109 if(exception instanceof CALC.DivisionByZeroError){116 if(exception instanceof CALC.DivisionByZeroError){
110 result = "division by zero error";117 result = "division by zero error";
111 } else if(exception instanceof SyntaxError){118 } else{
119 console.log(screenFormula, engineFormula);
120 screenFormula.pop();
121 engineFormula.pop();
122 scanner = new CALC.Scanner(engineFormula.join(''), context);
123 calculate();
112 return;124 return;
113 }125 }
114 }126 }
115127
=== modified file 'engine.js'
--- engine.js 2013-03-18 15:39:31 +0000
+++ engine.js 2013-03-22 16:16:24 +0000
@@ -523,7 +523,6 @@
523523
524 // If there are more values in the stack524 // If there are more values in the stack
525 // (Error) The user input has too many values.525 // (Error) The user input has too many values.
526 console.log(this.queue.length)
527 throw new Error('runtime error: too many values');526 throw new Error('runtime error: too many values');
528 },527 },
529528

Subscribers

People subscribed via source and target branches