mathmaker  0.6(alpha)
mamk_misc/doc/mathmaker4doxygen/maintenance/autotest/obj_test/calc_test/quotients_test.py
00001 # -*- coding: utf-8 -*-
00002 
00003 # Mathmaker creates automatically maths exercises sheets
00004 # with their answers
00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net>
00006 
00007 # This file is part of Mathmaker.
00008 
00009 # Mathmaker is free software; you can redistribute it and/or modify
00010 # it under the terms of the GNU General Public License as published by
00011 # the Free Software Foundation; either version 3 of the License, or
00012 # any later version.
00013 
00014 # Mathmaker is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 
00019 # You should have received a copy of the GNU General Public License
00020 # along with Mathmaker; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 import os
00024 import sys
00025 
00026 from core import *
00027 from core.base_calculus import *
00028 
00029 from maintenance.autotest import common
00030 
00031 check = common.check
00032 
00033 
00034 def action():
00035     if common.verbose:
00036         os.write(common.output, bytes("--- QUOTIENTS\n", 'utf-8'))
00037 
00038     quo_fraction_8over9_div_7over2 = Quotient(('+',
00039                                                Fraction(('+', 8, 9)),
00040                                                Fraction(('+', 7, 2)),
00041                                                1,
00042                                                'use_divide_symbol'
00043                                               ))
00044 
00045     quo_fraction_minus1over2_div_1over3 = Quotient(('-',
00046                                                Fraction(('+', 1, 2)),
00047                                                Fraction(('+', 1, 3)),
00048                                                1,
00049                                                'use_divide_symbol'
00050                                               ))
00051 
00052 
00053 
00054 
00055     check(quo_fraction_8over9_div_7over2,
00056          ["\\frac{8}{9}\div \\frac{7}{2}"])
00057 
00058     check(quo_fraction_8over9_div_7over2.calculate_next_step(),
00059          ["\\frac{8}{9}\\times \\frac{2}{7}"])
00060 
00061     #print str(quo_fraction_8over9_div_7over2.calculate_next_step())
00062 
00063     check(quo_fraction_8over9_div_7over2.calculate_next_step()\
00064           .calculate_next_step(),
00065          ["\\frac{8\\times 2}{9\\times 7}"])
00066 
00067 
00068     check(quo_fraction_minus1over2_div_1over3,
00069          ["-\\frac{1}{2}\div \\frac{1}{3}"])  #-\\frac{1}{2}\div \\frac{1}{3}
00070 
00071     next_step = quo_fraction_minus1over2_div_1over3.calculate_next_step()
00072     check(next_step,
00073          ["-\\frac{1}{2}\\times \\frac{3}{1}"])
00074 
00075     next_step = next_step.calculate_next_step()
00076     check(next_step,
00077          ["-\\frac{1\\times 3}{2\\times 1}"])
00078 
00079     next_step = next_step.calculate_next_step()
00080     check(next_step,
00081          ["-\\frac{3}{2}"])
00082 
00083 
00084