Add @icase decorator
This commit is contained in:
@@ -106,6 +106,10 @@ mod tests {
|
||||
quoted = dq ("\\" ANY / !dq ANY)* dq;
|
||||
|
||||
case_sensitivity = "Strict " ('a'..'z')+ ", loose "i ('a'..'z'i)+;
|
||||
|
||||
@icase
|
||||
hex_config = "let " var_name " = 0x" ('a'..'f' / '0'..'9')+;
|
||||
var_name = "foo" / "bar"; // case must match
|
||||
}
|
||||
|
||||
fn parse<T: Fn(&mut ParseState) -> bool>(rule: T, s: &str) -> bool {
|
||||
@@ -194,4 +198,12 @@ mod tests {
|
||||
assert!(parse(case_sensitivity, "Strict abc, loose XYZ"));
|
||||
assert!(parse(case_sensitivity, "Strict abc, LoOsE XyZ"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_icase_decorator() {
|
||||
assert!(parse(hex_config, "let foo = 0xc0ffee"));
|
||||
assert!(parse(hex_config, "LET bar = 0XCAFE"));
|
||||
assert!(!parse(hex_config, "let Foo = 0xc0ffee"));
|
||||
assert!(!parse(hex_config, "let BAR = 0xcafe"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user