Support SELF keyword in Podlang parser (#368)

* Support SELF keyword in Podlang parser

* Add pretty-printing for SELF
This commit is contained in:
Rob Knight 2025-07-30 01:35:48 +01:00 committed by GitHub
parent 0606a4098b
commit c7b39f21f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 39 additions and 5 deletions

View file

@ -34,7 +34,7 @@ mod tests {
middleware::{
hash_str, CustomPredicate, CustomPredicateBatch, CustomPredicateRef, Key,
NativePredicate, Params, PodId, PodType, Predicate, RawValue, StatementTmpl,
StatementTmplArg, Value, Wildcard, KEY_SIGNER, KEY_TYPE,
StatementTmplArg, Value, Wildcard, KEY_SIGNER, KEY_TYPE, SELF,
},
};
@ -877,6 +877,7 @@ mod tests {
Equal(?E["int"], {})
Equal(?F["bool"], {})
Equal(?G["sk"], {})
Equal(?H["self"], SELF)
)
"#,
Value::from(pk).to_podlang_string(),
@ -895,6 +896,8 @@ mod tests {
Equal(?D["string"], "hello")
Equal(?E["int"], 123)
Equal(?F["bool"], true)
Equal(?G["sk"], SecretKey(random_secret_key_base_64))
Equal(?H["self"], SELF)
)
*/
@ -902,8 +905,6 @@ mod tests {
let processed = parse(&input, &params, &[])?;
let request_templates = processed.request_templates;
assert_eq!(request_templates.len(), 7);
let expected_templates = vec![
StatementTmpl {
pred: Predicate::Native(NativePredicate::Equal),
@ -933,6 +934,10 @@ mod tests {
pred: Predicate::Native(NativePredicate::Equal),
args: vec![sta_ak(("G", 6), "sk"), sta_lit(Value::from(sk))],
},
StatementTmpl {
pred: Predicate::Native(NativePredicate::Equal),
args: vec![sta_ak(("H", 7), "self"), sta_lit(Value::from(SELF))],
},
];
assert_eq!(request_templates, expected_templates);