pub struct Subtest<'a> {
pub name: Option<&'a str>,
pub plan: Plan<'a>,
pub body: Vec<Statement<'a>>,
}Expand description
Subtests provide a way to nest one TAP14 stream inside another. This may be used in a variety of ways, depending on
the test harness.
Fields§
§name: Option<&'a str>Name of the subtest, declared by a comment at the start of the Subtest.
plan: Plan<'a>§body: Vec<Statement<'a>>Implementations§
Source§impl<'a> Subtest<'a>
impl<'a> Subtest<'a>
pub fn parse(pairs: Pairs<'a, Rule>) -> Result<Self>
Sourcepub fn parse_from_str(content: &'a str) -> Result<Self>
pub fn parse_from_str(content: &'a str) -> Result<Self>
Parse Subtest from a &str.
§Examples
Parsing a TAP subtest may look like this:
use tapconsooomer::Subtest;
let content = concat!(
"# Subtest: foo\n",
" 1..2\n",
" ok 1 - bar\n",
" ok 2 - tuna\n",
);
let subtest = Subtest::parse_from_str(content).expect("Parser error");
assert_eq!(subtest.name, Some("foo"));
assert_eq!(subtest.plan.first, 1);
assert_eq!(subtest.plan.last, 2);
assert_eq!(subtest.body.len(), 2);Note, the comment declaring Subtest::name is optional:
use tapconsooomer::Subtest;
let content = concat!(
" 1..4\n",
" ok 1 - foo\n",
" ok 2 - bar\n",
" ok 3 - foobar\n",
" ok 4 - catfood\n",
);
let subtest = Subtest::parse_from_str(content).expect("Parser error");
assert_eq!(subtest.name.is_none(), true);
assert_eq!(subtest.plan.first, 1);
assert_eq!(subtest.plan.last, 4);
assert_eq!(subtest.body.len(), 4);So is the order in which Plan and Body are declared:
use tapconsooomer::Subtest;
let content = concat!(
" ok 1 - hello world\n",
" 1..1\n",
);
let subtest = Subtest::parse_from_str(content).expect("Parser error");
assert_eq!(subtest.name.is_none(), true);
assert_eq!(subtest.plan.first, 1);
assert_eq!(subtest.plan.last, 1);
assert_eq!(subtest.body.len(), 1);Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Subtest<'a>
impl<'a> RefUnwindSafe for Subtest<'a>
impl<'a> Send for Subtest<'a>
impl<'a> Sync for Subtest<'a>
impl<'a> Unpin for Subtest<'a>
impl<'a> UnwindSafe for Subtest<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more