Esempio n. 1
0
 def test_func(self):
     fn = getattr(ll_math, 'll_math_' + fnname)
     repr = "%s(%s)" % (fnname, ', '.join(map(str, args)))
     try:
         got = fn(*args)
     except ValueError:
         assert expected == ValueError, "%s: got a ValueError" % (repr,)
     except OverflowError:
         assert expected == OverflowError, "%s: got an OverflowError" % (
             repr,)
     else:
         if not get_tester(expected)(got):
             raise AssertionError("%r: got %r, expected %r" %
                                  (repr, got, expected))
Esempio n. 2
0
 def test_func(self):
     fn = getattr(ll_math, 'll_math_' + fnname)
     repr = "%s(%s)" % (fnname, ', '.join(map(str, args)))
     try:
         got = fn(*args)
     except ValueError:
         assert expected == ValueError, "%s: got a ValueError" % (repr, )
     except OverflowError:
         assert expected == OverflowError, "%s: got an OverflowError" % (
             repr, )
     else:
         if not get_tester(expected)(got):
             raise AssertionError("%r: got %r, expected %r" %
                                  (repr, got, expected))
Esempio n. 3
0
def get_test_case((fnname, args, expected)):
    try:
        fn = getattr(math, fnname)
    except AttributeError:
        fn = getattr(rfloat, fnname)
    expect_valueerror = (expected == ValueError)
    expect_overflowerror = (expected == OverflowError)
    check = test_direct.get_tester(expected)
    #
    def testfn():
        try:
            got = fn(*args)
        except ValueError:
            return expect_valueerror
        except OverflowError:
            return expect_overflowerror
        else:
            return check(got)
    #
    testfn.func_name = 'test_' + fnname
    return testfn
Esempio n. 4
0
def get_test_case((fnname, args, expected)):
    try:
        fn = getattr(math, fnname)
    except AttributeError:
        fn = getattr(rfloat, fnname)
    expect_valueerror = (expected == ValueError)
    expect_overflowerror = (expected == OverflowError)
    check = test_direct.get_tester(expected)
    unroll_args = unrolling_iterable(args)

    #
    def testfn():
        debug_print('calling', fnname, 'with arguments:')
        for arg in unroll_args:
            debug_print('\t', arg)
        try:
            got = fn(*args)
        except ValueError:
            if expect_valueerror:
                return True
            else:
                debug_print('unexpected ValueError!')
                return False
        except OverflowError:
            if expect_overflowerror:
                return True
            else:
                debug_print('unexpected OverflowError!')
                return False
        else:
            if check(got):
                return True
            else:
                debug_print('unexpected result:', got)
                return False

    #
    testfn.func_name = 'test_' + fnname
    return testfn
Esempio n. 5
0
def get_test_case((fnname, args, expected)):
    try:
        fn = getattr(math, fnname)
    except AttributeError:
        fn = getattr(rfloat, fnname)
    expect_valueerror = (expected == ValueError)
    expect_overflowerror = (expected == OverflowError)
    check = test_direct.get_tester(expected)
    unroll_args = unrolling_iterable(args)
    #
    def testfn():
        debug_print('calling', fnname, 'with arguments:')
        for arg in unroll_args:
            debug_print('\t', arg)
        try:
            got = fn(*args)
        except ValueError:
            if expect_valueerror:
                return True
            else:
                debug_print('unexpected ValueError!')
                return False
        except OverflowError:
            if expect_overflowerror:
                return True
            else:
                debug_print('unexpected OverflowError!')
                return False
        else:
            if check(got):
                return True
            else:
                debug_print('unexpected result:', got)
                return False
    #
    testfn.func_name = 'test_' + fnname
    return testfn