1
0
dust/dust-lang/tests/enums.rs

47 lines
883 B
Rust
Raw Normal View History

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"),
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),
}
FooBarBaz::Baz(42.0)
"
),
Ok(Some(Value::enum_instance(
Identifier::new("FooBarBaz"),
Identifier::new("Baz"),
Some(vec![Value::float(42.0)]),
)))
);
}