aboutsummaryrefslogtreecommitdiff
path: root/src/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'src/makefile')
-rw-r--r--src/makefile/functions.rs96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs
index 9cd78f8..6e04b7a 100644
--- a/src/makefile/functions.rs
+++ b/src/makefile/functions.rs
@@ -373,6 +373,13 @@ mod test {
}
#[test]
+ fn strip() -> R {
+ let result = call!(strip " this is\tweirdly spaced text ");
+ assert_eq!(result, "this is weirdly spaced text");
+ Ok(())
+ }
+
+ #[test]
fn filter() -> R {
let result = call!(filter "word", "this contains a word inside it");
assert_eq!(result, "word");
@@ -447,6 +454,95 @@ mod test {
}
#[test]
+ fn test_if() -> R {
+ let mut macros = MacroSet::new();
+ macros.set(
+ "test1".to_owned(),
+ MacroSource::File,
+ TokenString::text("something"),
+ );
+ macros.set("test2".to_owned(), MacroSource::File, TokenString::text(""));
+
+ assert_eq!(
+ call(
+ "if",
+ &[
+ TokenString::r#macro("test1"),
+ TokenString::text("success"),
+ TokenString::r#macro("failed"),
+ ],
+ &macros
+ )?,
+ "success"
+ );
+ assert_eq!(
+ call(
+ "if",
+ &[
+ TokenString::r#macro("test2"),
+ "$(error failed)".parse()?,
+ TokenString::text("pass"),
+ ],
+ &macros
+ )?,
+ "pass"
+ );
+ Ok(())
+ }
+
+ #[test]
+ fn or() -> R {
+ assert_eq!(
+ call(
+ "or",
+ &[TokenString::text("yep"), TokenString::text("yeah")],
+ &MacroSet::new()
+ )?,
+ "yep"
+ );
+ assert_eq!(
+ call(
+ "or",
+ &[
+ TokenString::text(""),
+ TokenString::text("yeet"),
+ "$(error fail)".parse().unwrap()
+ ],
+ &MacroSet::new()
+ )?,
+ "yeet"
+ );
+
+ Ok(())
+ }
+
+ #[test]
+ fn and() -> R {
+ assert_eq!(
+ call(
+ "and",
+ &[TokenString::text("yep"), TokenString::text("yeah")],
+ &MacroSet::new()
+ )?,
+ "yeah"
+ );
+ assert_eq!(
+ call(
+ "and",
+ &[
+ TokenString::text("maybe"),
+ TokenString::text(""),
+ "$(error fail)".parse().unwrap()
+ ],
+ &MacroSet::new()
+ )?,
+ ""
+ );
+
+ Ok(())
+ }
+
+ #[test]
fn foreach() -> R {
let mut macros = MacroSet::new();
macros.set(