Skip to content

Commit

Permalink
check type stability in CI (#63)
Browse files Browse the repository at this point in the history
* check type stability

* add dependency

* move to extras
  • Loading branch information
aminnj committed Jul 24, 2021
1 parent b5b30cd commit 4747f6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ julia = "^1.3"
MD5 = "6ac74813-4b46-53a4-afec-0b5dc9d7885c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ThreadsX = "ac1d9e8a-700a-412c-b207-f0111f4b6c0d"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[targets]
test = ["Test", "ThreadsX", "MD5"]
test = ["Test", "ThreadsX", "MD5", "InteractiveUtils"]
25 changes: 25 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using UnROOT, LorentzVectors
using StaticArrays
using InteractiveUtils
using MD5

@static if VERSION > v"1.3.0"
Expand Down Expand Up @@ -413,3 +414,27 @@ end
@test all(ids_jagged[1] .== collect(1:56))
@test all(ids_jagged[9] .== collect(1:54))
end

@testset "Type stability" begin
function isfullystable(func)
io = IOBuffer()
print(io, (@code_typed func()).first);
typed = String(take!(io))
return !occursin("::Any", typed)
end

rootfile = ROOTFile(joinpath(SAMPLES_DIR, "NanoAODv5_sample.root"))
t = LazyTree(rootfile, "Events", ["MET_pt"])[1:10]

function f1()
s = 0.0f0
for evt in t
s += evt.MET_pt
end
s
end
f2() = sum(t.MET_pt)

@test isfullystable(f1)
@test isfullystable(f2)
end

0 comments on commit 4747f6f

Please sign in to comment.