diff options
author | Sid Nayyar <sidnayyar@google.com> | 2024-04-25 14:06:33 +0100 |
---|---|---|
committer | Giuliano Procida <gprocida@google.com> | 2024-04-25 22:06:18 +0100 |
commit | 0cdd97b7a7c5a0452f2504005eb8505ce26153a2 (patch) | |
tree | 97f08efac44e121cefacc7504f025507509eae5c | |
parent | bd7ac2942c870ce664eae326d81c6c6b48da9599 (diff) | |
download | stg-0cdd97b7a7c5a0452f2504005eb8505ce26153a2.tar.gz |
rust: add test case for rust tagged enums
PiperOrigin-RevId: 628050972
Change-Id: I856ffb8f0e5c743d1fecb2e29ce7708f60a58307
-rw-r--r-- | test_cases/info_tests/variant/expected/simple_rs.elf_stg | 33 | ||||
-rw-r--r-- | test_cases/info_tests/variant/simple.rs | 14 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test_cases/info_tests/variant/expected/simple_rs.elf_stg b/test_cases/info_tests/variant/expected/simple_rs.elf_stg new file mode 100644 index 0000000..4621cf8 --- /dev/null +++ b/test_cases/info_tests/variant/expected/simple_rs.elf_stg @@ -0,0 +1,33 @@ +version: 0x00000002 +root_id: 0x84ea5130 # interface +primitive { + id: 0x62aebfd4 + name: "bool" + encoding: BOOLEAN + bytesize: 0x00000001 +} +struct_union { + id: 0x176387ba + kind: STRUCT + name: "simple::Foo" + definition { + bytesize: 12 + } +} +function { + id: 0xbb888a50 + return_type_id: 0x62aebfd4 # bool + parameter_id: 0x176387ba # struct simple::Foo +} +elf_symbol { + id: 0x4e2f2fc8 + name: "is_unit" + is_defined: true + symbol_type: FUNCTION + type_id: 0xbb888a50 # bool(struct simple::Foo) + full_name: "simple::is_unit" +} +interface { + id: 0x84ea5130 + symbol_id: 0x4e2f2fc8 # bool simple::is_unit(struct simple::Foo) +} diff --git a/test_cases/info_tests/variant/simple.rs b/test_cases/info_tests/variant/simple.rs new file mode 100644 index 0000000..5f080ec --- /dev/null +++ b/test_cases/info_tests/variant/simple.rs @@ -0,0 +1,14 @@ +#[repr(u8)] +pub enum Foo { + Unit, + TwoU32s(u32, u32), + ThreeI16s { x: i16, y: i16, z: i16 }, +} + +#[no_mangle] +pub fn is_unit(foo: Foo) -> bool { + match foo { + Foo::Unit => true, + _ => false, + } +} |