@@ -48,7 +48,7 @@ macro testsuite(name, ex)
4848 fn = Symbol(" test_$(safe_name) " )
4949 return quote
5050 $ (esc(fn))(I) = $ (esc(ex))(I)
51- @assert ! haskey(tests, $ name)
51+ @assert ! haskey(tests, $ name) " duplicate testsuite name: $name "
5252 tests[$ name] = $ fn
5353 end
5454end
@@ -69,64 +69,6 @@ function test_sector(I::Type)
6969 end
7070end
7171
72- """
73- @testinferred [AllowedTypes] ex
74-
75- Like `Test.@inferred`, but registers failures through a test, rather than an error.
76- """
77- macro testinferred(ex)
78- return _inferred(ex, __module__)
79- end
80- macro testinferred(ex, allow)
81- return _inferred(ex, __module__, allow)
82- end
83-
84- # Implementation copied from Test._inferred:
85- function _inferred(ex, mod, allow = :(Union{}))
86- if Meta. isexpr(ex, :ref)
87- ex = Expr(:call, :getindex, ex. args... )
88- end
89- Meta. isexpr(ex, :call)|| error(" @testinferred requires a call expression" )
90- farg = ex. args[1 ]
91- if isa(farg, Symbol) && farg != = :.. && first(string(farg)) == ' .'
92- farg = Symbol(string(farg)[2 : end ])
93- ex = Expr(
94- :call, GlobalRef(Test, :_materialize_broadcasted),
95- farg, ex. args[2 : end ]. ..
96- )
97- end
98- result = let ex = ex
99- quote
100- let allow = $ (esc(allow))
101- allow isa Type || throw(ArgumentError(" @inferred requires a type as second argument" ))
102- $ (
103- if any(@nospecialize(a) -> (Meta. isexpr(a, :kw) || Meta. isexpr(a, :parameters)), ex. args)
104- # Has keywords
105- # Create the call expression with escaped user expressions
106- call_expr = :($ (esc(ex. args[1 ]))(args... ; kwargs... ))
107- quote
108- args, kwargs, result = $ (esc(Expr(:call, _args_and_call, ex. args[2 : end ]. .. , ex. args[1 ])))
109- # wrap in dummy hygienic-scope to work around scoping issues with `call_expr` already having `esc` on the necessary parts
110- inftype = $ (Expr(:var"hygienic-scope" , Base. gen_call_with_extracted_types(mod, Base. infer_return_type, call_expr; is_source_reflection = false ), Test))
111- end
112- else
113- # No keywords
114- quote
115- args = ($ ([esc(ex. args[i]) for i in 2 : length(ex. args)]. .. ),)
116- result = $ (esc(ex. args[1 ]))(args... )
117- inftype = Base. infer_return_type($ (esc(ex. args[1 ])), Base. typesof(args... ))
118- end
119- end
120- )
121- rettype = result isa Type ? Type{result} : typeof(result)
122- @test rettype <: allow || rettype == Base. typesplit(inftype, allow)
123- result
124- end
125- end
126- end
127- return Base. remove_linenums!(result)
128- end
129-
13072smallset(:: Type{I} ) where {I <: Sector } = take(values(I), 5 )
13173function smallset(:: Type{ProductSector{Tuple{I1, I2}}} ) where {I1, I2}
13274 iter = product(smallset(I1), smallset(I2))
0 commit comments