Skip to content

Commit 06db788

Browse files
wip
1 parent e313cef commit 06db788

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using Test, PerformanceTestTools
22

3+
using Cthulhu
4+
Cthulhu.CONFIG.type_depth_limit = nothing # disable type-depth limit printing in tests
5+
36
@testset "runtests.jl" begin
47
@testset "test_Cthulhu.jl" begin
58
include("test_Cthulhu.jl")

test/test_depth_limited_type_printing.jl

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,40 @@ import Cthulhu
66
Base.@kwdef struct Nested{A,B}
77
num::Int = 1
88
end
9-
struct F49231{a,b,c,d,e,f,g}
10-
num::g
11-
end;
129
bar(x) = rand() > 0.5 ? x : Any[0][1]
1310
mysum(x) = sum(y-> bar(x.num), 1:5; init=0)
1411
nest_val(na, nb, ::Val{1}) = Nested{na, nb}()
1512
nest_val(na, nb, ::Val{n}) where {n} = nest_val(Nested{na, nb}, Nested{na, nb}, Val(n-1))
1613
nest_val(na, nb, n::Int) = nest_val(na, nb, Val(n))
1714
nest_val(n) = nest_val(1, 1, n)
15+
const NV = nest_val(5)
1816

19-
f = nest_val(5)
20-
a = Any[f];
21-
mysum(a[1]) # make sure it runs
22-
Cthulhu.@descend mysum(a[1]) # navigate to sum -> sum, and F49231 will be there
17+
# f = nest_val(5)
18+
# a = Any[f];
19+
# mysum(a[1]) # make sure it runs
20+
# Cthulhu.@descend mysum(a[1]) # navigate to sum -> sum, and Nested will be there
21+
using Test
22+
include("setup.jl")
23+
@testset "hide type-stable statements" begin
24+
let # optimize code
25+
# f = nest_val(5)
26+
# a = Any[f];
27+
# mysum(a[1]) # make sure it runs
28+
# Cthulhu.@descend mysum(a[1]) # navigate to sum -> sum, and Nested will be there
29+
(; src, infos, mi, rt, exct, effects, slottypes) = @eval Module() begin
30+
$cthulhu_info($mysum, ($(typeof(NV)),))
31+
end;
32+
function prints(; kwargs...)
33+
io = IOBuffer()
34+
ioc = IOContext(io, :maxtypedepth => Cthulhu.CONFIG.type_depth_limit)
35+
Cthulhu.cthulhu_typed(ioc, :none, src, rt, exct, effects, mi; kwargs...)
36+
return String(take!(io))
37+
end;
38+
39+
let # by default, should print every statement
40+
s = prints()
41+
println(s)
42+
# @test occursin("::Nested{Nested{…}, Nested{…}}", s)
43+
end
44+
end
45+
end

0 commit comments

Comments
 (0)