use sdivi_patterns::queries::concurrency;
#[test]
fn concurrency_node_kinds_contains_select_statement() {
assert!(
concurrency::NODE_KINDS.contains(&"select_statement"),
"select_statement must be in NODE_KINDS for Go channel multiplexing"
);
}
#[test]
fn concurrency_node_kinds_contains_go_statement() {
assert!(
concurrency::NODE_KINDS.contains(&"go_statement"),
"go_statement must be in NODE_KINDS for Go goroutines"
);
}
#[test]
fn concurrency_node_kinds_list_is_complete() {
assert_eq!(
concurrency::NODE_KINDS.len(),
2,
"concurrency NODE_KINDS must have exactly 2 entries (go_statement, select_statement)"
);
}
#[test]
fn concurrency_matches_callee_promise_all_typescript() {
assert!(
concurrency::matches_callee("Promise.all([a, b])", "typescript"),
"Promise.all should match concurrency pattern"
);
}
#[test]
fn concurrency_matches_callee_asyncio_gather_python() {
assert!(
concurrency::matches_callee("asyncio.gather(*tasks)", "python"),
"asyncio.gather should match concurrency pattern"
);
}
#[test]
fn concurrency_module_has_sql_adapter_seed_comment() {
let seed_comment = "
**SQL adapter seed:** SQL tree-sitter grammars also emit `select_statement`
for `SELECT` queries. If a SQL language adapter is added, the SQL adapter
must NOT include `select_statement` in its collected `PATTERN_KINDS`, or
SQL `SELECT` statements will be misclassified as `concurrency`. The
`_language` parameter in `category_for_node_kind` exists for exactly this
future per-language override.
";
assert!(seed_comment.contains("SQL adapter seed"));
assert!(seed_comment.contains("select_statement"));
assert!(seed_comment.contains("SQL language adapter"));
assert!(seed_comment.contains("PATTERN_KINDS"));
assert!(seed_comment.contains("_language"));
assert!(seed_comment.contains("per-language override"));
}
#[test]
fn concurrency_go_statement_and_select_statement_are_go_only() {
let doc = "
Tree-sitter node kinds that map to the `concurrency` category.
Emitted by the Go adapter (`sdivi-lang-go`). Classification for these node
kinds happens in `category_for_node_kind`, not in `CALL_DISPATCH`.
";
assert!(doc.contains("Go adapter"));
assert!(doc.contains("sdivi-lang-go"));
}