Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions test/suite/core/test_core.jl

This file was deleted.

21 changes: 21 additions & 0 deletions test/suite/core/test_core_types.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module TestCoreTypes

import Test
import CTBase.Core

const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true

function test_types()
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "Type aliases" begin
Test.@test Core.ctNumber == Real
Test.@test Core.ctNumber === Real
Test.@test 1 isa Core.ctNumber
Test.@test 1.0 isa Core.ctNumber
end
return nothing
end

end # module

test_core_types() = TestCoreTypes.test_types()
18 changes: 18 additions & 0 deletions test/suite/core/test_utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module TestCoreUtils

import Test
import CTBase.Core

const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true

function test_utils()
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "Default value of the display during resolution" begin
Test.@test Core.__display()
end
return nothing
end

end # module

test_utils() = TestCoreUtils.test_utils()
1 change: 1 addition & 0 deletions test/suite/descriptions/test_display_description.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module TestDisplayDescription

import Test
import CTBase.Descriptions: Descriptions

const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true
Expand Down
67 changes: 67 additions & 0 deletions test/suite/exceptions/test_exception_display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,73 @@ function test_exception_display()
Test.@test contains(output, "Suggestion:")
Test.@test contains(output, "Increase max iterations")
end

Test.@testset "IncorrectArgument - got without expected" begin
io = IOBuffer()
e = Exceptions.IncorrectArgument("wrong value", got="bad_value")
Test.@test_nowarn showerror(io, e)
output = String(take!(io))

Test.@test contains(output, "Got:")
Test.@test contains(output, "bad_value")
Test.@test !contains(output, "Expected:")
end

Test.@testset "AmbiguousDescription - diagnostic rendering" begin
# "empty catalog" branch
io = IOBuffer()
e = Exceptions.AmbiguousDescription(
(:a,); diagnostic="empty catalog"
)
Test.@test_nowarn showerror(io, e)
output = String(take!(io))
Test.@test contains(output, "Diagnostic:")
Test.@test contains(output, "Empty catalog")

# "unknown symbols" branch
io = IOBuffer()
e = Exceptions.AmbiguousDescription(
(:z,); diagnostic="unknown symbols"
)
Test.@test_nowarn showerror(io, e)
output = String(take!(io))
Test.@test contains(output, "Diagnostic:")
Test.@test contains(output, "Unknown symbols")

# "no complete match" branch
io = IOBuffer()
e = Exceptions.AmbiguousDescription(
(:a, :z); diagnostic="no complete match"
)
Test.@test_nowarn showerror(io, e)
output = String(take!(io))
Test.@test contains(output, "Diagnostic:")
Test.@test contains(output, "No complete match")

# else branch — arbitrary diagnostic value
io = IOBuffer()
e = Exceptions.AmbiguousDescription(
(:a,); diagnostic="custom diagnostic"
)
Test.@test_nowarn showerror(io, e)
output = String(take!(io))
Test.@test contains(output, "Diagnostic:")
Test.@test contains(output, "custom diagnostic")
end

Test.@testset "AmbiguousDescription - closest-matches inline suggestion" begin
io = IOBuffer()
e = Exceptions.AmbiguousDescription(
(:b, :f);
candidates=["(:a, :b, :c)", "(:a, :d, :e)", "(:x, :y, :z)"],
suggestion="Try one of the closest matches:",
)
Test.@test_nowarn showerror(io, e)
output = String(take!(io))

Test.@test contains(output, "closest matches")
Test.@test contains(output, "(:a, :b, :c)")
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ end

end # module

test_types() = TestExceptionTypes.test_exception_types()
test_exception_types() = TestExceptionTypes.test_exception_types()
64 changes: 64 additions & 0 deletions test/suite/exceptions/test_extension_error.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module TestExtensionError

import Test
import CTBase.Exceptions

const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
const SHOWTIMING = isdefined(Main, :TestOptions) ? Main.TestOptions.SHOWTIMING : true

function test_extension_error()
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "ExtensionError Contract Implementation" begin
# Test constructor throws if no dependencies provided
Test.@test_throws Exceptions.PreconditionError Exceptions.ExtensionError()

# Test enriched ExtensionError creation
e = Exceptions.ExtensionError(
:Documenter,
:Markdown;
message="to generate documentation",
feature="automatic documentation",
context="reference generation",
)

Test.@test e isa Exceptions.ExtensionError
Test.@test e.weakdeps == (:Documenter, :Markdown)
Test.@test e.msg == "missing dependencies to generate documentation"
Test.@test e.feature == "automatic documentation"
Test.@test e.context == "reference generation"
end

Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "ExtensionError Constructor Validation" begin
Test.@testset "No dependencies provided" begin
Test.@test_throws Exceptions.PreconditionError Exceptions.ExtensionError()

try
Exceptions.ExtensionError()
Test.@test false # Should not reach here
catch e
Test.@test e isa Exceptions.PreconditionError
Test.@test occursin("weak dependence", e.msg)
Test.@test occursin("ExtensionError called without dependencies", e.reason)
end
end

Test.@testset "Single dependency" begin
e = Exceptions.ExtensionError(:MyExt)
Test.@test e isa Exceptions.ExtensionError
Test.@test e.weakdeps == (:MyExt,)
Test.@test e.msg == "missing dependencies"
end

Test.@testset "Multiple dependencies with message" begin
e = Exceptions.ExtensionError(:Ext1, :Ext2; message="to enable feature X")
Test.@test e isa Exceptions.ExtensionError
Test.@test e.weakdeps == (:Ext1, :Ext2)
Test.@test e.msg == "missing dependencies to enable feature X"
end
end

return nothing
end

end # module

test_extension_error() = TestExtensionError.test_extension_error()
Loading
Loading