aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xixanta/src')
-rw-r--r--lib/xixanta/src/node.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs
index 357b9e0..dac131a 100644
--- a/lib/xixanta/src/node.rs
+++ b/lib/xixanta/src/node.rs
@@ -69,6 +69,8 @@ impl PString {
if c > 'f' && c <= 'z' {
valid_hex = false;
}
+ } else {
+ valid_hex = false;
}
}
@@ -512,4 +514,29 @@ mod tests {
assert_eq!(is_asan_friendly_name(&string), expect);
}
}
+
+ #[test]
+ fn is_valid_identifier() {
+ let tests = vec![
+ ("", false),
+ ("valid", true),
+ ("invalid::scoped", false),
+ ("x", false),
+ ("aaaa", false),
+ ("123", false),
+ ("@aa", true),
+ ];
+
+ for (name, expect) in tests {
+ let ps = PString {
+ value: name.to_string(),
+ line: 0,
+ start: 0,
+ end: 0,
+ };
+
+ let res = ps.is_valid_identifier(false).is_ok();
+ assert_eq!(res, expect);
+ }
+ }
}