aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lua/template.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lua/template.rs b/src/lua/template.rs
index 99dfded..a5666a6 100644
--- a/src/lua/template.rs
+++ b/src/lua/template.rs
@@ -304,7 +304,6 @@ pub fn parse_call_args(text: &str) -> (ModuleFunction, std::vec::IntoIter<(ArgIn
CallInnerToken::Pipe => {
args.push(parse_arg(&arg, &mut idx));
arg = String::new();
- idx += 1;
}
}
}
@@ -331,3 +330,19 @@ pub fn parse_call_args(text: &str) -> (ModuleFunction, std::vec::IntoIter<(ArgIn
args.into_iter(),
)
}
+
+#[cfg(test)]
+mod test_parse_call_args {
+ use crate::lua::template::ArgIndex;
+
+ #[test]
+ fn test_anon_args() {
+ let (modfun, mut args) = super::parse_call_args("test|foo|bar|baz");
+ assert_eq!(modfun.function_name, "test");
+ assert_eq!(modfun.module_name, "default");
+ assert!(matches!(args.next(), Some((ArgIndex::Num(1), s)) if s == "foo"));
+ assert!(matches!(args.next(), Some((ArgIndex::Num(2), s)) if s == "bar"));
+ assert!(matches!(args.next(), Some((ArgIndex::Num(3), s)) if s == "baz"));
+ assert!(matches!(args.next(), None));
+ }
+}