summaryrefslogtreecommitdiff
path: root/src/steps.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-01-06 11:54:50 +0200
committerLars Wirzenius <liw@liw.fi>2020-01-06 12:02:05 +0200
commita5854b22214b229644014d88a5f5ef9fd7f86d64 (patch)
treed0650eea70c29c11fc74ea23f65d06b25a042e42 /src/steps.rs
parent8cf12026479d68bc54e846a3d08f84685fc066c1 (diff)
downloadsubplot-a5854b22214b229644014d88a5f5ef9fd7f86d64.tar.gz
Add: progress reporting in generated test program
Diffstat (limited to 'src/steps.rs')
-rw-r--r--src/steps.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/steps.rs b/src/steps.rs
index 1a70ce4..7df6dda 100644
--- a/src/steps.rs
+++ b/src/steps.rs
@@ -1,4 +1,5 @@
use crate::{Error, Result};
+use std::fmt;
/// A scenario step.
///
@@ -57,6 +58,12 @@ impl ScenarioStep {
}
}
+impl fmt::Display for ScenarioStep {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{} {}", self.kind(), self.text())
+ }
+}
+
/// The kind of scenario step we have: given, when, or then.
///
/// This needs to be extended if the Subplot language gets extended with other
@@ -74,6 +81,17 @@ pub enum StepKind {
Then,
}
+impl fmt::Display for StepKind {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let s = match self {
+ StepKind::Given => "given",
+ StepKind::When => "when",
+ StepKind::Then => "then",
+ };
+ write!(f, "{}", s)
+ }
+}
+
#[cfg(test)]
mod test {
use super::{ScenarioStep, StepKind};