File:  [CENS] / python / pyGiNaC / test4 / test_ex.py
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Mon Nov 26 22:37:44 2001 UTC (16 years ago) by pearu
Branches: MAIN
CVS tags: HEAD
See NEWS.txt (impl. matrix)

#!/usr/bin/env python
"""
  test_ex - run ginac.ex tests.
  Usage:
    python test_ex.py [-v]
"""
"""
  This file is part of the PyGiNaC package.
  http://cens.ioc.ee/projects/pyginac/

  $Revision: 1.6 $
  $Id: test_ex.py,v 1.6 2001-11-26 22:37:44 pearu Exp $
 
  Copyright 2001 Pearu Peterson all rights reserved,
  Pearu Peterson <pearu@cens.ioc.ee>
  Permission to use, modify, and distribute this software is given under the
  terms of the LGPL.  See http://www.fsf.org
 
  NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
"""

import test_all
import ginac

class test_ex(ginac.ex):
    def __init__(self):
        """
        >>> ex()
        numeric('0')
        >>> ex(ex())
        numeric('0')
        >>> ex(2)
        numeric('2')
        >>> ex(0.0)
        numeric('0.0')
        >>> ex(0.0j)
        numeric('0.0')
        >>> ex(1234567890123456789L)
        numeric('1234567890123456789')
        >>> ex(lst())
        lst()
        >>> ex([])
        Traceback (most recent call last):
        ...
        ValueError: matrix(): rows=0 and cols=0 must be positive
        >>> ex(ex(3).ex)
        numeric('3')
        >>> ex(type)
        Traceback (most recent call last):
        ...
        TypeError: ex(): <type 'builtin_function_or_method'>
        >>> class arbitrary_class: pass
        ...
        >>> ex(arbitrary_class())
        Traceback (most recent call last):
        ...
        TypeError: ex(instance): arbitrary_class
        """
    def __coerce__(self):
        """
        >>> e = ex()
        >>> a = symbol('a')
        >>> coerce(e,a)
        (numeric('0'), symbol('a'))
        >>> coerce(e,1)
        (numeric('0'), numeric('1'))
        >>> coerce(1,e)
        (numeric('1'), numeric('0'))
        """
    def __abs__(self):
        """
        >>> a = symbol('a')

        > >> abs(a)
        symbol(name = 'a')
        """
    def get_hash(self):
        """
        >>> type(ex().get_hash())
        <type 'int'>
        """
    def __lt__(self):
        """
        >>> symbol('a') < symbol('b')
        relational(symbol('a'),symbol('b'),'<')
        >>> symbol('a') < 2
        relational(symbol('a'),numeric('2'),'<')
        >>> 2 < symbol('a')
        relational(numeric('2'),symbol('a'),'<')
        """
    def __gt__(self):
        """
        >>> symbol('a') > symbol('b')
        relational(symbol('b'),symbol('a'),'<')
        """
    def __ge__(self):
        """
        >>> symbol('a') >= symbol('b')
        relational(symbol('b'),symbol('a'),'<=')
        """
    def __le__(self):
        """
        >>> symbol('a') <= symbol('b')
        relational(symbol('a'),symbol('b'),'<=')
        """
    def __eq__(self):
        """
        >>> symbol('a') == symbol('b')
        relational(symbol('a'),symbol('b'),'==')
        """
    def __ne__(self):
        """
        >>> symbol('a') != symbol('b')
        relational(symbol('a'),symbol('b'),'!=')
        >>> symbol('a') != 2
        relational(symbol('a'),numeric('2'),'!=')
        >>> 2 != symbol('a')
        relational(symbol('a'),numeric('2'),'!=')
        """
    def no_test(self):
        """No tests are needed as they should be implemented in derived classes."""
    __add__ = __div__ = __divmod__ = __invert__ =\
              __mul__ = __neg__ = __nonzero__ = __pos__ = __radd__ =\
              __rdiv__ = __repr__ = __rmul__ = __rsub__ = __str__ =\
              __sub__ = get_class_name = get_precedence = to_context =\
              extract_archived = no_test
def _test():
    import test_ex
    return test_all.test(test_ex)

if __name__ == "__main__":
    _test()

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>