Fix #10, add test

This commit is contained in:
Mahdi Dibaiee
2015-07-07 15:50:05 +04:30
parent a4b45ded0a
commit 9274694d98
5 changed files with 16 additions and 5 deletions

View File

@ -182,7 +182,7 @@ const parseExpression = expression => {
stack.push(`-${cur}`);
// 2 - 5 is also OK, pass
} else if (_.isNumber(beforeSign)) {
} else if (_.isNumber(beforeSign) || isVariable(beforeSign)) {
stack.push(cur);
} else {
stack[past] += cur;
@ -379,9 +379,11 @@ const fixFloat = number => {
* @return {Boolean}
* true if variable, else false
*/
const SPECIALS = '()[]{}'.split('');
export const isVariable = a => {
return typeof a === 'string' && !_.isNumber(a) &&
!operators[a] && a === a.toLowerCase();
!operators[a] && a === a.toLowerCase() && SPECIALS.indexOf(a) === -1;
};
export default Equation;