-
Notifications
You must be signed in to change notification settings - Fork 2
Incorporate test interface.jl using GraphsInterfaceChecker #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# test_interface_igraphs_containers.jl | ||
# Pattern inspired by NautyGraphs' interface test, adapted to test the | ||
# IGraphs container interfaces using GraphsInterfaceChecker. | ||
|
||
using Test | ||
using GraphsInterfaceChecker # brings in interface definitions & helpers | ||
using Interfaces | ||
import BaseInterfaces # IterationInterface, ArrayInterface traits | ||
using IGraphs | ||
|
||
@testset "interface (IGraphs base containers)" begin | ||
# === Vector-like interface checks (IGraphs.vtypes) === | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests seem to already exist elsewhere in the code base. No need to repeat them. This seems to actually copy a lot of these existing tests. |
||
for (VTs, ET, _) in IGraphs.vtypes | ||
VT = eval(VTs) | ||
|
||
# Provide example instances to the checker | ||
v_samples = [VT(rand(ET, 10))] | ||
|
||
# Declare conformance (mirrors NautyGraphs pattern) | ||
@implements BaseInterfaces.IterationInterface VT v_samples | ||
@implements BaseInterfaces.IterationInterface{(:indexing,)} VT v_samples | ||
@implements BaseInterfaces.ArrayInterface VT v_samples | ||
@implements BaseInterfaces.ArrayInterface{(:logical,:setindex!)} VT v_samples | ||
|
||
# Run the interface tests | ||
@test Interfaces.test(BaseInterfaces.IterationInterface, VT, v_samples) | ||
@test Interfaces.test(BaseInterfaces.IterationInterface{(:indexing,)}, VT, v_samples) | ||
@test Interfaces.test(BaseInterfaces.ArrayInterface, VT, v_samples) | ||
@test Interfaces.test(BaseInterfaces.ArrayInterface{(:logical,:setindex!)}, VT, v_samples) | ||
|
||
# Round-trip conversion checks (from IGraphs test_interfaces) | ||
v = VT(rand(ET, 10)) | ||
@test Vector(VT(Vector(v))) == Vector(v) | ||
@test VT(Vector(v)) == v | ||
end | ||
|
||
# === Matrix-like interface checks (IGraphs.mtypes) === | ||
for (MTs, ET, _) in IGraphs.mtypes | ||
MT = eval(MTs) | ||
|
||
m_samples = [MT(rand(ET, 10, 5))] | ||
|
||
# Declare conformance | ||
@implements BaseInterfaces.IterationInterface MT m_samples | ||
@implements BaseInterfaces.IterationInterface{(:indexing,)} MT m_samples | ||
@implements BaseInterfaces.ArrayInterface MT m_samples | ||
@implements BaseInterfaces.ArrayInterface{(:logical,:setindex!)} MT m_samples | ||
|
||
# Run the interface tests | ||
@test Interfaces.test(BaseInterfaces.IterationInterface, MT, m_samples) | ||
@test Interfaces.test(BaseInterfaces.IterationInterface{(:indexing,)}, MT, m_samples) | ||
@test Interfaces.test(BaseInterfaces.ArrayInterface, MT, m_samples) | ||
@test Interfaces.test(BaseInterfaces.ArrayInterface{(:logical,:setindex!)}, MT, m_samples) | ||
|
||
# Round-trip conversion checks | ||
m = MT(rand(ET, 10, 5)) | ||
@test Matrix(MT(Matrix(m))) == Matrix(m) | ||
@test MT(Matrix(m)) == m | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
using IGraphs | ||
using TestItemRunner | ||
|
||
|
||
include("interface.jl") # NEW | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not necessary, we are using TestItemRunner.jl which picks tests up automatically as long as they are marked appropriately. Check out its docs. |
||
|
||
# filter for the test | ||
testfilter = ti -> begin | ||
exclude = Symbol[] | ||
|
@@ -17,4 +20,4 @@ end | |
|
||
println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...") | ||
|
||
@run_package_tests filter=testfilter | ||
@run_package_tests filter=testfilter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your editor seems to have removed the ending newline in the file. Stack overflow has a good discussion about why ending newlines are important and why tools like github mark their omission with a warning sign. You can also set up your editor in a way that ensures that ending newlines are always present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid superfluous comments. LLMs in particular generate a lot of unhelpful and occasionally misleading comments. If the code is obvious, there should be no comments.