Skip to content

Commit

Permalink
don't do the block-unblocking anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Nov 21, 2020
1 parent 7ebbd87 commit 11a516b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ module Chain

export @chain

function get_unblocked_parts(x, exprs = Any[])
if x isa Expr && x.head == :block
for arg in x.args
exprs = get_unblocked_parts(arg, exprs)
end
else
push!(exprs, x)
end
exprs
end

is_excepted(x) = false
is_excepted(x::Expr) = x.head == :macrocall && x.args[1] == Symbol("@!")

Expand All @@ -33,7 +22,7 @@ macro chain(firstpart, block)
error("Second argument must be a begin / end block")
end

unblocked_parts = get_unblocked_parts(block)
unblocked_parts = block.args
isempty(unblocked_parts) && error("No expressions found in chain block.")

newexprs = []
Expand Down
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ end
@test y == 16
end

@testset "nested begin" begin
x = 1:5
y = @chain x begin
begin
z = sum(_) + 3
z - 7
end
sqrt
end
@test y == sqrt(sum(x) + 3 - 7)
end

@testset "invalid invocations" begin
# just one argument
@test_throws LoadError eval(quote
Expand Down

2 comments on commit 11a516b

@jkrumbiegel
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/25091

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 11a516b43e30e5f82805c8f91d3eceeba3b1b5e9
git push origin v0.1.0

Please sign in to comment.