-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the tests module (hopefully!)
- Loading branch information
1 parent
51910f6
commit d8c785c
Showing
4 changed files
with
90 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,78 @@ | ||
//! A module that tests everything to dow with clauses | ||
#![allow(unused)] | ||
|
||
// #[test] | ||
use terms::*; | ||
use clause::*; | ||
|
||
#[test] | ||
fn create() { | ||
assert!(true == true); | ||
let c1 = clause![term!["A"]]; | ||
let c2 = clause![term!["A"]]; | ||
assert_eq!(c1, c2); | ||
} | ||
|
||
|
||
// #[test] | ||
#[test] | ||
fn compare() { | ||
// let a = term!["A", "B"]; | ||
// let b = term!["B", "C"]; | ||
// let c = term!["A", "B"]; | ||
let c1 = clause![term!["A"]]; | ||
let c2 = clause![term!["A"]]; | ||
assert_eq!(c1, c2); | ||
|
||
let c3 = clause![term!["A", "B"], term!["!B"]]; | ||
let c4 = clause![term!["B", "A"], term!["!B"]]; | ||
assert_eq!(c3, c4); | ||
|
||
let c5 = clause![term!["A", "B"], term!["B"]]; | ||
let c6 = clause![term!["A"], term!["!B"]]; | ||
assert!(c5 != c6); | ||
} | ||
|
||
#[test] | ||
fn reduce_1() { | ||
let a = term!["A", "!B"]; | ||
let b = term!["C", "!D"]; | ||
let c = term!["E"]; | ||
|
||
let mut cl = clause![a, b, c]; | ||
cl.reduce(); | ||
|
||
/* We should no longer contain "E" */ | ||
assert!(! cl.contains(&term!["E"])); | ||
} | ||
|
||
#[test] | ||
fn reduce_2() { | ||
let a = term!["A", "!B"]; | ||
let b = term!["C", "!D"]; | ||
let c = term!["E"]; | ||
let d = term!["F"]; | ||
|
||
let mut cl = clause![a.clone(), b.clone(), c, d]; | ||
cl.reduce(); | ||
cl.reduce(); | ||
|
||
/* Should now look like {A, !B} & {C, !D} */ | ||
assert_eq!(cl, clause![a, b]); | ||
} | ||
|
||
|
||
#[test] | ||
fn count_symbols() { | ||
let cl = clause![ term!["A", "B"], | ||
term!["A", "!C"], | ||
term!["C"], | ||
term!["B"], | ||
term!["A"] | ||
]; | ||
|
||
// let clause = clause![a, b]; | ||
// unimplemented!(); | ||
let count = cl.count_symbols(); | ||
let a: i32 = *count.get(&symbol!["A"]).unwrap(); | ||
let b: i32 = *count.get(&symbol!["B"]).unwrap(); | ||
let c: i32 = *count.get(&symbol!["C"]).unwrap(); | ||
let nc: i32 = *count.get(&symbol!["!C"]).unwrap(); | ||
|
||
assert_eq!(a, 3); | ||
assert_eq!(b, 2); | ||
assert_eq!(c, 1); | ||
assert_eq!(nc, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
//! A module that handles unit testing for symbols | ||
#[allow(unused)] | ||
#![allow(unused)] | ||
|
||
use terms::*; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
//! A module that handles unit testing for terms | ||
#[allow(unused)] | ||
#![allow(unused)] | ||
|
||
use terms::*; | ||
|
||
|