@@ -25,31 +25,27 @@ false-positive.
25
25
- Other keyword arguments such as `imported` and `ambiguous_bottom`
26
26
are passed to `Test.detect_ambiguities` as-is.
27
27
"""
28
- test_ambiguities (packages; kwargs... ) = _test_ambiguities (aspkgids (packages); kwargs... )
28
+ function test_ambiguities (packages; broken:: Bool = false , kwargs... )
29
+ num_ambiguities, strout, strerr = Ambiguities. find_ambiguities (packages; kwargs... )
29
30
30
- const ExcludeSpec = Pair{Base. PkgId,String}
31
-
32
- aspkgids (pkg:: Union{Module,PkgId} ) = aspkgids ([pkg])
33
- aspkgids (packages) = mapfoldl (aspkgid, push!, packages, init = PkgId[])
31
+ println (stderr , strerr)
32
+ println (stdout , strout)
34
33
35
- aspkgid (pkg :: PkgId ) = pkg
36
- function aspkgid (m :: Module )
37
- if ! ispackage (m)
38
- error ( " Non-package (non-toplevel) module is not supported. Got: $m " )
34
+ if broken
35
+ @test_broken num_ambiguities == 0
36
+ else
37
+ @test num_ambiguities == 0
39
38
end
40
- return PkgId (m)
41
- end
42
- function aspkgid (name:: Symbol )
43
- # Maybe `Base.depwarn()`
44
- return Base. identify_package (String (name)):: PkgId
45
39
end
46
40
47
- ispackage (m:: Module ) =
48
- if m in (Base, Core)
49
- true
50
- else
51
- parentmodule (m) == m
52
- end
41
+ module Ambiguities
42
+
43
+ using Base: PkgId
44
+ using Test: detect_ambiguities
45
+
46
+ using .. Aqua: aspkgids, checked_repr, reprpkgid
47
+
48
+ const ExcludeSpec = Pair{Base. PkgId,String}
53
49
54
50
strnameof (x) = string (x)
55
51
strnameof (x:: Type ) = string (nameof (x))
@@ -81,23 +77,15 @@ function reprexclude(exspecs::Vector{ExcludeSpec})
81
77
itemreprs = map (exspecs) do (pkgid, name)
82
78
string (" (" , reprpkgid (pkgid), " => " , repr (name), " )" )
83
79
end
84
- return string (" Aqua.ExcludeSpec[" , join (itemreprs, " , " ), " ]" )
80
+ return string (" Aqua.Ambiguities. ExcludeSpec[" , join (itemreprs, " , " ), " ]" )
85
81
end
86
82
87
- function _test_ambiguities (packages:: Vector{PkgId} ; broken:: Bool = false , kwargs... )
88
- num_ambiguities, strout, strerr = _find_ambiguities (packages; kwargs... )
89
-
90
- println (stderr , strerr)
91
- println (stdout , strout)
92
-
93
- if broken
94
- @test_broken num_ambiguities == 0
95
- else
96
- @test num_ambiguities == 0
97
- end
83
+ function find_ambiguities (packages; kwargs... )
84
+ package_ids = aspkgids (packages):: Vector{PkgId}
85
+ return find_ambiguities (package_ids; kwargs... )
98
86
end
99
87
100
- function _find_ambiguities (
88
+ function find_ambiguities (
101
89
packages:: Vector{PkgId} ;
102
90
color:: Union{Bool,Nothing} = nothing ,
103
91
exclude:: AbstractVector = [],
@@ -113,7 +101,7 @@ function _find_ambiguities(
113
101
code = """
114
102
$(Base. load_path_setup_code ())
115
103
using Aqua
116
- Aqua.test_ambiguities_impl(
104
+ Aqua.Ambiguities. test_ambiguities_impl(
117
105
$packages_repr ,
118
106
$options_repr ,
119
107
$exclude_repr ,
@@ -153,15 +141,6 @@ function reprpkgids(packages::Vector{PkgId})
153
141
return packages_repr
154
142
end
155
143
156
- function reprpkgid (pkg:: PkgId )
157
- name = pkg. name
158
- if pkg. uuid === nothing
159
- return " Base.PkgId($(repr (name)) )"
160
- end
161
- uuid = pkg. uuid. value
162
- return " Base.PkgId(Base.UUID($(repr (uuid)) ), $(repr (name)) )"
163
- end
164
-
165
144
struct _NoValue end
166
145
167
146
function getobj (m:: Method )
@@ -252,3 +231,5 @@ function ambiguity_hint(m1::Method, m2::Method)
252
231
end
253
232
end
254
233
end
234
+
235
+ end # module
0 commit comments