diff options
Diffstat (limited to 'src/poem.rs')
-rw-r--r-- | src/poem.rs | 151 |
1 files changed, 145 insertions, 6 deletions
diff --git a/src/poem.rs b/src/poem.rs index a063a14..db57e55 100644 --- a/src/poem.rs +++ b/src/poem.rs @@ -67,10 +67,17 @@ mod tests { assert!(poem.is_ok()); let mut verses = poem.unwrap().into_iter(); let verse = verses.next().unwrap(); - assert_eq!(verse.io, Rune::Read); + assert!(verse.io.contains(&Rune::Read)); assert_eq!( verse.stanza, - vec!["lolcat", "<", "src/main.rs"] + vec!["lolcat"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.ip, + vec!["src/main.rs"] .iter() .map(|s| s.to_string()) .collect::<Vec<String>>() @@ -86,10 +93,76 @@ mod tests { assert!(poem.is_ok()); let mut verses = poem.unwrap().into_iter(); let verse = verses.next().unwrap(); - assert_eq!(verse.io, Rune::Write); + assert!(verse.io.contains(&Rune::Write)); assert_eq!( verse.stanza, - vec!["cat", "src/main.rs", "<", "/dev/null"] + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.op, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_write2_rune() { + let poem = Poem::read( + "cat src/main.rs 2> /dev/null".to_string(), + &Environment::new(), + ); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert!(verse.io.contains(&Rune::Write2)); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.ep, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_write_all_rune() { + let poem = Poem::read( + "cat src/main.rs &> /dev/null".to_string(), + &Environment::new(), + ); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert!(verse.io.contains(&Rune::WriteAll)); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.op, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.ep, + vec!["/dev/null"] .iter() .map(|s| s.to_string()) .collect::<Vec<String>>() @@ -105,10 +178,76 @@ mod tests { assert!(poem.is_ok()); let mut verses = poem.unwrap().into_iter(); let verse = verses.next().unwrap(); - assert_eq!(verse.io, Rune::Addendum); + assert!(verse.io.contains(&Rune::Addendum)); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.op, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_addendum2_rune() { + let poem = Poem::read( + "cat src/main.rs 2>> /dev/null".to_string(), + &Environment::new(), + ); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert!(verse.io.contains(&Rune::Addendum2)); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.ep, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_addendum_all_rune() { + let poem = Poem::read( + "cat src/main.rs &>> /dev/null".to_string(), + &Environment::new(), + ); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert!(verse.io.contains(&Rune::AddendumAll)); assert_eq!( verse.stanza, - vec!["cat", "src/main.rs", "<", "/dev/null"] + vec!["cat", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.op, + vec!["/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + assert_eq!( + verse.ep, + vec!["/dev/null"] .iter() .map(|s| s.to_string()) .collect::<Vec<String>>() |