add structural tests for partial strings, rename ast.rs

This commit is contained in:
Mark Thom
2018-09-04 21:20:45 -06:00
parent 9713286023
commit 33d1a7c701
27 changed files with 46 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
#[macro_use] extern crate prolog_parser;
extern crate termion;
use prolog::ast::*;
use prolog::instructions::*;
mod prolog;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::fixtures::*;
use prolog::targets::*;

View File

@@ -1,4 +1,4 @@
use prolog::ast::*;
use prolog::instructions::*;
use std::ops::{Index, IndexMut};
use std::vec::Vec;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use std::cell::Cell;
use std::cmp::{min, max};
use std::rc::Rc;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::allocator::*;
use prolog::arithmetic::*;
use prolog::fixtures::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::debray_allocator::*;
use prolog::codegen::*;
use prolog::machine::*;

View File

@@ -1,5 +1,5 @@
use prolog::ast::*;
use prolog::and_stack::*;
use prolog::instructions::*;
use std::ops::IndexMut;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::allocator::*;
use prolog::targets::*;

View File

@@ -1,8 +1,8 @@
use prolog_parser::ast::*;
use prolog::instructions::*;
use prolog::iterators::*;
use prolog::ast::*;
use std::cell::Cell;
use std::collections::{BTreeMap, HashMap};
use std::collections::btree_map::{IntoIter, IterMut, Values};

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::machine::machine_state::*;
use std::collections::HashSet;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::machine::machine_state::*;
use prolog::num::*;
use prolog::heap_iter::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use std::collections::{HashMap, VecDeque};
use std::hash::Hash;
use std::rc::Rc;
@@ -217,7 +217,6 @@ impl CodeOffsets {
IntIndex::Internal(_) => prelude_len - lst_offset + 1
}
}
pub fn add_indices(self, code: &mut Code, mut code_body: Code)
{

View File

@@ -1,4 +1,4 @@
use prolog::ast::*;
use prolog::instructions::*;
use prolog::heap_print::*;
use prolog::machine::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use std::cell::Cell;
use std::collections::VecDeque;
use std::iter::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::machine::machine_state::*;
use prolog::num::bigint::BigInt;

View File

@@ -1,7 +1,7 @@
use prolog_parser::ast::*;
use prolog_parser::tabled_rc::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::and_stack::*;
use prolog::copier::*;
use prolog::heap_print::*;

View File

@@ -1,7 +1,7 @@
use prolog_parser::ast::*;
use prolog_parser::string_list::StringList;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::and_stack::*;
use prolog::copier::*;
use prolog::heap_iter::*;
@@ -1528,10 +1528,22 @@ impl MachineState {
return Ordering::Greater,
(HeapCellValue::Addr(Addr::Con(Constant::String(_))),
HeapCellValue::Addr(Addr::Con(Constant::Number(_)))) =>
return Ordering::Greater,
return Ordering::Greater,
(HeapCellValue::Addr(Addr::Con(Constant::String(s1))),
HeapCellValue::Addr(Addr::Con(Constant::String(s2)))) =>
return s1.cmp(&s2),
return if s1.is_expandable() {
if s2.is_expandable() {
s1.cmp(&s2)
} else {
Ordering::Greater
}
} else {
if s2.is_expandable() {
Ordering::Less
} else {
s1.cmp(&s2)
}
},
(HeapCellValue::Addr(Addr::Con(Constant::String(_))), _) =>
return Ordering::Less,
(HeapCellValue::Addr(Addr::Con(Constant::Atom(..))),

View File

@@ -1,7 +1,7 @@
use prolog_parser::ast::*;
use prolog_parser::tabled_rc::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::compile::*;
use prolog::heap_print::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::machine::machine_errors::*;
use prolog::machine::machine_state::*;
use prolog::num::{ToPrimitive, Zero};

View File

@@ -2,7 +2,7 @@ extern crate num;
extern crate ordered_float;
extern crate prolog_parser;
#[macro_use] pub mod ast;
#[macro_use] pub mod instructions;
pub mod and_stack;
#[macro_use] pub mod macros;
#[macro_use] pub mod allocator;

View File

@@ -1,4 +1,4 @@
use prolog::ast::*;
use prolog::instructions::*;
use std::ops::{Index, IndexMut};
use std::vec::Vec;

View File

@@ -1,7 +1,7 @@
use prolog_parser::ast::*;
use prolog_parser::parser::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::iterators::*;
use prolog::machine::machine_state::*;

View File

@@ -1,6 +1,6 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::iterators::*;
pub trait CompilationTarget<'a> {

View File

@@ -2,7 +2,7 @@ use prolog_parser::ast::*;
use prolog_parser::parser::*;
use prolog_parser::tabled_rc::*;
use prolog::ast::*;
use prolog::instructions::*;
use prolog::iterators::*;
use prolog::machine::*;
use prolog::num::*;

View File

@@ -1,7 +1,7 @@
use prolog_parser::ast::*;
use prolog::ast::*;
use prolog::heap_print::*;
use prolog::instructions::*;
use prolog::compile::*;
use prolog::machine::*;
@@ -1936,4 +1936,7 @@ fn test_queries_on_string_lists()
assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), partial_string(\"ababc\", Y), Y = [a,b|Z],
X == Z.");
assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X), X @> \"abc\".");
assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), X \\=@= \"abc\".");
assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), X @< \"abc\".");
}