Skip to content

Commit 64155c4

Browse files
authored
Merge pull request #447 from control-toolbox/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents 34765d3 + fbe4c44 commit 64155c4

35 files changed

Lines changed: 270 additions & 208 deletions

src/Exceptions/display.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Apply dimmed (faint) ANSI styling to a string.
1212
# Returns
1313
- `String`: The string wrapped in dim ANSI escape codes.
1414
"""
15-
_dim(s) = "\033[2m$(s)\033[0m"
15+
_dim(s) = "\033[2m$(s)\033[0m"
1616

1717
"""
1818
$(TYPEDSIGNATURES)
@@ -25,7 +25,7 @@ Apply bold ANSI styling to a string.
2525
# Returns
2626
- `String`: The string wrapped in bold ANSI escape codes.
2727
"""
28-
_bold(s) = "\033[1m$(s)\033[0m"
28+
_bold(s) = "\033[1m$(s)\033[0m"
2929

3030
"""
3131
$(TYPEDSIGNATURES)
@@ -38,7 +38,7 @@ Apply red ANSI styling to a string.
3838
# Returns
3939
- `String`: The string wrapped in red ANSI escape codes.
4040
"""
41-
_red(s) = "\033[1;31m$(s)\033[0m"
41+
_red(s) = "\033[1;31m$(s)\033[0m"
4242

4343
"""
4444
$(TYPEDSIGNATURES)
@@ -64,7 +64,7 @@ Apply green ANSI styling to a string.
6464
# Returns
6565
- `String`: The string wrapped in green ANSI escape codes.
6666
"""
67-
_green(s) = "\033[32m$(s)\033[0m"
67+
_green(s) = "\033[32m$(s)\033[0m"
6868

6969
"""
7070
extract_user_frames(st::Vector)
@@ -136,7 +136,7 @@ Build primary field `(label, value, color)` tuples for `IncorrectArgument` displ
136136
"""
137137
function _build_primary_pairs(e::IncorrectArgument)
138138
pairs = []
139-
!isnothing(e.got) && push!(pairs, ("Got", string(e.got), :yellow))
139+
!isnothing(e.got) && push!(pairs, ("Got", string(e.got), :yellow))
140140
!isnothing(e.expected) && push!(pairs, ("Expected", string(e.expected), :green))
141141
return pairs
142142
end
@@ -177,7 +177,8 @@ Build primary field `(label, value, color)` tuples for `NotImplemented` display.
177177
"""
178178
function _build_primary_pairs(e::NotImplemented)
179179
pairs = []
180-
!isnothing(e.required_method) && push!(pairs, ("Method", string(e.required_method), :default))
180+
!isnothing(e.required_method) &&
181+
push!(pairs, ("Method", string(e.required_method), :default))
181182
return pairs
182183
end
183184

@@ -218,7 +219,8 @@ Build primary field `(label, value, color)` tuples for `AmbiguousDescription` di
218219
"""
219220
function _build_primary_pairs(e::AmbiguousDescription)
220221
pairs = []
221-
!isnothing(e.diagnostic) && push!(pairs, ("Diagnostic", _format_diagnostic(e.diagnostic), :yellow))
222+
!isnothing(e.diagnostic) &&
223+
push!(pairs, ("Diagnostic", _format_diagnostic(e.diagnostic), :yellow))
222224
push!(pairs, ("Requested", string(e.description), :default))
223225
if !isnothing(e.candidates) && !isempty(e.candidates)
224226
push!(pairs, ("Available", e.candidates, :default))
@@ -283,8 +285,12 @@ Build secondary field `(label, value, color)` tuples for generic `CTException` d
283285
"""
284286
function _build_secondary_pairs(e::CTException)
285287
pairs = []
286-
hasfield(typeof(e), :context) && !isnothing(e.context) && push!(pairs, ("Context", e.context, :default))
287-
hasfield(typeof(e), :suggestion) && !isnothing(e.suggestion) && push!(pairs, ("Hint", e.suggestion, :green))
288+
hasfield(typeof(e), :context) &&
289+
!isnothing(e.context) &&
290+
push!(pairs, ("Context", e.context, :default))
291+
hasfield(typeof(e), :suggestion) &&
292+
!isnothing(e.suggestion) &&
293+
push!(pairs, ("Hint", e.suggestion, :green))
288294
return pairs
289295
end
290296

