'A generic check function that run both pyfunc, and jitted pyfunc,
and compare results.'

def check(self, pyfunc, *args, **kwargs):

    run_parallel = (kwargs['run_parallel'] if ('run_parallel' in kwargs) else False)
    assert_allocate_list = (kwargs['assert_allocate_list'] if ('assert_allocate_list' in kwargs) else False)
    assert_dtype = (kwargs['assert_dtype'] if ('assert_dtype' in kwargs) else None)
    cfunc = jit(nopython=True, parallel=run_parallel)(pyfunc)
    pyres = pyfunc(*args)
    cres = cfunc(*args)
    np.testing.assert_array_equal(pyres, cres)
    if assert_dtype:
        self.assertEqual(cres[1].dtype, assert_dtype)
    if assert_allocate_list:
        self.assertIn('allocate    list', cfunc.inspect_llvm(cfunc.signatures[0]))
    else:
        self.assertNotIn('allocate    list', cfunc.inspect_llvm(cfunc.signatures[0]))
    if run_parallel:
        self.assertIn('@do_scheduling', cfunc.inspect_llvm(cfunc.signatures[0]))
