use super::*;
#[test]
fn dotted_source_identifier_suppresses_camel_passwd_segment() {
assert!(
looks_like_dotted_source_identifier("userDb.passwd.value"),
"camel-cased dotted candidate with a passwd segment must be a source identifier",
);
}
#[test]
fn dotted_passwd_without_camel_or_receiver_does_not_suppress() {
assert!(
!looks_like_dotted_source_identifier("db.passwd.field"),
"a flat passwd dotted path with no camel segment must not be suppressed",
);
}
#[test]
fn dotted_source_identifier_segment_count_and_body_bounds() {
assert!(!looks_like_dotted_source_identifier("aB.cD.eF.gH.iJ.kL"));
assert!(!looks_like_dotted_source_identifier("userDbPasswd"));
assert!(!looks_like_dotted_source_identifier("userDb..passwd"));
assert!(!looks_like_dotted_source_identifier("userDb.pass-wd.value"));
}
#[test]
fn dotted_source_identifier_receiver_first_segment() {
assert!(looks_like_dotted_source_identifier(&format!(
"{}.field",
SOURCE_RECEIVERS[0].as_str()
)));
}
#[test]
fn generated_template_interpolation_prefix_is_source_syntax() {
let randomness = TokenRandomness::for_candidate("__vlist$");
assert!(looks_like_source_code_expression_with_randomness(
"__vlist$",
&randomness
));
assert!(!looks_like_template_interpolation_prefix("realSecret$"));
}
#[test]
fn indexed_javascript_length_expression_is_source_syntax() {
for value in [
"_a8fe8b046732.length]))",
"_715561396085.length]))",
"$715561396085.length])",
] {
let randomness = TokenRandomness::for_candidate(value);
assert!(looks_like_source_code_expression_with_randomness(
value,
&randomness
));
}
for value in [
"_a8fe8b046732.length",
"opaque-key.length]))",
"_a8fe8b046732.length]))suffix",
"715561396085.length]))",
] {
let randomness = TokenRandomness::for_candidate(value);
assert!(!looks_like_source_code_expression_with_randomness(
value,
&randomness
));
}
}