Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Commit

Permalink
* Fix documentation link
Browse files Browse the repository at this point in the history
* Move remaining tests from FactCheck to BaseTestNext
  • Loading branch information
gdziadkiewicz committed Jul 25, 2016
1 parent 7f6cf37 commit 9609978
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ julia> bar(1, 2, 3)
```

Plays well with macros. See
[ValueDispatch.jl](https://github.com/zachallaun/ValueDispatch.jl/blob/master/src/ValueDispatch.jl)
[ValueDispatch.jl](https://github.com/gdziadkiewicz/ValueDispatch.jl)
for another example.

### Low-level utilities
Expand Down
3 changes: 1 addition & 2 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
FactCheck
BaseTestNext
BaseTestNext
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if VERSION < v"0.5.0-dev"
else
using Base.Test
end
using FactCheck
using ExpressionUtils

include("functions.jl")
Expand Down
29 changes: 16 additions & 13 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
facts("Expression destructuring") do
@testset "Expression destructuring" begin

context("expr_bindings") do
@testset "expr_bindings" begin

@fact expr_bindings(:(x = 5), :(x = _val_)) --> Dict(:_val_ => 5)
@fact expr_bindings(:(x = 5), :(_sym_ = 5)) --> Dict(:_sym_ => :x)
@fact expr_bindings(:(x = 5), :_ex_) --> Dict(:_ex_ => :(x = 5))
@test expr_bindings(:(x = 5), :(x = _val_)) == Dict(:_val_ => 5)
@test expr_bindings(:(x = 5), :(_sym_ = 5)) == Dict(:_sym_ => :x)
@test expr_bindings(:(x = 5), :_ex_) == Dict(:_ex_ => :(x = 5))

splatex = Expr(:let, :_body_, :_SPLAT_bindings_)
ex = :(let x=1, y=2, z=3
Expand All @@ -13,14 +13,16 @@ facts("Expression destructuring") do
end)

bindings = expr_bindings(ex, splatex)
body = bindings[:_body_]
b = bindings[:_bindings_]

@fact haskey(bindings, :_body_) --> true
@fact haskey(bindings, :_bindings_) --> true
@fact bindings[:_body_] --> body -> isa(body, Expr) && body.head == :block
@fact bindings[:_bindings_] --> b -> isa(b, Array) && length(b) == 3
@test haskey(bindings, :_body_)
@test haskey(bindings, :_bindings_)
@test isa(body, Expr) && body.head == :block
@test isa(b, Array) && length(b) == 3
end

context("expr_replace") do
@testset "expr_replace" begin

ex = quote
let x, y, z
Expand All @@ -45,9 +47,10 @@ facts("Expression destructuring") do

foofun = expr_replace(ex, template, out)
eval(foofun)
@fact foofun.head --> :function
@fact eval(foofun)(1,2,3) --> 5
@fact bar(1,2,3) --> 5

@test foofun.head == :function
@test eval(foofun)(1,2,3) == 5
@test bar(1,2,3) == 5
end

end

0 comments on commit 9609978

Please sign in to comment.