@@ -404,7 +410,7 @@ function _format_user_friendly_error(io::IO, e::CTException)
404410
println(io, _dim(""), " ", _bold(e.msg))
405411

406412
# Build field pairs
407-
primary_pairs = _build_primary_pairs(e)
413+
primary_pairs = _build_primary_pairs(e)
408414
secondary_pairs = _build_secondary_pairs(e)
409415
all_pairs = vcat(primary_pairs, secondary_pairs)
410416

@@ -432,7 +438,7 @@ function _format_user_friendly_error(io::IO, e::CTException)
432438
end
433439

434440
# Closing visual
435-
println(io, _dim("└─"))
441+
return println(io, _dim("└─"))
436442
end
437443

438444
"""

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# See test/README.md for usage instructions (running specific tests, coverage, etc.)
66
#
77
# ==============================================================================
8-
import Test
9-
import CTBase
8+
using Test: Test
9+
using CTBase: CTBase
1010

1111
# Controls nested testset output formatting (used by individual test files)
1212
module TestOptions

test/suite/core/test_core_types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestCoreTypes
22

3-
import Test
3+
using Test: Test
44
import CTBase.Core
55

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

test/suite/core/test_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestCoreUtils
22

3-
import Test
3+
using Test: Test
44
import CTBase.Core
55

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

test/suite/descriptions/test_catalog.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestCatalog
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions
55
import CTBase.Exceptions
66

@@ -90,8 +90,10 @@ function test_catalog()
9090

9191
Test.@testset "Type stability - add function" begin
9292
# Add to empty catalog
93-
Test.@test (Test.@inferred Descriptions.add((), (:a,))) isa Tuple{Vararg{Descriptions.Description}}
94-
Test.@test (Test.@inferred Descriptions.add((), (:a, :b))) isa Tuple{Vararg{Descriptions.Description}}
93+
Test.@test (Test.@inferred Descriptions.add((), (:a,))) isa
94+
Tuple{Vararg{Descriptions.Description}}
95+
Test.@test (Test.@inferred Descriptions.add((), (:a, :b))) isa
96+
Tuple{Vararg{Descriptions.Description}}
9597

9698
# Add to non-empty catalog
9799
descriptions = ((:a,),)
@@ -112,7 +114,9 @@ function test_catalog()
112114
algorithms = Descriptions.add(algorithms, (:a, :b, :c))
113115

114116
# Basic error check
115-
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(algorithms, (:a, :b, :c))
117+
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(
118+
algorithms, (:a, :b, :c)
119+
)
116120

117121
# Enriched error check - verify all exception fields
118122
try
@@ -132,13 +136,19 @@ function test_catalog()
132136
descriptions = ((:a,), (:b,), (:c,))
133137

134138
# Try to add duplicate of first
135-
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(descriptions, (:a,))
139+
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(
140+
descriptions, (:a,)
141+
)
136142

137143
# Try to add duplicate of middle
138-
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(descriptions, (:b,))
144+
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(
145+
descriptions, (:b,)
146+
)
139147

140148
# Try to add duplicate of last
141-
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(descriptions, (:c,))
149+
Test.@test_throws Exceptions.IncorrectArgument Descriptions.add(
150+
descriptions, (:c,)
151+
)
142152
end
143153

144154
Test.@testset "Return type consistency" begin

test/suite/descriptions/test_complete.jl

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestComplete
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions
55
import CTBase.Exceptions
66

@@ -36,7 +36,8 @@ function test_complete()
3636
algorithms = ()
3737
algorithms = Descriptions.add(algorithms, (:a, :b, :c))
3838
algorithms = Descriptions.add(algorithms, (:a, :b, :c, :d))
39-
Test.@test Descriptions.complete((:a, :b); descriptions=algorithms) == (:a, :b, :c)
39+
Test.@test Descriptions.complete((:a, :b); descriptions=algorithms) ==
40+
(:a, :b, :c)
4041
Test.@test Descriptions.complete((:a, :b, :c, :d); descriptions=algorithms) ==
4142
(:a, :b, :c, :d)
4243
end
@@ -46,12 +47,14 @@ function test_complete()
4647
algos_swapped = ()
4748
algos_swapped = Descriptions.add(algos_swapped, (:a, :b, :c, :d))
4849
algos_swapped = Descriptions.add(algos_swapped, (:a, :b, :c))
49-
Test.@test Descriptions.complete((:a, :b); descriptions=algos_swapped) == (:a, :b, :c, :d)
50+
Test.@test Descriptions.complete((:a, :b); descriptions=algos_swapped) ==
51+
(:a, :b, :c, :d)
5052

5153
algos_ordered = ()
5254
algos_ordered = Descriptions.add(algos_ordered, (:a, :b, :c))
5355
algos_ordered = Descriptions.add(algos_ordered, (:a, :b, :c, :d))
54-
Test.@test Descriptions.complete((:a, :b); descriptions=algos_ordered) == (:a, :b, :c)
56+
Test.@test Descriptions.complete((:a, :b); descriptions=algos_ordered) ==
57+
(:a, :b, :c)
5558
end
5659

5760
Test.@testset "Successful completion with exact and partial matches" begin
@@ -134,16 +137,20 @@ function test_complete()
134137
descriptions = ((:a, :b), (:a, :c), (:b, :c))
135138

136139
# Varargs overload
137-
Test.@test (Test.@inferred Descriptions.complete(:a; descriptions=descriptions)) isa
138-
Descriptions.Description
139-
Test.@test (Test.@inferred Descriptions.complete(:a, :b; descriptions=descriptions)) isa
140-
Descriptions.Description
140+
Test.@test (Test.@inferred Descriptions.complete(
141+
:a; descriptions=descriptions
142+
)) isa Descriptions.Description
143+
Test.@test (Test.@inferred Descriptions.complete(
144+
:a, :b; descriptions=descriptions
145+
)) isa Descriptions.Description
141146

142147
# Tuple overload
143-
Test.@test (Test.@inferred Descriptions.complete((:a,); descriptions=descriptions)) isa
144-
Descriptions.Description
145-
Test.@test (Test.@inferred Descriptions.complete((:a, :b); descriptions=descriptions)) isa
146-
Descriptions.Description
148+
Test.@test (Test.@inferred Descriptions.complete(
149+
(:a,); descriptions=descriptions
150+
)) isa Descriptions.Description
151+
Test.@test (Test.@inferred Descriptions.complete(
152+
(:a, :b); descriptions=descriptions
153+
)) isa Descriptions.Description
147154

148155
# Verify return type consistency
149156
result = Descriptions.complete(:a; descriptions=descriptions)
@@ -161,7 +168,9 @@ function test_complete()
161168
)
162169

163170
# Empty catalog
164-
Test.@test_throws Exceptions.AmbiguousDescription Descriptions.complete(:a; descriptions=())
171+
Test.@test_throws Exceptions.AmbiguousDescription Descriptions.complete(
172+
:a; descriptions=()
173+
)
165174

166175
# Enriched error checks - rigorous
167176

test/suite/descriptions/test_description_types.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestDescriptionTypes
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions
55

66
const VERBOSE = isdefined(Main, :TestOptions) ? Main.TestOptions.VERBOSE : true
@@ -106,7 +106,8 @@ function test_description_types()
106106
Test.@test result == (:a, :b, :c)
107107

108108
# Test with Test.@inferred
109-
Test.@test (Test.@inferred create_description(:x, :y)) isa Descriptions.Description
109+
Test.@test (Test.@inferred create_description(:x, :y)) isa
110+
Descriptions.Description
110111
end
111112
end
112113
end

test/suite/descriptions/test_display_description.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestDisplayDescription
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions: Descriptions
55

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

test/suite/descriptions/test_integration.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestIntegration
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions: Descriptions
55
import CTBase.Extensions: Extensions
66
import CTBase.Exceptions: Exceptions
@@ -22,8 +22,9 @@ function test_integration()
2222
# Successful completion from partial descriptions
2323
Test.@test Descriptions.complete((:descent,); descriptions=algorithms) ==
2424
(:descent, :bfgs, :bisection)
25-
Test.@test Descriptions.complete((:gradient, :fixedstep); descriptions=algorithms) ==
26-
(:descent, :gradient, :fixedstep)
25+
Test.@test Descriptions.complete(
26+
(:gradient, :fixedstep); descriptions=algorithms
27+
) == (:descent, :gradient, :fixedstep)
2728

2829
# Removing known prefix from completed description
2930
full = Descriptions.complete((:descent,); descriptions=algorithms)

test/suite/descriptions/test_remove.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestRemove
22

3-
import Test
3+
using Test: Test
44
import CTBase.Descriptions
55

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

0 commit comments

Comments
 (0)