From bed33a7421b2c8f6b595f8feaa602de041bcc14f Mon Sep 17 00:00:00 2001 From: ychenfo Date: Sun, 27 Mar 2022 10:14:22 +0800 Subject: [PATCH] nac3standalone: add tests for tuple --- nac3standalone/demo/demo.rs | 5 +++++ nac3standalone/demo/src/tuple.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 nac3standalone/demo/src/tuple.py diff --git a/nac3standalone/demo/demo.rs b/nac3standalone/demo/demo.rs index 7f42c89b..c7e44527 100644 --- a/nac3standalone/demo/demo.rs +++ b/nac3standalone/demo/demo.rs @@ -74,6 +74,11 @@ pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _conte unimplemented!(); } +#[no_mangle] +pub extern "C" fn __nac3_raise(_state: u32, _exception_object: u32, _context: u32) -> u32 { + unimplemented!(); +} + extern "C" { fn run() -> i32; } diff --git a/nac3standalone/demo/src/tuple.py b/nac3standalone/demo/src/tuple.py new file mode 100644 index 00000000..f71d3f99 --- /dev/null +++ b/nac3standalone/demo/src/tuple.py @@ -0,0 +1,29 @@ +@extern +def output_int32_list(x: list[int32]): + ... + +@extern +def output_int32(x: int32): + ... + +class A: + a: int32 + b: bool + def __init__(self, a: int32, b: bool): + self.a = a + self.b = b + +def run() -> int32: + data = [0, 1, 2, 3] + + t = [(d, d + d) for d in data] + for i in t: + tt = (Some(i[1]), i[0]) + tl = ([i[0], i[1] + i[0]], i[1]) + output_int32(tt[0].unwrap()) + output_int32(tt[1]) + output_int32(tl[0][0]) + output_int32(tl[0][1]) + output_int32(tl[1]) + + return 0 \ No newline at end of file