mathmaker  0.6(alpha)
mamk_misc/doc/mathmaker4doxygen/maintenance/autotest/obj_test/cross_product_equations_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 #import locale
00026 
00027 #from lib.common import default
00028 
00029 from core import *
00030 from core.calculus import *
00031 from core.base_calculus import *
00032 
00033 from maintenance.autotest import common
00034 
00035 try:
00036    locale.setlocale(locale.LC_ALL, default.LANGUAGE + '.' + default.ENCODING)
00037 except:
00038     locale.setlocale(locale.LC_ALL, '')
00039 
00040 check = common.check
00041 
00042 
00043 def action():
00044     if common.verbose:
00045         os.write(common.output, bytes("--- CROSS PRODUCT EQUATIONS\n", 'utf-8'))
00046 
00047 
00048     e1 = CrossProductEquation((Item("AB"),    Item(3),
00049                                Item(4),       Item(8)))
00050 
00051     check(e1,
00052          [  "\\frac{\\text{AB}}{4}=\\frac{3}{8}"])
00053 
00054     check(e1.auto_resolution(dont_display_equations_name=True),
00055          [  "\[\\frac{\\text{AB}}{4}=\\frac{3}{8}\]" \
00056          +  "\[\\text{AB}=\\frac{3\\times 4}{8}\]"
00057          +  "\[\\text{AB}=\\frac{3\\times \\bcancel{4}}{\\bcancel{4}\\times 2}\]"
00058          +  "\[\\text{AB}=\\frac{3}{2}\]"
00059          ])
00060 
00061     check(e1.auto_resolution(dont_display_equations_name=True,
00062                              skip_fraction_simplification=True,
00063                              decimal_result=2),
00064          [  "\[\\frac{\\text{AB}}{4}=\\frac{3}{8}\]" \
00065          +  "\[\\text{AB}=\\frac{3\\times 4}{8}\]"
00066          +  "\[\\text{AB}=" + locale.str(1.5) + "\]"
00067          ])
00068 
00069     check(e1.auto_resolution(dont_display_equations_name=True,
00070                              skip_fraction_simplification=True),
00071          [  "\[\\frac{\\text{AB}}{4}=\\frac{3}{8}\]" \
00072          +  "\[\\text{AB}=\\frac{3\\times 4}{8}\]"
00073          +  "\[\\text{AB}=\\frac{3}{2}\]"
00074          ])
00075 
00076     e2 = CrossProductEquation((Item(6),   Item(1.4),
00077                                Item(1.5), Item("AB")
00078                              ))
00079 
00080     check(e2.auto_resolution(dont_display_equations_name=True,
00081                              skip_fraction_simplification=True,
00082                              decimal_result=2),
00083          [  "\[\\frac{6}{" + locale.str(1.5) + "}=\\frac{" \
00084          + locale.str(1.4) + "}{\\text{AB}}\]" \
00085          +  "\[\\text{AB}=\\frac{" + locale.str(1.4) + "\\times " \
00086          + locale.str(1.5) + "}{6}\]"
00087          +  "\[\\text{AB}=" + locale.str(0.35) + "\]"
00088          ])
00089 
00090 
00091 
00092 
00093