2024-06-19 14:48:22 +00:00
|
|
|
use dust_lang::{identifier::Identifier, *};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn simple_enum() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret(
|
|
|
|
"test",
|
|
|
|
"
|
2024-06-20 22:41:07 +00:00
|
|
|
enum FooBar {
|
2024-06-19 14:48:22 +00:00
|
|
|
Foo,
|
|
|
|
Bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
FooBar::Foo
|
|
|
|
"
|
|
|
|
),
|
|
|
|
Ok(Some(Value::enum_instance(
|
|
|
|
Identifier::new("FooBar"),
|
2024-07-12 15:08:53 +00:00
|
|
|
None,
|
2024-06-19 14:48:22 +00:00
|
|
|
Identifier::new("Foo"),
|
|
|
|
None
|
|
|
|
)))
|
|
|
|
);
|
|
|
|
}
|
2024-06-19 16:03:25 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn big_enum() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret(
|
|
|
|
"test",
|
|
|
|
"
|
2024-06-20 22:41:07 +00:00
|
|
|
enum FooBarBaz <T, U, V> {
|
2024-06-19 16:03:25 +00:00
|
|
|
Foo(T),
|
|
|
|
Bar(U),
|
|
|
|
Baz(V),
|
|
|
|
}
|
|
|
|
|
2024-07-12 15:08:53 +00:00
|
|
|
FooBarBaz::<int, str, float>::Baz(42.0)
|
2024-06-19 16:03:25 +00:00
|
|
|
"
|
|
|
|
),
|
|
|
|
Ok(Some(Value::enum_instance(
|
|
|
|
Identifier::new("FooBarBaz"),
|
2024-07-12 15:08:53 +00:00
|
|
|
None,
|
2024-06-19 16:03:25 +00:00
|
|
|
Identifier::new("Baz"),
|
2024-07-12 15:08:53 +00:00
|
|
|
Some(Value::float(42.0)),
|
2024-06-19 16:03:25 +00:00
|
|
|
)))
|
|
|
|
);
|
|
|
|
}
|