using SparseConnectivityTracer
using Test

using Aqua: Aqua
using JET: JET
using ExplicitImports: ExplicitImports

# Load package extensions so they get tested by ExplicitImports.jl
using ChainRulesCore: ChainRulesCore
using NaNMath: NaNMath
using NNlib: NNlib
using SpecialFunctions: SpecialFunctions

@testset "Aqua tests" begin
    @info "...with Aqua.jl"
    Aqua.test_all(
        SparseConnectivityTracer;
        ambiguities = false,
        undocumented_names = true,
    )
end

if VERSION > v"1.11" # JET v0.10 requires Julia v1.12
    @testset "JET tests" begin
        @info "...with JET.jl"
        JET.test_package(SparseConnectivityTracer; target_defined_modules = true)
    end
end

@testset "ExplicitImports tests" begin
    @info "...with ExplicitImports.jl"
    @testset "Improper implicit imports" begin
        @test ExplicitImports.check_no_implicit_imports(SparseConnectivityTracer) ===
            nothing
    end
    @testset "Improper explicit imports" begin
        @test ExplicitImports.check_no_stale_explicit_imports(
            SparseConnectivityTracer
        ) === nothing
        @test ExplicitImports.check_all_explicit_imports_via_owners(
            SparseConnectivityTracer
        ) === nothing
        # TODO: test in the future when `public` is more common
        # @test ExplicitImports.check_all_explicit_imports_are_public(
        #     SparseConnectivityTracer
        # ) === nothing
    end
    @testset "Improper qualified accesses" begin
        @test ExplicitImports.check_all_qualified_accesses_via_owners(
            SparseConnectivityTracer
        ) === nothing
        @test ExplicitImports.check_no_self_qualified_accesses(SparseConnectivityTracer) ===
            nothing
        # TODO: test in the future when `public` is more common
        # @test ExplicitImports.check_all_qualified_accesses_are_public(
        #     SparseConnectivityTracer
        # ) === nothing
    end
end
