Skip to content

Commit

Permalink
Merge pull request SciML#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

0 comments on commit 9a8c427

Please sign in to comment.