Skip to content

Commit

Permalink
[wip] core: introspection: Test stability of enum type ids
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis-hamester committed Dec 2, 2024
1 parent feedcca commit 10261ff
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion core/src/introspection/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use super::{Introspectable, Introspection, Layout, LexicalId, References, Struct};
use super::{Enum, Introspectable, Introspection, Layout, LexicalId, References, Struct};
use crate::ids::TypeId;
use uuid::uuid;

#[test]
fn duplicate_lexical_id_good() {
Expand Down Expand Up @@ -72,3 +74,30 @@ fn duplicate_lexical_id_bad() {

Introspection::new::<Dup>();
}

#[test]
fn basic_enum_type_id() {
struct Foo;

impl Introspectable for Foo {
fn layout() -> Layout {
Enum::builder("test", "Foo")
.variant_with_type(0, "Var1", LexicalId::U8)
.unit_variant(1, "Var2")
.finish()
.into()
}

fn lexical_id() -> LexicalId {
LexicalId::custom("test", "Foo")
}

fn add_references(_references: &mut References) {}
}

let type_id = TypeId::compute::<Foo>();
assert_eq!(
type_id,
TypeId(uuid!("f81d8f58-1f03-5be4-a8ac-3220597d7730"))
);
}

0 comments on commit 10261ff

Please sign in to comment.