Skip to content

Commit

Permalink
Fixes #23377: rudderc parses ncf_const.s as const.s
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Sep 4, 2023
1 parent 202694f commit d640aa0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion policies/rudderc/src/ir/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn ncf_const(s: &str) -> IResult<&str, Expression> {
terminated(
map(
|s| expression(s, true),
|out| Expression::Const(Box::new(out)),
|out| Expression::NcfConst(Box::new(out)),
),
char('}'),
),
Expand Down Expand Up @@ -503,6 +503,11 @@ mod tests {
out,
Expression::Const(Box::new(Expression::Scalar("dollar".to_string())))
);
let out: Expression = "${ncf_const.s}".parse().unwrap();
assert_eq!(
out,
Expression::NcfConst(Box::new(Expression::Scalar("s".to_string())))
);
let out: Expression = "${sys.interface_flags[eth0]}".parse().unwrap();
assert_eq!(
out,
Expand Down Expand Up @@ -559,6 +564,15 @@ mod tests {
);
}

#[test]
fn it_reads_vcf_const_var() {
let (_, out) = ncf_const("${ncf_const.s}").unwrap();
assert_eq!(
out,
Expression::NcfConst(Box::new(Expression::Scalar("s".to_string())))
);
}

#[test]
fn it_reads_parameters() {
let (_, out) = parameter("${rudder.parameters[plouf]}").unwrap();
Expand Down

0 comments on commit d640aa0

Please sign in to comment.