aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r--src/makefile/token.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs
index 22ef24a..508a779 100644
--- a/src/makefile/token.rs
+++ b/src/makefile/token.rs
@@ -271,6 +271,8 @@ impl FromStr for TokenString {
mod test {
use super::{tokenize, Token, TokenString};
+ type R = anyhow::Result<()>;
+
impl From<Vec<Token>> for TokenString {
fn from(x: Vec<Token>) -> Self {
TokenString(x)
@@ -300,16 +302,17 @@ mod test {
}
#[test]
- fn no_macros() {
+ fn no_macros() -> R {
let text = "This is an example sentence! There aren't macros in it at all!";
- let tokens = tokenize(text);
+ let tokens = tokenize(text)?;
assert_eq!(tokens, TokenString(vec![token_text(text)]));
+ Ok(())
}
#[test]
- fn no_replacement() {
+ fn no_replacement() -> R {
let text = "This is a $Q sentence! There are $(BORING) macros in it at ${YEET}!";
- let tokens = tokenize(text);
+ let tokens = tokenize(text)?;
assert_eq!(
tokens,
TokenString(vec![
@@ -322,12 +325,13 @@ mod test {
token_text("!"),
])
);
+ Ok(())
}
#[test]
- fn escaped() {
+ fn escaped() -> R {
let text = "This costs $$2 to run, which isn't ideal";
- let tokens = tokenize(text);
+ let tokens = tokenize(text)?;
assert_eq!(
tokens,
TokenString(vec![
@@ -336,12 +340,13 @@ mod test {
token_text("2 to run, which isn't ideal"),
])
);
+ Ok(())
}
#[test]
- fn replacement() {
+ fn replacement() -> R {
let text = "Can I get a $(DATA:.c=.oof) in this ${SWAG:.yolo=}";
- let tokens = tokenize(text);
+ let tokens = tokenize(text)?;
assert_eq!(
tokens,
TokenString(vec![
@@ -359,12 +364,13 @@ mod test {
),
])
);
+ Ok(())
}
#[test]
- fn hell() {
+ fn hell() -> R {
let text = "$(OOF:${ouch:hi=hey} there=$(owie:$(my)=${bones})), bro.";
- let tokens = tokenize(text);
+ let tokens = tokenize(text)?;
assert_eq!(
tokens,
TokenString(vec![
@@ -387,5 +393,6 @@ mod test {
token_text(", bro."),
])
);
+ Ok(())
}
}