From 5a3dd8c79185be07b7bf68d51ccc8f98ced59182 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 12 Feb 2024 23:07:48 +1100 Subject: [PATCH] tests/ports/unix: Add coverage test for frozen functions and generators. Signed-off-by: Damien George --- ports/unix/variants/coverage/frzmpy/frzmpy4.py | 16 ++++++++++++++++ tests/ports/unix/extra_coverage.py | 3 +++ tests/ports/unix/extra_coverage.py.exp | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 ports/unix/variants/coverage/frzmpy/frzmpy4.py diff --git a/ports/unix/variants/coverage/frzmpy/frzmpy4.py b/ports/unix/variants/coverage/frzmpy/frzmpy4.py new file mode 100644 index 0000000000..669b37535b --- /dev/null +++ b/ports/unix/variants/coverage/frzmpy/frzmpy4.py @@ -0,0 +1,16 @@ +# Test importing frozen functions. + +# A simple bytecode function with no children. +def f(): + return 1 + + +print(__name__, f()) + + +# A simple bytecode generator with no children. +def g(): + yield 2 + + +print(__name__, next(g())) diff --git a/tests/ports/unix/extra_coverage.py b/tests/ports/unix/extra_coverage.py index 0ea8f7886b..ec68a55508 100644 --- a/tests/ports/unix/extra_coverage.py +++ b/tests/ports/unix/extra_coverage.py @@ -87,6 +87,9 @@ except ZeroDivisionError: # test importing various objects import frzmpy3 +# test importing other things +import frzmpy4 + # test for MP_QSTR_NULL regression from frzqstr import returns_NULL diff --git a/tests/ports/unix/extra_coverage.py.exp b/tests/ports/unix/extra_coverage.py.exp index 3db1c5a63e..adffc2d582 100644 --- a/tests/ports/unix/extra_coverage.py.exp +++ b/tests/ports/unix/extra_coverage.py.exp @@ -201,6 +201,8 @@ ZeroDivisionError X '\x1b' b'\x00\xff' +frzmpy4 1 +frzmpy4 2 NULL uPy a long string that is not interned