-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for Base.copy! #52682
Added tests for Base.copy! #52682
Conversation
For some reason test x86_64-w64-mingw32 bash .buildkite/utilities/test_julia.sh is failing in the tests by buildkite. i686 works perfectly fine. Since this is my first PR I would really appreciate it if a reviewer might help me out. I closed the same PR once before because of some unwanted commits for this PR. I am enjoying the spirits over here and am looking forward to contribute more for Julia. |
a309c3e
to
25cc727
Compare
Hey @shashi what must I do ? To make the change happen and add these tests. Kindly help me out here... I am really new to contributing. Is there something I overlooked/misunderstood from the contribution pathways ? |
Looks like there was just some issues with the buildkite runner that don't impact your PR. Could you move these to a different test file, such as |
Sure, would do it ASAP. |
@vtjnash Seems like there already is one copy.jl that is much more able in testing the copy! but for different issues do I still add these basic tests for it ? |
Yes, just append them to the end of it. Side question: how did you determine these needed tests, and is there a relevant issue that should be closed now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests for copy!
are generally associated with the type of input, which is probably why copy.jl
does not contain tests for copy!
.
Lines 1077 to 1094 in af90dac
@testset "copy!" begin | |
@testset "AbstractVector" begin | |
s = Vector([1, 2]) | |
for a = ([1], UInt[1], [3, 4, 5], UInt[3, 4, 5]) | |
@test s === copy!(s, Vector(a)) == Vector(a) | |
end | |
# issue #35649 | |
s = [1, 2, 3, 4] | |
s2 = reshape(s, 2, 2) # shared data | |
@test s === copy!(s, 11:14) == 11:14 | |
end | |
@testset "AbstractArray" begin | |
@test_throws ArgumentError copy!(zeros(2, 3), zeros(3, 2)) | |
s = zeros(2, 2) | |
@test s === copy!(s, fill(1, 2, 2)) == fill(1, 2, 2) | |
@test s === copy!(s, fill(1.0, 2, 2)) == fill(1.0, 2, 2) | |
end | |
end |
Lines 1420 to 1430 in af90dac
@testset "copy!" begin | |
s = Dict(1=>2, 2=>3) | |
for a = ([3=>4], [0x3=>0x4], [3=>4, 5=>6, 7=>8], Pair{UInt,UInt}[3=>4, 5=>6, 7=>8]) | |
@test s === copy!(s, Dict(a)) == Dict(a) | |
if length(a) == 1 # current limitation of Base.ImmutableDict | |
@test s === copy!(s, Base.ImmutableDict(a[])) == Dict(a[]) | |
end | |
end | |
s2 = copy(s) | |
@test copy!(s, s) == s2 | |
end |
Lines 179 to 190 in af90dac
@testset "copy!" begin | |
for S = (Set, BitSet) | |
s = S([1, 2]) | |
for a = ([1], UInt[1], [3, 4, 5], UInt[3, 4, 5]) | |
@test s === copy!(s, Set(a)) == S(a) | |
@test s === copy!(s, BitSet(a)) == S(a) | |
end | |
end | |
s = Set([1, 2]) | |
s2 = copy(s) | |
@test copy!(s, s) == s2 | |
end |
Ok then I feel like it still is kind of needed to be added in the copy.jl since there is no unit display of the usecase through tests. @inkydragon |
@vtjnash I have appended the same code in copy.jl and have emptied the future test folder. Do tell me if I have to do anything else. Answering the side note : |
It looks like @inkydragon is correct that these methods appear to already be covered in the original PR: #29178 Is there anything there that this covers that isn't already covered? It doesn't look like we need these added tests |
@vtjnash Absolutely ! The tests for a language must be concise and not confusing. I do not see any issues being covered here. I am really grateful to all of the reviewers to put their attention to my first PR towards Julia. I will try to be more aware next time. |
Testing the deep copying of Sets, Dictionaries and arrays was necessary. Added tests for Base.copy!