Skip to content
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

Merged
merged 2 commits into from
May 2, 2024
Merged

improve effects of factorial #54320

merged 2 commits into from
May 2, 2024

Conversation

aviatesk
Copy link
Sponsor Member

@aviatesk aviatesk commented May 1, 2024

So that it can be concrete-evaluated.

Comment on lines +80 to +85
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Sponsor Member Author

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.

Copy link
Contributor

@Seelengrab Seelengrab May 1, 2024

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)

base/combinatorics.jl Outdated Show resolved Hide resolved
So that it can be concrete-evaluated.
base/combinatorics.jl Outdated Show resolved Hide resolved
@aviatesk aviatesk merged commit c0ce76c into master May 2, 2024
7 checks passed
@aviatesk aviatesk deleted the avi/factorial-effects branch May 2, 2024 09:12
lazarusA pushed a commit to lazarusA/julia that referenced this pull request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants