@@ -259,44 +259,46 @@ let _true = Ref(true), f, g, h
259
259
@test g () == 0
260
260
end
261
261
262
- module ReflectionTest
263
- using Test, Random, InteractiveUtils
264
-
265
- function test_ast_reflection (freflect, f, types)
266
- @test ! isempty (freflect (f, types))
267
- nothing
268
- end
269
-
270
- function test_bin_reflection (freflect, f, types)
271
- iob = IOBuffer ()
272
- freflect (iob, f, types)
273
- str = String (take! (iob))
274
- @test ! isempty (str)
275
- nothing
276
- end
262
+ @testset " Reflection test" begin
263
+
264
+ # abstract type
265
+ @test ! isempty (sprint (code_llvm, occursin, Tuple{Regex, AbstractString}))
266
+ @test ! isempty (sprint (code_llvm, occursin, (Regex, AbstractString)))
267
+ # leaftype signature
268
+ @test ! isempty (sprint (code_llvm, + , Tuple{Int, Int}))
269
+ @test ! isempty (sprint (code_llvm, + , (Int, Int)))
270
+ # incomplete types
271
+ @test ! isempty (sprint (code_llvm, + , Tuple{Array{Float32}, Array{Float32}}))
272
+ @test ! isempty (sprint (code_llvm, + , (Array{Float32}, Array{Float32})))
273
+ # Module() constructor (transforms to call)
274
+ @test ! isempty (sprint (code_llvm, Module, Tuple{}))
275
+ @test ! isempty (sprint (code_llvm, Module, ()))
276
+ # with incomplete types
277
+ @test ! isempty (sprint (code_llvm, Array{Int64}, Tuple{Array{Int32}}))
278
+ @test ! isempty (sprint (code_llvm, Array{Int64}, (Array{Int32},)))
279
+ @test ! isempty (sprint (code_llvm, muladd, Tuple{Float64, Float64, Float64}))
280
+ @test ! isempty (sprint (code_llvm, muladd, (Float64, Float64, Float64)))
281
+
282
+ # abstract type
283
+ @test ! isempty (sprint (code_native, occursin, Tuple{Regex, AbstractString}))
284
+ @test ! isempty (sprint (code_native, occursin, (Regex, AbstractString)))
285
+ # leaftype signature
286
+ @test ! isempty (sprint (code_native, + , Tuple{Int, Int}))
287
+ @test ! isempty (sprint (code_native, + , (Int, Int)))
288
+ # incomplete types
289
+ @test ! isempty (sprint (code_native, + , Tuple{Array{Float32}, Array{Float32}}))
290
+ @test ! isempty (sprint (code_native, + , (Array{Float32}, Array{Float32})))
291
+ # Module() constructor (transforms to call)
292
+ @test ! isempty (sprint (code_native, Module, Tuple{}))
293
+ @test ! isempty (sprint (code_native, Module, ()))
294
+ # with incomplete types
295
+ @test ! isempty (sprint (code_native, Array{Int64}, Tuple{Array{Int32}}))
296
+ @test ! isempty (sprint (code_native, Array{Int64}, (Array{Int32},)))
297
+ @test ! isempty (sprint (code_native, muladd, Tuple{Float64, Float64, Float64}))
298
+ @test ! isempty (sprint (code_native, muladd, (Float64, Float64, Float64)))
277
299
278
- function test_code_reflection (freflect, f, types, tester)
279
- tester (freflect, f, types)
280
- tester (freflect, f, (types. parameters... ,))
281
- nothing
282
300
end
283
301
284
- function test_code_reflections (tester, freflect)
285
- test_code_reflection (freflect, occursin,
286
- Tuple{Regex, AbstractString}, tester) # abstract type
287
- test_code_reflection (freflect, + , Tuple{Int, Int}, tester) # leaftype signature
288
- test_code_reflection (freflect, + ,
289
- Tuple{Array{Float32}, Array{Float32}}, tester) # incomplete types
290
- test_code_reflection (freflect, Module, Tuple{}, tester) # Module() constructor (transforms to call)
291
- test_code_reflection (freflect, Array{Int64}, Tuple{Array{Int32}}, tester) # with incomplete types
292
- test_code_reflection (freflect, muladd, Tuple{Float64, Float64, Float64}, tester)
293
- end
294
-
295
- test_code_reflections (test_bin_reflection, code_llvm)
296
- test_code_reflections (test_bin_reflection, code_native)
297
-
298
- end # module ReflectionTest
299
-
300
302
@test_throws ArgumentError (" argument is not a generic function" ) code_llvm (=== , Tuple{Int, Int})
301
303
@test_throws ArgumentError (" argument is not a generic function" ) code_native (=== , Tuple{Int, Int})
302
304
0 commit comments