use paper_gap::{analyse, arxiv::Paper, report, repos::Repository};
fn result(title: &str, score: u32) -> report::PaperResult {
report::PaperResult {
paper: Paper {
id: title.into(),
title: title.into(),
abstract_text: "abstract".into(),
authors: vec!["Ada".into()],
published_date: Some("2026-01-01".into()),
updated_date: None,
doi: None,
arxiv_id: Some("2601.00001".into()),
url: "https://arxiv.org/abs/2601.00001".into(),
categories: vec!["cs.PL".into()],
extracted_methods: Vec::new(),
source_provider: "arxiv".into(),
},
code_links: Vec::new(),
repositories: Vec::new(),
repository_analyses: Vec::new(),
gap_assessment: analyse::GapAssessment {
implementation_gap_score: score,
components: analyse::ScoreComponents {
no_code_score: score,
..Default::default()
},
gaps: vec![analyse::Gap {
gap_type: analyse::GapType::NoPublicImplementationFound,
points: score,
explanation: "because".into(),
}],
},
}
}
#[test]
fn markdown_ranks_by_gap_score_and_explains_components() {
let scan = report::ScanReport {
paper_results: vec![result("low", 1), result("high", 50)],
};
let markdown = report::render(&scan, report::OutputFormat::Markdown).unwrap();
assert!(markdown.find("## 1. high").unwrap() < markdown.find("## 2. low").unwrap());
assert!(markdown.contains("Implementation gap score: 50"));
assert!(markdown.contains("no_code_score: 50"));
assert!(markdown.contains("NoPublicImplementationFound: +50 — because"));
}
#[test]
fn json_round_trips_scan_report() {
let scan = report::ScanReport {
paper_results: vec![result("paper", 50)],
};
let json = report::render(&scan, report::OutputFormat::Json).unwrap();
let parsed: report::ScanReport = serde_json::from_str(&json).unwrap();
assert_eq!(parsed.paper_results.len(), 1);
assert_eq!(
parsed.paper_results[0]
.gap_assessment
.implementation_gap_score,
50
);
}
#[test]
fn markdown_shows_repository_quality_signals() {
let mut result = result("paper", 10);
result.repositories.push(Repository {
forge: "github".into(),
url: "https://github.com/a/b".into(),
owner: "a".into(),
name: "b".into(),
description: None,
primary_language: Some("Rust".into()),
stars: None,
forks: None,
license: Some("MIT".into()),
archived: Some(false),
default_branch: Some("main".into()),
last_commit_date: None,
source_provider: "github".into(),
});
result
.repository_analyses
.push(analyse::RepositoryAnalysis {
has_readme: true,
has_license: true,
has_tests: true,
has_ci: true,
has_docs: true,
has_examples: true,
has_package_manifest: true,
has_reproducibility_scripts: true,
has_benchmarks: true,
is_notebook_only: false,
is_stale: false,
is_archived: false,
primary_language: Some("Rust".into()),
});
let markdown = report::render(
&report::ScanReport {
paper_results: vec![result],
},
report::OutputFormat::Markdown,
)
.unwrap();
assert!(markdown.contains("https://github.com/a/b (github)"));
assert!(
markdown.contains("README, license, tests, CI, docs, examples, package, repro, benchmarks")
);
}