Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GPUToolbox"
uuid = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc"
version = "0.1.0"
version = "0.2.0"

[compat]
julia = "1.10"
1 change: 1 addition & 0 deletions src/GPUToolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module GPUToolbox

include("simpleversion.jl") # exports SimpleVersion, @sv_str
include("ccalls.jl") # exports @checked, @debug_ccall, @gcsafe_ccall
include("literals.jl")

end # module GPUToolbox
10 changes: 10 additions & 0 deletions src/literals.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export i8, i16, i32, u8, u16, u32
# helper type for writing smaller than Int64 literals
struct Literal{T} end
Base.:(*)(x::Number, ::Type{Literal{T}}) where {T} = T(x)
const i8 = Literal{Int8}
const i16 = Literal{Int16}
const i32 = Literal{Int32}
const u8 = Literal{UInt8}
const u16 = Literal{UInt16}
const u32 = Literal{UInt32}
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,16 @@ using GPUToolbox
end

# TODO: @debug_ccall and @gcsafe_ccall tests

@testset "Literals" begin
@test 1i8 === Int8(1)
@test 1i16 === Int16(1)
@test 1i32 === Int32(1)
@test_throws InexactError 128i8

@test 1u8 === UInt8(1)
@test 1u16 === UInt16(1)
@test 1u32 === UInt32(1)
@test_throws InexactError 256u8
end
end
Loading