use sdivi_patterns::queries::category_for_node_kind;
use sdivi_patterns::queries::concurrency;
use sdivi_patterns::queries::ALL_CATEGORIES;
#[test]
fn go_statement_maps_to_concurrency_category() {
let result = category_for_node_kind("go_statement", "go");
assert_eq!(
result,
Some("concurrency"),
"go_statement must map to concurrency category"
);
}
#[test]
fn select_statement_maps_to_concurrency_category() {
let result = category_for_node_kind("select_statement", "go");
assert_eq!(
result,
Some("concurrency"),
"select_statement must map to concurrency category"
);
}
#[test]
fn go_statement_language_parameter_ignored() {
assert_eq!(
category_for_node_kind("go_statement", "python"),
Some("concurrency")
);
assert_eq!(
category_for_node_kind("go_statement", "rust"),
Some("concurrency")
);
assert_eq!(
category_for_node_kind("go_statement", "typescript"),
Some("concurrency")
);
assert_eq!(
category_for_node_kind("select_statement", "python"),
Some("concurrency")
);
assert_eq!(
category_for_node_kind("select_statement", "rust"),
Some("concurrency")
);
assert_eq!(
category_for_node_kind("select_statement", "typescript"),
Some("concurrency")
);
}
#[test]
fn unknown_go_node_kinds_return_none() {
assert_eq!(category_for_node_kind("go_foo_statement", "go"), None);
assert_eq!(category_for_node_kind("unknown_node", "go"), None);
}
#[test]
fn defer_statement_maps_to_resource_management() {
assert_eq!(
category_for_node_kind("defer_statement", "go"),
Some("resource_management")
);
}
#[test]
fn all_concurrency_node_kinds_are_classified() {
for node_kind in concurrency::NODE_KINDS {
let result = category_for_node_kind(node_kind, "go");
assert_eq!(
result,
Some("concurrency"),
"{} should be classified as concurrency",
node_kind
);
}
}
#[test]
fn go_statement_not_misclassified() {
for cat in ALL_CATEGORIES {
if *cat == "concurrency" {
assert_eq!(
category_for_node_kind("go_statement", "go"),
Some("concurrency"),
"go_statement must map to concurrency"
);
} else {
assert_ne!(
category_for_node_kind("go_statement", "go"),
Some(*cat),
"go_statement must not map to {}",
cat
);
}
}
}