'Test printing a single argument value.'

@tag('important')
def test_print_values(self):

    pyfunc = print_value
    def check_values(typ, values):
        cr = compile_isolated(pyfunc, (typ,))
        cfunc = cr.entry_point
        for val in values:
            with captured_stdout():
                cfunc(val)
                self.assertEqual(sys.stdout.getvalue(), (str(val) + '\n'))
    check_values(types.int32, (1, (-234)))
    check_values(types.int64, (1, (-234), 123456789876543210, (-123456789876543210)))
    check_values(types.uint64, (1, 234, 123456789876543210, ((2 ** 63) + 123)))
    check_values(types.boolean, (True, False))
    check_values(types.float64, (1.5, (100.0 ** 10.0), float('nan')))
    check_values(types.complex64, ((1 + 1j),))
    check_values(types.NPTimedelta('ms'), (np.timedelta64(100, 'ms'),))
    cr = compile_isolated(pyfunc, (types.float32,))
    cfunc = cr.entry_point
    with captured_stdout():
        cfunc(1.1)
        got = sys.stdout.getvalue()
        expect = '1.10000002384'
        self.assertTrue(got.startswith(expect))
        self.assertTrue(got.endswith('\n'))
    with self.assertNoNRTLeak():
        x = [1, 3, 5, 7]
        with self.assertRefCount(x):
            check_values(types.List(types.int32), (x,))
    arraytype = types.Array(types.int32, 1, 'C')
    cr = compile_isolated(pyfunc, (arraytype,), flags=enable_pyobj_flags)
    cfunc = cr.entry_point
    with captured_stdout():
        cfunc(np.arange(10))
        self.assertEqual(sys.stdout.getvalue(), '[0    1    2    3    4    5    6    7    8    9]\n')
