aca9d5bc40
* modframebuf: _mp_framebuf_p_t is not "really" a protocol, but the QSTR assignment caused problems when building as a dynamic module * modure: str_index_to_ptr is not in the natmod API, disable URE match spans when dynamic. mp_obj_len() is a bugfix, we should throw here if the object is not string-like * moduzlib: Correct paths to uzlib headers & sources. this relative path (from moduzlib.c to the referenced file) works in all cases, the other only worked from ports/PORTNAME. * dynruntime: Handle 2-arg m_malloc, assert_native_inited, add a micropythonish mp_arg_check_num_mp, fix mp_raise_msg to use dumb strings, add mp_raise_arg1 * nativeglue: ad assert_native_inited * translate: MP_ERROR_TEXT evaluates to its argument for DYNRUNTIME * mpy-tool: A straggling magic number change * mpy_ld: Have to renumber manually after dynruntime change * import_mpy_native_gc.py: Update copy of features0 baked into this test
30 lines
488 B
Python
30 lines
488 B
Python
# This Python code will be merged with the C code in main.c
|
|
|
|
import array
|
|
|
|
|
|
def isclose(a, b):
|
|
return abs(a - b) < 1e-3
|
|
|
|
|
|
def test():
|
|
tests = [
|
|
isclose(add(0.1, 0.2), 0.3),
|
|
isclose(add_f(0.1, 0.2), 0.3),
|
|
]
|
|
|
|
ar = array.array("f", [1, 2, 3.5])
|
|
productf(ar)
|
|
tests.append(isclose(ar[0], 7))
|
|
|
|
if "add_d" in globals():
|
|
tests.append(isclose(add_d(0.1, 0.2), 0.3))
|
|
|
|
print(tests)
|
|
|
|
if not all(tests):
|
|
raise SystemExit(1)
|
|
|
|
|
|
test()
|