-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
improve effects of factorial
#54320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve effects of factorial
#54320
Conversation
| for T = Base.uniontypes(Union{Base.Checked.SignedInt,Base.Checked.UnsignedInt}) | ||
| @testset let T = T | ||
| @test factorial(T(7)) == 5040 | ||
| @test Core.Compiler.is_foldable(Base.infer_effects(factorial, (T,))) | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for T = Base.uniontypes(Union{Base.Checked.SignedInt,Base.Checked.UnsignedInt}) | |
| @testset let T = T | |
| @test factorial(T(7)) == 5040 | |
| @test Core.Compiler.is_foldable(Base.infer_effects(factorial, (T,))) | |
| end | |
| end | |
| types = Base.uniontypes(Union{Base.Checked.SignedInt,Base.Checked.UnsignedInt}) | |
| @testset for T = types | |
| @test factorial(T(7)) == 5040 | |
| @test Core.Compiler.is_foldable(Base.infer_effects(factorial, (T,))) | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the contextual testset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @testset for will also show the iterated object as context on a failure, but aggregated and not as individual testsets:
julia> using Test
julia> types = Base.uniontypes(Union{Base.Checked.SignedInt,Base.Checked.UnsignedInt});
julia> @testset begin
@testset for T = types
@test factorial(T(7)) == 5040
@test Core.Compiler.is_foldable(Base.infer_effects(factorial, (T,)))
end
end
[...]
Test Summary: | Pass Fail Total Time
test set | 10 10 20 0.4s
T = Int128 | 1 1 2 0.0s
T = Int16 | 1 1 2 0.0s
T = Int32 | 1 1 2 0.0s
T = Int64 | 1 1 2 0.0s
T = Int8 | 1 1 2 0.0s
T = UInt128 | 1 1 2 0.0s
T = UInt16 | 1 1 2 0.0s
T = UInt32 | 1 1 2 0.0s
T = UInt64 | 1 1 2 0.0s
T = UInt8 | 1 1 2 0.0s
ERROR: Some tests did not pass: 10 passed, 10 failed, 0 errored, 0 broken.
(run on a ~month old master, hence the failures)
So that it can be concrete-evaluated.
96993af to
abed954
Compare
So that it can be concrete-evaluated.