summaryrefslogtreecommitdiff
path: root/chain/src/default.rs
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/default.rs')
-rw-r--r--chain/src/default.rs34
1 files changed, 30 insertions, 4 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs
index 697b997..b9d7fe6 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -432,7 +432,7 @@ impl Chain for DefaultChain {
type DerIter = DerIter;
- fn derive(&mut self, t: usize, pos: usize) -> Result<Self::DerIter, Self::Error> {
+ fn derive(&mut self, t: usize, _pos: usize) -> Result<Self::DerIter, Self::Error> {
use TNT::*;
/// Convert an error telling us that an index is out of bounds.
@@ -518,7 +518,7 @@ impl Chain for DefaultChain {
let parent = Parent::new(0, 0);
- for atom_child in atom_child_iter.clone() {
+ for atom_child in atom_child_iter {
let atom_child_accepting = chain.atom.is_accepting(atom_child).unwrap();
let atom_child_empty_node = chain.atom.is_empty_node(atom_child).unwrap();
@@ -763,6 +763,7 @@ mod test_chain {
for arg in std::env::args() {
let parse_as_digit: Result<usize, _> = arg.parse();
+ // just use the first number in the arguments
if let Ok(parse_result) = parse_as_digit {
result = parse_result;
@@ -798,11 +799,36 @@ mod test_chain {
dbg!(elapsed);
dbg!(chain.current());
- println!("index: terminal, history");
+ assert_eq!(input.len(), chain.history().len());
+
+ if std::fs::metadata("output/history").is_ok() {
+ std::fs::remove_file("output/history")?;
+ }
+
+ let mut history_file = std::fs::OpenOptions::new()
+ .create(true)
+ .write(true)
+ .open("output/history")?;
+
+ use std::fmt::Write;
+ use std::io::Write as IOWrite;
+
+ let mut log_string = String::new();
+
+ writeln!(&mut log_string, "index: terminal, history")?;
+
for (index, t) in input.iter().copied().enumerate().take(input.len() - 1) {
- println!("{index}: {t}, {}", chain.history().get(index).unwrap());
+ writeln!(
+ &mut log_string,
+ "{index}: {t}, {}",
+ chain.history().get(index).unwrap()
+ )?;
}
+ println!("Successfully logged to output/history");
+
+ history_file.write_all(log_string.as_bytes())?;
+
#[cfg(feature = "test-print-viz")]
{
chain.graph.print_viz("chain.gv")?;