diff options
-rw-r--r-- | src/poem.rs | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/src/poem.rs b/src/poem.rs index db51d16..069fb79 100644 --- a/src/poem.rs +++ b/src/poem.rs @@ -59,52 +59,56 @@ mod tests { assert_eq!(poem.first().unwrap().meter, Rune::Continue); } - // #[test] - // fn it_parses_verse_with_the_read_meter() { - // let poem = Poem::read("lolcat < src/main.rs".to_string()); - // assert!(poem.is_ok()); - // let mut verses = poem.unwrap().into_iter(); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.verb(), "lolcat"); - // assert_eq!(verse.meter, Rune::Read); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.stanza, vec!["src/main.rs".to_string()]); - // } - - // #[test] - // fn it_parses_verse_with_the_write_meter() { - // let poem = Poem::read("cat src/main.rs > /dev/null".to_string()); - // assert!(poem.is_ok()); - // let mut verses = poem.unwrap().into_iter(); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.verb(), "cat"); - // assert_eq!(verse.clause().unwrap(), vec!["src/main.rs".to_string()]); - // assert_eq!(verse.meter, Rune::Write); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.stanza, vec!["/dev/null".to_string()]); - // } - - // #[test] - // fn it_parses_verse_with_the_addenum_meter() { - // let poem = Poem::read("cat src/main.rs >> /dev/null".to_string()); - // assert!(poem.is_ok()); - // let mut verses = poem.unwrap().into_iter(); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.verb(), "cat"); - // assert_eq!(verse.clause().unwrap(), vec!["src/main.rs".to_string()]); - // assert_eq!(verse.meter, Rune::Addendum); - - // let verse = verses.next().unwrap(); - // assert_eq!(verse.stanza, vec!["/dev/null".to_string()]); - // } + #[test] + fn it_parses_a_verse_with_the_read_rune() { + let poem = Poem::read("lolcat < src/main.rs".to_string()); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert_eq!(verse.io, Rune::Read); + assert_eq!( + verse.stanza, + vec!["lolcat", "<", "src/main.rs"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_write_rune() { + let poem = Poem::read("cat src/main.rs > /dev/null".to_string()); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert_eq!(verse.io, Rune::Write); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs", "<", "/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } + + #[test] + fn it_parses_a_verse_with_the_addendum_rune() { + let poem = Poem::read("cat src/main.rs >> /dev/null".to_string()); + assert!(poem.is_ok()); + let mut verses = poem.unwrap().into_iter(); + let verse = verses.next().unwrap(); + assert_eq!(verse.io, Rune::Addendum); + assert_eq!( + verse.stanza, + vec!["cat", "src/main.rs", "<", "/dev/null"] + .iter() + .map(|s| s.to_string()) + .collect::<Vec<String>>() + ); + } #[test] - fn it_throws_a_parse_error_if_no_files_are_specified_for_the_read_meter() { + fn it_throws_a_parse_error_if_no_files_are_specified_for_the_read_rune() { let poem = Poem::read("lolcat <".to_string()); assert!(poem.is_err()); let poem = Poem::read("lolcat <;".to_string()); @@ -114,7 +118,7 @@ mod tests { } #[test] - fn it_throws_a_parse_error_if_no_files_are_specified_for_the_write_meter() { + fn it_throws_a_parse_error_if_no_files_are_specified_for_the_write_rune() { let poem = Poem::read("cat src/main.rs >".to_string()); assert!(poem.is_err()); let poem = Poem::read("cat src/main.rs >;".to_string()); @@ -124,7 +128,7 @@ mod tests { } #[test] - fn it_throws_a_parse_error_if_no_files_are_specified_for_the_addendum_meter() { + fn it_throws_a_parse_error_if_no_files_are_specified_for_the_addendum_rune() { let poem = Poem::read("cat src/main.rs >>".to_string()); assert!(poem.is_err()); let poem = Poem::read("cat src/main.rs >>;".to_string()); |