Skip to content

Commit

Permalink
finish tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgymnich committed Sep 18, 2024
1 parent fe00905 commit f9bccdc
Showing 1 changed file with 25 additions and 41 deletions.
66 changes: 25 additions & 41 deletions test/output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
@test out == "foobar\n"

# c argument promotions
# function kernel(A)
# @mtlprintf("%f %f\n", A[1], A[1])
# return
# end
# x = MtlArray(ones(2, 2))
# _, out = @grab_output begin
# Metal.@sync @metal kernel(x)
# end
# @test out == "1.000000 1.000000\n"
function kernel(A)
@mtlprintf("%f %f\n", A[1], A[1])
return
end
x = mtl(ones(2, 2))
_, out = @grab_output begin
Metal.@sync @metal kernel(x)
end
@test out == "1.000000 1.000000\n"
end

@testset "@mtlprint" begin
Expand Down Expand Up @@ -92,9 +92,9 @@
test_output(typ(42), "42")
end

# for typ in (Float32,)
# test_output(typ(42), "42.000000")
# end
for typ in (Float32,)
test_output(typ(42), "42.000000")
end

test_output(Cchar('c'), "c")

Expand All @@ -108,8 +108,7 @@

test_output((1,), "(1,)")
test_output((1,2), "(1, 2)")
# test_output((1,2,3.), "(1, 2, 3.000000)")

test_output((1,2,3.0f0), "(1, 2, 3.000000)")

# escaping

Expand All @@ -122,33 +121,18 @@
@test out == "42\n"
end

# @testset "@mtlshow" begin
# function kernel()
# seven_i32 = Int32(7)
# three_f32 = Float32(3)
# @mtlshow seven_i32
# @mtlshow three_f32
# @mtlshow 1f0 + 4f0
# return
# end

# _, out = @grab_output @on_device kernel()
# @test out == "seven_i32 = 7\nthree_f64 = 3.000000\n1.0f0 + 4.0f0 = 5.000000\n"
# end

# @testset "@mtlshow array pointers" begin
# function kernel()
# a = mtlStaticSharedArray(Float32, 1)
# b = mtlStaticSharedArray(Float32, 2)
# @mtlshow pointer(a) pointer(b)
# return
# end

# _, out = @grab_output @on_device kernel()
# @test ocmtlrsin("pointer(a) = ", out)
# @test ocmtlrsin("pointer(b) = ", out)
# @test ocmtlrsin("= 0", out)
# end
@testset "@mtlshow" begin
function kernel()
seven_i32 = Int32(7)
three_f32 = Float32(3)
@mtlshow seven_i32
@mtlshow three_f32
@mtlshow 1f0 + 4f0
return
end

_, out = @grab_output @on_device kernel()
@test out == "seven_i32 = 7\nthree_f32 = 3.000000\n1.0f0 + 4.0f0 = 5.000000\n"
end
end

0 comments on commit f9bccdc

Please sign in to comment.