Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/NoBang/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ resize(xs::AbstractVector, n::Integer) = similar(xs, (n,))

setproperty(value, name, x) = setproperties(value, NamedTuple{(name,)}((x,)))

materialize(::Any, x) = Broadcast.materialize(x)
materialize(dest, x) =
Broadcast.materialize(Broadcast.instantiate(Broadcast.broadcasted(first ∘ tuple, x, dest)))

@inline _union(args...) = union(args...)

Expand Down
1 change: 1 addition & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ implements(::typeof(setproperty!), ::Type{<:NamedTuple}) = false

struct Undefined end
implements(::Mutator, ::Undefined) = false
Base.broadcastable(x::Undefined) = Ref(x)

"""
possible(f!, args...) :: Bool
Expand Down
2 changes: 1 addition & 1 deletion test/preamble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Test
using Base: ImmutableDict
using BangBang
using BangBang: implements
using StaticArrays: SVector
using StaticArrays: SVector, SizedVector

"""
==ₜ(x, y)
Expand Down
20 changes: 18 additions & 2 deletions test/test_macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ end

let x = [1, 2]
y = SVector(0, 0)
@test (@! y .= x .* 2)::Vector{Int} == [2, 4]
@test (@! y .= x .* 2)::SizedVector{2, Int} == [2, 4]
end

let y = [0, 0]
@test (@! y .= 1)::Vector{Int} == [1, 1]
end

let y = SVector(0, 0)
@test (@! y .= 1) === SVector(1, 1)
end
end

Expand Down Expand Up @@ -63,7 +71,15 @@ end

let x = [1, 2]
y = SVector(0, 0)
@test (@! @. y = x * 2)::Vector{Int} == [2, 4]
@test (@! @. y = x * 2)::SizedVector{2, Int} == [2, 4]
end

let y = [0, 0]
@test (@! @. y = 1)::Vector{Int} == [1, 1]
end

let y = SVector(0, 0)
@test (@! @. y = 1) === SVector(1, 1)
end
end

Expand Down