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

47 lines
897 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",
"
type FooBar = enum {
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",
"
type FooBarBaz = enum |T, U, V| {
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)]),
)))
);
}