GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

test_milestones.py 735 Bytes
Newer Older
1 2 3
"""
Harness JIT tests using py.test framework
"""
John Zhang's avatar
John Zhang committed
4
from util import fncptr_from_c_script
5 6 7
import ctypes


John Zhang's avatar
John Zhang committed
8
def test_constant_function():
John Zhang's avatar
John Zhang committed
9
    fn, _ = fncptr_from_c_script("test_constfunc.c", 'test_fnc')
10 11
    assert fn() == 0

12
def test_milsum():
John Zhang's avatar
John Zhang committed
13
    fn, _ = fncptr_from_c_script("test_milsum.c", "milsum", [ctypes.c_ulonglong])
14 15
    assert fn(1000000) == 500000500000

16
def test_factorial():
John Zhang's avatar
John Zhang committed
17
    fn, _ = fncptr_from_c_script("test_fac.c", "fac", [ctypes.c_ulonglong])
18 19
    assert fn(20) == 2432902008176640000

20
def test_fibonacci():
John Zhang's avatar
John Zhang committed
21
    fn, _ = fncptr_from_c_script("test_fib.c", "fib", [ctypes.c_ulonglong])
22
    assert fn(20) == 6765
23 24

def test_multifunc():
John Zhang's avatar
John Zhang committed
25 26
    fn, _ = fncptr_from_c_script("test_multifunc.c", "entry")
    assert fn() == 6765