Open
Conversation
maleadt
reviewed
Sep 23, 2022
test/testsuite/base.jl
Outdated
| # print([1]) shows as [1] on 64bit but Int64[1] on 32bit | ||
| msg = showstr(A) | ||
| @test msg == "[1]" || msg == "Int64[1]" | ||
| @test occursin("[1]", msg) || occursin("Int64[1]", msg) |
Member
There was a problem hiding this comment.
Multiple occursins with strings that are substrings of each other isn't very useful.
Contributor
Author
There was a problem hiding this comment.
This is true. Maybe these should detect the brackets which this PR adds, at least this will fail before:
Suggested change
| @test occursin("[1]", msg) || occursin("Int64[1]", msg) | |
| @test occursin("([1])", msg) || occursin("(Int64[1])", msg) |
Contributor
Author
There was a problem hiding this comment.
These tests fail on CI, and running the package's tests locally, on Julia <= 1.8.
But what they aim to test seems to work fine in isolation, and with just this @testset. Any idea what's wrong?
julia> using JLArrays
julia> jl([1]), 2 # this works fine:
(JLArray([1]), 2)
julia> # from tests:
replstr(x, kv::Pair...) = sprint((io,x) -> show(IOContext(io, :compact => false, :limit => true, :displaysize => (24, 80), kv...), MIME("text/plain"), x), x)
showstr(x, kv::Pair...) = sprint((io,x) -> show(IOContext(io, :limit => true, :displaysize => (24, 80), kv...), x), x);
julia> replstr(jl([1]))
"1-element JLArray{Int64, 1}:\n 1"
julia> showstr(jl([1])) # still fine
"JLArray([1])"
julia> let AT = JLArray
@testset "showing" begin
# vectors and non-vector arrays showing
# are handled differently in base/arrayshow.jl
A = AT(Int64[1])
B = AT(Int64[1 2;3 4])
msg = replstr(A)
@test occursin(Regex("^1-element $AT{Int64,\\s?1.*}:\n 1\$"), msg)
# # result of e.g. `print` differs on 32bit and 64bit machines
# due to different definition of `Int` type
# print([1]) shows as [1] on 64bit but Int64[1] on 32bit
msg = showstr(A)
@test occursin("([1])", msg) || occursin("(Int64[1])", msg)
msg = replstr(B)
@test occursin(Regex("^2×2 $AT{Int64,\\s?2.*}:\n 1 2\n 3 4\$"), msg)
msg = showstr(B)
@test occursin("([1 2; 3 4])", msg) || occursin("(Int64[1 2; 3 4])", msg)
# the printing of Adjoint depends on global state
msg = replstr(A')
@test occursin(Regex("^1×1 Adjoint{Int64,\\s?$AT{Int64,\\s?1.*}}:\n 1\$"), msg) ||
occursin(Regex("^1×1 LinearAlgebra.Adjoint{Int64,\\s?$AT{Int64,\\s?1.*}}:\n 1\$"), msg) ||
occursin(Regex("^1×1 adjoint\\(::$AT{Int64,\\s?1.*}\\) with eltype Int64:\n 1\$"), msg)
end
end
Test Summary: | Pass Total
showing | 5 5
Test.DefaultTestSet("showing", Any[], 5, false, false)
julia> VERSION
v"1.6.0"
mcabbott
commented
Sep 23, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces JuliaGPU/CUDA.jl#1197 with a more generic version:
This sort-of assumes
typeof(A).name.nameis a reasonable constructor.Unlike JuliaGPU/CUDA.jl#1197, this is going to print
CuArray(Float32[2.0 3.0])rather than shortening tocu([2.0 3.0]).