in src/metrics/cognitive.rs [883:925]
fn mozjs_sequence_same_booleans() {
check_metrics::<MozjsParser>(
"function f() {
if (a && b && 1 == 1) { // +2 (+1 sequence of &&)
window.print(\"test\");
}
}",
"foo.js",
|metric| {
insta::assert_json_snapshot!(
metric.cognitive,
@r###"
{
"sum": 2.0,
"average": 2.0,
"min": 0.0,
"max": 2.0
}"###
);
},
);
check_metrics::<MozjsParser>(
"function f() {
if (a || b || c || d) { // +2 (+1 sequence of ||)
window.print(\"test\");
}
}",
"foo.js",
|metric| {
insta::assert_json_snapshot!(
metric.cognitive,
@r###"
{
"sum": 2.0,
"average": 2.0,
"min": 0.0,
"max": 2.0
}"###
);
},
);
}