Add (failing) data constructor test

This commit is contained in:
Greg Shuflin 2021-10-25 16:53:25 -07:00
parent cac61ba093
commit a1d6661a6b
2 changed files with 15 additions and 2 deletions

View File

@ -225,7 +225,7 @@ impl<'a> Reducer<'a> {
GlobalBinding => Expression::Lookup(Lookup::GlobalVar(def_id.unwrap())),
LocalVariable => Expression::Lookup(Lookup::LocalVar(def_id.unwrap())),
FunctionParam(n) => Expression::Lookup(Lookup::Param(n)),
DataConstructor { .. } => {
DataConstructor { index, arity, type_id } => {
Expression::ReductionError("DataConstructor not supported".to_string())
},
RecordConstructor { .. } => {

View File

@ -5,6 +5,7 @@ use crate::tree_walk_eval::State;
fn evaluate_input(input: &str) -> Result<String, String> {
let ast = crate::util::quick_ast(input);
println!("AST: {:?}", ast);
let mut symbol_table = SymbolTable::new();
symbol_table.process_ast(&ast).unwrap();
let reduced_ir = crate::reduced_ir::reduce(&ast, &symbol_table);
@ -62,6 +63,18 @@ fn scopes() {
eval_assert(scope_ok, "20");
}
#[test]
fn adt_output_1() {
let source = r#"
type Option<T> = Some(T) | None
let x = Option::Some(10)
x
"#;
eval_assert(source, "Option::Some(10)");
}
/*
#[test]
fn if_is_patterns() {
let source = r#"
@ -75,7 +88,7 @@ type Option<T> = Some(T) | None
let x = Option::None; if x is Option::Some(q) then { q } else { 0 }"#;
eval_assert(source, "0");
}
*/
#[test]