Source

hack2 / pypyembed / test / test_example.py

Full commit

from embed import export_function

@export_function
def adder(a, b):
    return a + b

def test_basics():
    assert adder(1, 2) == 3
    assert adder(1.2, 3.4) == 4.6

@export_function
def returning_numarray(size):
    import numpy
    return numpy.arange(size)

def test_returning_numarray():
    assert returning_numarray(100)[13] == 13

@export_function
def returning_numarray_multidim(a, b):
    import numpy
    return numpy.arange(a * b).reshape(a, b)

def test_returning_numarray_multidim():
    assert (returning_numarray_multidim(2, 5)[1] == [5, 6, 7, 8, 9]).all()