Skip to content

Commit

Permalink
Merge pull request #15 from SciML/staticuint
Browse files Browse the repository at this point in the history
add static(::UInt) methods
  • Loading branch information
chriselrod authored Aug 30, 2021
2 parents bf61620 + 0afdc8e commit 9a8c427
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Static"
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
authors = ["chriselrod", "ChrisRackauckas", "Tokazama"]
version = "0.3.0"
version = "0.3.1"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
5 changes: 4 additions & 1 deletion src/Static.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ static
@aggressive_constprop static(x::X) where {X} = ifelse(is_static(X), identity, _no_static_type)(x)
@aggressive_constprop static(x::Int) = StaticInt(x)
@aggressive_constprop static(x::Union{Int8,UInt8,Int16,UInt16}) = StaticInt(x % Int)
if sizeof(Int) == 8
@static if sizeof(Int) == 8
@aggressive_constprop static(x::Union{Int32,UInt32}) = StaticInt(x % Int)
@aggressive_constprop static(x::UInt64) = StaticInt(Int(x))
else
@aggressive_constprop static(x::UInt32) = StaticInt(Int(x))
end
@aggressive_constprop static(x::Float64) = StaticFloat64(x)
@aggressive_constprop static(x::Bool) = StaticBool(x)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Test
Aqua.test_all(Static)

@testset "StaticInt" begin
@test StaticInt(UInt(8)) === StaticInt{8}()
@test static(UInt(8)) === StaticInt(UInt(8)) === StaticInt{8}()
@test iszero(StaticInt(0))
@test !iszero(StaticInt(1))
@test !isone(StaticInt(0))
Expand Down

2 comments on commit 9a8c427

@chriselrod
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/43779

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 9a8c42778ad7cdbdab32be272db35ad433dfc4a6
git push origin v0.3.1

Please sign in to comment.