scryer-engine 0.3.0

Tree-sitter AST indexing and reference resolution engine for Scryer code intelligence
//! Recall conformance: the fixtures in `tests/recall/` mark every reference an index must
//! hold. Gaps not yet closed are `#[ignore]`d with the Plan 18 phase that closes them, so this
//! file doubles as the roadmap (`cargo test -- --ignored` lists what remains).

mod support;

use std::path::Path;

use scryer_engine::IndexOptions;
use support::recall::{self, Recall};

async fn score(language: &str) -> anyhow::Result<Recall> {
    let root = Path::new(env!("CARGO_MANIFEST_DIR"))
        .join("tests/recall")
        .join(language);
    recall::run(language, &root, IndexOptions::default()).await
}

fn assert_phases(recall: &Recall, phases: &[u32]) {
    let missed = recall.missed_in(phases);
    assert!(
        missed.is_empty(),
        "{}: {} of {} expected references missing for phases {phases:?}: {missed:#?}",
        recall.language,
        missed.len(),
        recall.expected_in(phases)
    );
}

#[tokio::test]
async fn rust_plain_constructs() -> anyhow::Result<()> {
    assert_phases(&score("rust").await?, &[0]);
    Ok(())
}

#[tokio::test]
async fn python_plain_constructs() -> anyhow::Result<()> {
    assert_phases(&score("python").await?, &[0]);
    Ok(())
}

#[tokio::test]
async fn typescript_plain_constructs() -> anyhow::Result<()> {
    assert_phases(&score("typescript").await?, &[0]);
    Ok(())
}

#[tokio::test]
async fn rust_calls_inside_macros() -> anyhow::Result<()> {
    assert_phases(&score("rust").await?, &[3]);
    Ok(())
}

#[tokio::test]
async fn function_used_as_a_value() -> anyhow::Result<()> {
    for language in ["rust", "python", "typescript"] {
        assert_phases(&score(language).await?, &[4]);
    }
    Ok(())
}

#[tokio::test]
async fn trait_paths_and_non_function_enclosing_symbols() -> anyhow::Result<()> {
    for language in ["rust", "python", "typescript"] {
        assert_phases(&score(language).await?, &[5]);
    }
    Ok(())
}