-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
47 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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use serde_json; | ||
use scryer_prolog::machine::Machine; | ||
|
||
#[test] | ||
#[cfg_attr(miri, ignore = "it takes too long to run")] | ||
#[ignore = "uses old flawed interface"] | ||
fn integration_test() { | ||
let mut machine = Machine::new_lib(); | ||
|
||
// File with test commands, i.e. program code to consult and queries to run | ||
let code = include_str!("./lib_integration_test_commands.txt"); | ||
|
||
// Split the code into blocks | ||
let blocks = code.split("====="); | ||
|
||
let mut i = 0; | ||
let mut last_result: Option<_> = None; | ||
// Iterate over the blocks | ||
for block in blocks { | ||
// Trim the block to remove any leading or trailing whitespace | ||
let block = block.trim(); | ||
|
||
// Skip empty blocks | ||
if block.is_empty() { | ||
continue; | ||
} | ||
|
||
// Check if the block is a query | ||
if let Some(query) = block.strip_prefix("query") { | ||
// Parse and execute the query | ||
let result = machine.run_query(query.to_string()); | ||
assert!(result.is_ok()); | ||
|
||
last_result = Some(result); | ||
} else if let Some(code) = block.strip_prefix("consult") { | ||
// Load the code into the machine | ||
machine.consult_module_string("facts", code.to_string()); | ||
} else if let Some(result) = block.strip_prefix("result") { | ||
i += 1; | ||
if let Some(Ok(ref last_result)) = last_result { | ||
let _ = result; | ||
let _ = i; | ||
let _ = last_result; | ||
//println!("\n\n=====Result No. {i}=======\n{last_result}\n==============="); | ||
//assert_eq!(last_result.to_string(), result.to_string().trim(),) | ||
} | ||
} | ||
} | ||
} |