class << self
def build(expression)
parser.parse(expression)
-# rescue
-# raise InvalidExpressionError
+ rescue
+ raise InvalidExpressionError
end
def parser
def self.solve(problem)
answer = solve_problem(problem)
- Mint::Builder.build(answer)
+ Mint::Builder.build(problem)
end
private
--- /dev/null
+# -*- coding: utf-8 -*-
+
+module Mint::Solver::Engine::Maxima
+
+ class Arithmetic < Base
+
+ private
+ def self.solve_problem(problem)
+ maxima(problem)
+ end
+ end
+end
+
--- /dev/null
+# -*- coding: utf-8 -*-
+
+require File.dirname(__FILE__) + '/../../../spec_helper.rb'
+
+module Mint::Solver::Engine
+ describe Maxima::Arithmetic do
+ subject { Maxima::Arithmetic }
+
+ [
+ ['-92.92 - (-0.45)', '-92.47'],
+ ['0.18 * (-0.44)', '-0.0792'],
+ ['91 - (-43)', '134'],
+ ['15/44 + (-68/54)', '-1091 / 1188']
+ ].each do |exp, ans|
+ it exp do
+ result = subject.solve(exp)
+ answer = Mint::Builder.build(exp)
+ result.should == answer
+ end
+ end
+ end
+end
+
['3 * 3', '3 * 3'],
['4 / 4', '4 / 4'],
['5 div 5', '5 div 5'],
+ ['-233/23', '-233 / 23'],
['(x^2 + 4)(y^3 - 2)', '(x^2 + 4) * (y^3 - 2)'],
['(x^3 + 2)(x^2- 3)', '(x^3 + 2) * (x^2 - 3)'],
['2(x^2 + xy + y^2)', '2 * (x^2 + x * y + y^2)'],