Skip to content

Commit 90c6fce

Browse files
authored
Merge pull request #33 from JuliaArrays/teh/returnnode
Fix anonymous-function printing for ReturnNode
2 parents 0795578 + 26ce32a commit 90c6fce

File tree

5 files changed

+17
-52
lines changed

5 files changed

+17
-52
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ language: julia
33
os:
44
- linux
55
- osx
6+
- windows
67
julia:
7-
- 0.7
88
- 1.0
9-
- 1.2
9+
- 1
1010
- nightly
1111
notifications:
1212
email: false

Project.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name = "MappedArrays"
22
uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
3-
version = "0.2.2"
3+
version = "0.3.0"
4+
5+
[deps]
6+
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
47

58
[compat]
6-
FixedPointNumbers = "≥ 0.3.0"
7-
julia = "0.7, 1"
9+
FixedPointNumbers = "0.6.1, 0.7, 0.8"
10+
julia = "1"
811

912
[extras]
1013
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"

appveyor.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/MappedArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function func_print(io, f, types)
234234
end
235235
lwrd = lwrds[1]
236236
c = lwrd.code
237-
if length(c) == 2 && isa(c[2], Expr) && c[2].head == :return
237+
if length(c) == 2 && ((isa(c[2], Expr) && c[2].head === :return) || (isdefined(Core, :ReturnNode) && isa(c[2], Core.ReturnNode)))
238238
# This is a single-line anonymous function, we should handle it
239239
s = lwrd.slotnames[2:end]
240240
if length(s) == 1

test/runtests.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ end
140140
@test a[1,2] == N0f8(0.25)
141141
@test b[1,2] == N0f8(0.35)
142142
@test c[1,2] == 0
143-
@test_throws InexactError(intsym, Int, N0f8(0.45)) M[1,2] = RGB(0.25, 0.35, 0.45)
143+
try
144+
M[1,2] = RGB(0.25, 0.35, 0.45)
145+
catch err
146+
# Can't use `@test_throws` because is differs by FPN version, and we support multiple versions
147+
@test err == InexactError(intsym, Int, N0f8(0.45)) || err == InexactError(:Integer, N0f8, N0f8(0.45))
148+
end
144149
R = reinterpret(N0f8, M)
145150
@test R == N0f8[0.1 0.25; 0.6 0.35; 0 0; 0.3 0.4; 0.4 0.3; 0 1]
146151
R[2,1] = 0.8
@@ -162,9 +167,9 @@ end
162167
@testset "Display" begin
163168
a = [1,2,3,4]
164169
b = mappedarray(sqrt, a)
165-
@test summary(b) == "4-element mappedarray(sqrt, ::Array{Int64,1}) with eltype Float64"
170+
@test summary(b) == "4-element mappedarray(sqrt, ::$(Vector{Int})) with eltype Float64"
166171
c = mappedarray(sqrt, x->x*x, a)
167-
@test summary(c) == "4-element mappedarray(sqrt, x->x * x, ::Array{Int64,1}) with eltype Float64"
172+
@test summary(c) == "4-element mappedarray(sqrt, x->x * x, ::$(Vector{Int})) with eltype Float64"
168173
# issue #26
169174
M = @inferred mappedarray((x1,x2)->x1+x2, a, a)
170175
io = IOBuffer()

0 commit comments

Comments
 (0)