Make eval primitive object test pass
This commit is contained in:
parent
59956903f2
commit
856e74cb5e
@ -136,9 +136,9 @@ enum Primitive {
|
||||
impl Primitive {
|
||||
fn to_repl(&self) -> String {
|
||||
match self {
|
||||
Primitive::Object { type_id, items, .. } => {
|
||||
format!("{}{}", type_id.local_name(), paren_wrapped(items.iter().map(|item| item.to_repl())))
|
||||
},
|
||||
Primitive::Object { type_id, items, .. } if items.len() == 0 => format!("{}", type_id.local_name()),
|
||||
Primitive::Object { type_id, items, .. } =>
|
||||
format!("{}{}", type_id.local_name(), paren_wrapped(items.iter().map(|item| item.to_repl()))),
|
||||
Primitive::Literal(lit) => match lit {
|
||||
Literal::Nat(n) => format!("{}", n),
|
||||
Literal::Int(i) => format!("{}", i),
|
||||
@ -258,6 +258,9 @@ impl<'a> State<'a> {
|
||||
Primitive::unit()
|
||||
},
|
||||
Expression::Call { box f, args } => self.call_expression(f, args)?,
|
||||
Expression::Callable(Callable::DataConstructor { type_id, arity, tag }) if arity == 0 => Primitive::Object {
|
||||
type_id, tag, items: vec![]
|
||||
},
|
||||
Expression::Callable(func) => Primitive::Callable(func),
|
||||
Expression::ReductionError(e) => return Err(e.into()),
|
||||
})
|
||||
|
@ -70,9 +70,9 @@ fn adt_output_1() {
|
||||
type Option<T> = Some(T) | None
|
||||
let a = Option::None
|
||||
let b = Option::Some(10)
|
||||
(a, b)
|
||||
(b, a)
|
||||
"#;
|
||||
eval_assert(source, "(Option::None, Option::Some(10))");
|
||||
eval_assert(source, "(Some(10), None)");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user