Skip to content

Commit

Permalink
Add new test_nothing method
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Benz committed Apr 14, 2015
1 parent 8136c28 commit 14c9809
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/base.jl
Expand Up @@ -648,6 +648,8 @@ function test_nothing(; error = nothing)
end
end

test_nothing(convertible::Convertible) = test_nothing()(convertible)


function to_bool(convertible::Convertible)
"""Convert a julia data to a boolean.
Expand Down
3 changes: 3 additions & 0 deletions test/test_base.jl
Expand Up @@ -496,6 +496,9 @@ tuple_non_strict_converter = struct(
@test Convertible(42) |> test_nothing(error = "No value allowed.") |> to_value_error == (42, "No value allowed.")
@test Convertible("") |> test_nothing() |> to_value_error == ("", "Unexpected value")
@test Convertible(nothing) |> test_nothing() |> to_value_error == (nothing, nothing)
@test Convertible(42) |> test_nothing |> to_value_error == (42, "Unexpected value")
@test Convertible("") |> test_nothing |> to_value_error == ("", "Unexpected value")
@test Convertible(nothing) |> test_nothing |> to_value_error == (nothing, nothing)

# to_bool
@test Convertible("0") |> to_bool |> to_value === false
Expand Down

0 comments on commit 14c9809

Please sign in to comment.