Commit 0f5c8cc3 authored by Jeff Smits's avatar Jeff Smits

Fail to build list with improper tail

parent 56cac738
......@@ -281,7 +281,7 @@ fn gen_strc_tests() {
for entry in read_dir("tests/strc_tests").unwrap() {
let path = entry.unwrap().path();
if path.is_file() && Some("ctree".as_ref()) == path.extension() {
// TODO: sanatise file_stem so it's likely to be a valid test name?
// TODO: sanitise file_stem so it's likely to be a valid test name?
let test_name = path.file_stem()
.unwrap()
.to_str()
......@@ -305,6 +305,7 @@ fn {}() {{
let program = io::read_aterm(&f, &"{}");
assert!(program.is_ok());
let term = interpret_main(&f, program.unwrap(), libraries.unwrap());
println!("{{:?}}", term);
assert!(term.is_ok());
let mut result = String::new();
assert!(term.unwrap().to_ascii(&mut result).is_ok());
......
......@@ -393,7 +393,19 @@ impl BuildTerm {
.with_annos(context.factory.t_string(s.clone()), annos.unwrap_or_default()))
}
Op(ref s, ref t) => {
use interpreter::b;
use aterm::Term::Application;
let t = Self::build_vec(context, t)?;
if s == "Cons" && t.len() == 2 {
match b(&t[1]).as_inner().term {
Application(ref c, ref r)
if c == "Nil" && r.is_empty() || c == "Cons" && r.len() == 2 => {},
_ => {
return Err(Error::StrategyFailed);
}
}
}
Ok(context
.factory
.with_annos(context.factory.t_application(s.clone(), t.into_iter()),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment