Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 555953e

Browse files
author
Paul H. Liu
committed
Add test cases for both += and .+=
1 parent fb10359 commit 555953e

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

test/misc.jl

+30-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ end
8989
Int[ mod(x, y), rem(x, y) ]
9090
end
9191

92+
@acc function end_test(a)
93+
a[3:end] .+ 1
94+
end
95+
96+
function test6()
97+
end_test([1;2;3;4]) == [4;5]
98+
end
99+
100+
92101
@acc function end_test_numeric(a)
93102
a[3:4] .+ 1
94103
end
@@ -97,14 +106,25 @@ function test7()
97106
end_test_numeric([1;2;3;4]) == [4;5]
98107
end
99108

100-
@acc function end_test(a)
101-
a[3:end] .+ 1
109+
@acc function accum1()
110+
a = zeros(Int, 3)
111+
b = a
112+
for i = 1:3
113+
a += ones(Int, 3)
114+
end
115+
a .+ b
102116
end
103117

104-
function test6()
105-
end_test([1;2;3;4]) == [4;5]
118+
@acc function accum2()
119+
a = zeros(Int, 3)
120+
b = a
121+
for i = 1:3
122+
a .+= ones(Int, 3)
123+
end
124+
a .+ b
106125
end
107126

127+
108128
end
109129

110130
using Base.Test
@@ -120,5 +140,11 @@ println("Testing miscellaneous features...")
120140
@test MiscTest.mod_rem_test(7,-3) == [-2, 1]
121141
@test MiscTest.mod_rem_test(-7,3) == [2, -1]
122142
@test MiscTest.mod_rem_test(-7,-3) == [-1, -1]
143+
@test MiscTest.accum1() == [3,3,3]
144+
if VERSION > v"0.5.0-"
145+
@test MiscTest.accum2() == [6,6,6]
146+
else
147+
@test MiscTest.accum2() == [3,3,3]
148+
end
123149
println("Done testing miscellaneous features...")
124150

0 commit comments

Comments
 (0)