Created
September 3, 2018 01:29
-
-
Save eaglgenes101/1dfe6d343c780fd468be05d5a9b89d23 to your computer and use it in GitHub Desktop.
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
pub mod automaton; | |
pub mod state_machine; | |
pub mod move_state_machine; | |
#[cfg(test)] | |
mod tests { | |
use automaton::Automaton; | |
#[test] | |
fn fnmut_automaton_test() { | |
use std::ops::FnMut; | |
let mut i: i64 = 0; | |
let mut j: i64 = 1; | |
let k = Box::new(|r: &i64| { | |
i = j; | |
j = *r; | |
i | |
}) as Box<Automaton<i64, i64> + FnMut(i64) -> i64>; | |
/* | |
let mut a: i64 = 0; | |
let mut b: i64 = 1; | |
let s = |r: &i64| { | |
a = b; | |
b = *r; | |
a | |
} as Automaton<i64, i64>; | |
let k: Box<Automaton<i64, i64>> = w;*/ | |
assert!(k.transition(&3) == 1); | |
assert!(k.transition(&2) == 3); | |
assert!(k.transition(&6) == 2); | |
assert!(i == 2); | |
assert!(j == 6); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment