diff --git a/base/deprecated.jl b/base/deprecated.jl index 44e83e07e72c7..fa77d899d749a 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -2172,6 +2172,8 @@ end @deprecate merge!(repo::LibGit2.GitRepo, args...; kwargs...) LibGit2.merge!(repo, args...; kwargs...) +@deprecate |>(x, f) f(x) + # issue #24019 @deprecate similar(a::Associative) empty(a) @deprecate similar(a::Associative, ::Type{Pair{K,V}}) where {K, V} empty(a, K, V) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index 0d6a760a9af29..dd5067877812f 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -585,11 +585,11 @@ Low-level macro used to mark expressions returned by a macro that should be docu more than one expression is marked then the same docstring is applied to each expression. macro example(f) - quote + esc(quote \$(f)() = 0 @__doc__ \$(f)(x) = 1 \$(f)(x, y) = 2 - end |> esc + end) end `@__doc__` has no effect when a macro that uses it is not documented. diff --git a/base/docs/utils.jl b/base/docs/utils.jl index b4a1f4eb947ec..5c76db7dd0555 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -262,7 +262,7 @@ end function fuzzysort(search, candidates) scores = map(cand -> (fuzzyscore(search, cand), -levenshtein(search, cand)), candidates) - candidates[sortperm(scores)] |> reverse + reverse(candidates[sortperm(scores)]) end # Levenshtein Distance @@ -362,9 +362,9 @@ moduleusings(mod) = ccall(:jl_module_usings, Any, (Any,), mod) filtervalid(names) = filter(x->!ismatch(r"#", x), map(string, names)) accessible(mod::Module) = - [filter!(s->Base.isdeprecated(mod, s), names(mod, true, true)); + filtervalid(unique([filter!(s->Base.isdeprecated(mod, s), names(mod, true, true)); map(names, moduleusings(mod))...; - builtins] |> unique |> filtervalid + builtins])) completions(name) = fuzzysort(name, accessible(Main)) completions(name::Symbol) = completions(string(name)) diff --git a/base/exports.jl b/base/exports.jl index 31af9f6ce7813..806ed7908b570 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -214,7 +214,6 @@ export \, ^, |, - |>, ~, :, =>, diff --git a/base/markdown/GitHub/GitHub.jl b/base/markdown/GitHub/GitHub.jl index ae2cfd1120f3a..23700521afee3 100644 --- a/base/markdown/GitHub/GitHub.jl +++ b/base/markdown/GitHub/GitHub.jl @@ -21,9 +21,9 @@ function fencedcode(stream::IO, block::MD) if startswith(stream, string(ch) ^ n) if !startswith(stream, string(ch)) if flavor == "math" - push!(block, LaTeX(String(take!(buffer)) |> chomp)) + push!(block, LaTeX(chomp(String(take!(buffer))))) else - push!(block, Code(flavor, String(take!(buffer)) |> chomp)) + push!(block, Code(flavor, chomp(String(take!(buffer))))) end return true else @@ -63,4 +63,3 @@ end linebreak, escapes, en_dash, inline_code, asterisk_bold, asterisk_italic, image, footnote_link, link, autolink] - diff --git a/base/markdown/render/terminal/formatting.jl b/base/markdown/render/terminal/formatting.jl index 36a4d390a7138..8b3b938cc2e61 100644 --- a/base/markdown/render/terminal/formatting.jl +++ b/base/markdown/render/terminal/formatting.jl @@ -51,7 +51,7 @@ end # Wrapping function ansi_length(s) - replace(s, r"\e\[[0-9]+m", "") |> length + length(replace(s, r"\e\[[0-9]+m", "")) end words(s) = split(s, " ") @@ -64,7 +64,7 @@ function wrapped_lines(s::AbstractString; width = 80, i = 0) end ws = words(s) lines = AbstractString[ws[1]] - i += ws[1] |> ansi_length + i += ansi_length(ws[1]) for word in ws[2:end] word_length = ansi_length(word) if i + word_length + 1 > width diff --git a/base/operators.jl b/base/operators.jl index d40cf227410e1..0bd57c75c2ddd 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -917,21 +917,6 @@ julia> widen(1.5f0) """ widen(x::T) where {T<:Number} = convert(widen(T), x) -# function pipelining - -""" - |>(x, f) - -Applies a function to the preceding argument. This allows for easy function chaining. - -# Examples -```jldoctest -julia> [1:5;] |> x->x.^2 |> sum |> inv -0.01818181818181818 -``` -""" -|>(x, f) = f(x) - # function composition """ diff --git a/doc/src/manual/mathematical-operations.md b/doc/src/manual/mathematical-operations.md index b539efbe3d0e5..04051ecf0506a 100644 --- a/doc/src/manual/mathematical-operations.md +++ b/doc/src/manual/mathematical-operations.md @@ -361,7 +361,6 @@ Julia applies the following order and associativity of operations, from highest | Bitshifts | `<< >> >>>` | Left | | Addition | `+ - \| ⊻` | Left[^2] | | Syntax | `: ..` | Left | -| Syntax | `\|>` | Left | | Syntax | `<\|` | Right | | Comparisons | `> < >= <= == === != !== <:` | Non-associative | | Control flow | `&&` followed by `\|\|` followed by `?` | Right | diff --git a/doc/src/stdlib/base.md b/doc/src/stdlib/base.md index d29a4e552d528..17dd71a9d00c9 100644 --- a/doc/src/stdlib/base.md +++ b/doc/src/stdlib/base.md @@ -188,7 +188,6 @@ Core.applicable Core.invoke Base.invokelatest new -Base.:(|>) Base.:(∘) Base.equalto ``` diff --git a/stdlib/IterativeEigenSolvers/test/runtests.jl b/stdlib/IterativeEigenSolvers/test/runtests.jl index 9c56af6a26b52..f9ac24d3c6045 100644 --- a/stdlib/IterativeEigenSolvers/test/runtests.jl +++ b/stdlib/IterativeEigenSolvers/test/runtests.jl @@ -274,7 +274,7 @@ end @testset "promotion" begin eigs(rand(1:10, 10, 10)) - eigs(rand(1:10, 10, 10), rand(1:10, 10, 10) |> t -> t't) + eigs(rand(1:10, 10, 10), (t -> t't)(rand(1:10, 10, 10))) svds(rand(1:10, 10, 8)) @test_throws MethodError eigs(big.(rand(1:10, 10, 10))) @test_throws MethodError eigs(big.(rand(1:10, 10, 10)), rand(1:10, 10, 10)) diff --git a/stdlib/SuiteSparse/test/cholmod.jl b/stdlib/SuiteSparse/test/cholmod.jl index d948d2c09bf75..8387c1b528472 100644 --- a/stdlib/SuiteSparse/test/cholmod.jl +++ b/stdlib/SuiteSparse/test/cholmod.jl @@ -402,7 +402,7 @@ end @test logdet(ldltfact(A1pd)) ≈ logdet(Array(A1pd)) @test isposdef(A1pd) @test !isposdef(A1) - @test !isposdef(A1 + A1' |> t -> t - 2eigmax(Array(t))*I) + @test !isposdef((t -> t - 2eigmax(Array(t))*I)(A1 + A1')) if elty <: Real @test CHOLMOD.issymmetric(Sparse(A1pd, 0)) @@ -634,7 +634,7 @@ end end @testset "Issue 14134" begin - A = CHOLMOD.Sparse(sprandn(10,5,0.1) + I |> t -> t't) + A = CHOLMOD.Sparse((t -> t't)(sprandn(10,5,0.1) + I)) b = IOBuffer() serialize(b, A) seekstart(b) @@ -677,7 +677,7 @@ end end @testset "Real factorization and complex rhs" begin - A = sprandn(5, 5, 0.4) |> t -> t't + I + A = (t -> t't + I)(sprandn(5, 5, 0.4)) B = complex.(randn(5, 2), randn(5, 2)) @test cholfact(A)\B ≈ A\B end diff --git a/test/broadcast.jl b/test/broadcast.jl index feb44df004e55..eab2281493d20 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -326,7 +326,6 @@ import Base.Meta: isexpr # PR #17623: Fused binary operators @test [true] .* [true] == [true] -@test [1,2,3] .|> (x->x+1) == [2,3,4] let g = Int[], ⊕ = (a,b) -> let c=a+2b; push!(g, c); c; end @test [1,2,3] .⊕ [10,11,12] .⊕ [100,200,300] == [221,424,627] @test g == [21,221,24,424,27,627] # test for loop fusion diff --git a/test/docs.jl b/test/docs.jl index 308849a6a21e1..cf31fefb90c19 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -384,11 +384,11 @@ module MacroGenerated import Base.@__doc__ macro example_1(f) - quote + esc(quote $(f)() = 0 @__doc__ $(f)(x) = x $(f)(x, y) = x + y - end |> esc + end) end "f" @@ -397,11 +397,11 @@ end @example_1 _f macro example_2(f) - quote + esc(quote $(f)() = 0 @__doc__ $(f)(x) = x @__doc__ $(f)(x, y) = x + y - end |> esc + end) end "g" diff --git a/test/libgit2.jl b/test/libgit2.jl index a38fa6fcb01af..5fcbeffbc591b 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -512,7 +512,7 @@ mktempdir() do dir @test isdir(joinpath(cache_repo, ".git")) # set a remote branch branch = "upstream" - LibGit2.GitRemote(repo, branch, repo_url) |> close + close(LibGit2.GitRemote(repo, branch, repo_url)) # test remote's representation in the repo's config config = joinpath(cache_repo, ".git", "config") diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index fdb6b94e8963b..c16bb452e65ff 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -12,10 +12,10 @@ using Test @test ones(0,0)*ones(0,4) == zeros(0,4) @test ones(3,0)*ones(0,0) == zeros(3,0) @test ones(0,0)*ones(0,0) == zeros(0,0) - @test Matrix{Float64}(uninitialized, 5, 0) |> t -> t't == zeros(0,0) - @test Matrix{Float64}(uninitialized, 5, 0) |> t -> t*t' == zeros(5,5) - @test Matrix{Complex128}(uninitialized, 5, 0) |> t -> t't == zeros(0,0) - @test Matrix{Complex128}(uninitialized, 5, 0) |> t -> t*t' == zeros(5,5) + @test (t -> t't)(Matrix{Float64}(uninitialized, 5, 0)) == zeros(0,0) + @test (t -> t*t')(Matrix{Float64}(uninitialized, 5, 0)) == zeros(5,5) + @test (t -> t't)(Matrix{Complex128}(uninitialized, 5, 0)) == zeros(0,0) + @test (t -> t*t')(Matrix{Complex128}(uninitialized, 5, 0)) == zeros(5,5) end @testset "2x2 matmul" begin AA = [1 2; 3 4] diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index 0d8b5d8dbb083..9f341c38c5d3e 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -11,7 +11,7 @@ srand(123) debug && println("Test basic type functionality") @test_throws DimensionMismatch LowerTriangular(randn(5, 4)) -@test LowerTriangular(randn(3, 3)) |> t -> [size(t, i) for i = 1:3] == [size(Matrix(t), i) for i = 1:3] +@test (t -> [size(t, i) for i = 1:3] == [size(Matrix(t), i) for i = 1:3])(LowerTriangular(randn(3, 3))) # The following test block tries to call all methods in base/linalg/triangular.jl in order for a combination of input element types. Keep the ordering when adding code. for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloat}, Int) @@ -22,7 +22,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa (UnitLowerTriangular, :L)) # Construct test matrix - A1 = t1(elty1 == Int ? rand(1:7, n, n) : convert(Matrix{elty1}, (elty1 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo1 == :U ? t : adjoint(t))) + A1 = t1(elty1 == Int ? rand(1:7, n, n) : convert(Matrix{elty1}, (t -> uplo1 == :U ? t : adjoint(t))((t -> chol(t't))(elty1 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n))))) debug && println("elty1: $elty1, A1: $t1") @@ -238,7 +238,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa @test ladb ≈ fladb atol=sqrt(eps(real(float(one(elty1)))))*n*n # Matrix square root - @test sqrt(A1) |> t -> t*t ≈ A1 + @test (t -> t*t)(sqrt(A1)) ≈ A1 # naivesub errors @test_throws DimensionMismatch naivesub!(A1,ones(elty1,n+1)) @@ -275,7 +275,7 @@ for elty1 in (Float32, Float64, BigFloat, Complex64, Complex128, Complex{BigFloa debug && println("elty1: $elty1, A1: $t1, elty2: $elty2") - A2 = t2(elty2 == Int ? rand(1:7, n, n) : convert(Matrix{elty2}, (elty2 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n)) |> t -> chol(t't) |> t -> uplo2 == :U ? t : adjoint(t))) + A2 = t2(elty2 == Int ? rand(1:7, n, n) : convert(Matrix{elty2}, (t -> uplo2 == :U ? t : adjoint(t))((t -> chol(t't))(elty2 <: Complex ? complex.(randn(n, n), randn(n, n)) : randn(n, n))))) # Convert if elty1 <: Real && !(elty2 <: Integer) @@ -397,9 +397,9 @@ end # Matrix square root Atn = UpperTriangular([-1 1 2; 0 -2 2; 0 0 -3]) Atp = UpperTriangular([1 1 2; 0 2 2; 0 0 3]) -@test sqrt(Atn) |> t->t*t ≈ Atn +@test (t->t*t)(sqrt(Atn)) ≈ Atn @test typeof(sqrt(Atn)[1,1]) <: Complex -@test sqrt(Atp) |> t->t*t ≈ Atp +@test (t->t*t)(sqrt(Atp)) ≈ Atp @test typeof(sqrt(Atp)[1,1]) <: Real Areal = randn(n, n)/2 @@ -419,7 +419,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) debug && println("\ntype of A: ", eltya, " type of b: ", eltyb, "\n") debug && println("Solve upper triangular system") - Atri = UpperTriangular(lufact(A)[:U]) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned + Atri = (t -> eltya <: Complex && eltyb <: Real ? real(t) : t)(UpperTriangular(lufact(A)[:U])) # Here the triangular matrix can't be too badly conditioned b = convert(Matrix{eltyb}, eltya <: Complex ? Matrix(Atri)*ones(n, 2) : Matrix(Atri)*ones(n, 2)) x = Matrix(Atri) \ b @@ -447,7 +447,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) end debug && println("Solve lower triangular system") - Atri = UpperTriangular(lufact(A)[:U]) |> t -> eltya <: Complex && eltyb <: Real ? real(t) : t # Here the triangular matrix can't be too badly conditioned + Atri = (t -> eltya <: Complex && eltyb <: Real ? real(t) : t)(UpperTriangular(lufact(A)[:U])) # Here the triangular matrix can't be too badly conditioned b = convert(Matrix{eltyb}, eltya <: Complex ? Matrix(Atri)*ones(n, 2) : Matrix(Atri)*ones(n, 2)) x = Matrix(Atri)\b diff --git a/test/markdown.jl b/test/markdown.jl index 76a18ba1a828e..9c3667ba73274 100644 --- a/test/markdown.jl +++ b/test/markdown.jl @@ -201,24 +201,24 @@ end @test md"Foo \[bar](baz)" == MD(Paragraph("Foo [bar](baz)")) # Basic plain (markdown) output -@test md"foo" |> plain == "foo\n" -@test md"foo *bar* baz" |> plain == "foo *bar* baz\n" -@test md"# title" |> plain == "# title\n" -@test md"## section" |> plain == "## section\n" -@test md"## section `foo`" |> plain == "## section `foo`\n" -@test md"""Hello +@test plain(md"foo") == "foo\n" +@test plain(md"foo *bar* baz") == "foo *bar* baz\n" +@test plain(md"# title") == "# title\n" +@test plain(md"## section") == "## section\n" +@test plain(md"## section `foo`") == "## section `foo`\n" +@test plain(md"""Hello --- -World""" |> plain == "Hello\n\n---\n\nWorld\n" -@test md"[*a*](b)" |> plain == "[*a*](b)\n" -@test md""" +World""") == "Hello\n\n---\n\nWorld\n" +@test plain(md"[*a*](b)") == "[*a*](b)\n" +@test plain(md""" > foo > > * bar > > ``` > baz -> ```""" |> plain == """> foo\n>\n> * bar\n>\n> ```\n> baz\n> ```\n\n""" +> ```""") == """> foo\n>\n> * bar\n>\n> ```\n> baz\n> ```\n\n""" # Terminal (markdown) output @@ -240,45 +240,45 @@ let doc = Markdown.parse( end # HTML output -@test md"foo *bar* baz" |> html == "

foo bar baz

\n" -@test md"something ***" |> html == "

something ***

\n" -@test md"# h1## " |> html == "

h1##

\n" -@test md"## h2 ### " |> html == "

h2

\n" -@test md"###### h6" |> html == "
h6
\n" -@test md"####### h7" |> html == "

####### h7

\n" -@test md" >" |> html == "
\n
\n" -@test md"1. Hello" |> html == "
    \n
  1. Hello

    \n
  2. \n
\n" -@test md"* World" |> html == "\n" -@test md"# title *blah*" |> html == "

title blah

\n" -@test md"## title *blah*" |> html == "

title blah

\n" -@test md"" |> html == """

https://julialang.org

\n""" -@test md"" |> html == """

mailto://a@example.com

\n""" -@test md"" |> html == "

<https://julialang.org/not a link>

\n" -@test md"""""" |> html == "

<https://julialang.org/nota link>

\n" -@test md"""Hello +@test html(md"foo *bar* baz") == "

foo bar baz

\n" +@test html(md"something ***") == "

something ***

\n" +@test html(md"# h1## ") == "

h1##

\n" +@test html(md"## h2 ### ") == "

h2

\n" +@test html(md"###### h6") == "
h6
\n" +@test html(md"####### h7") == "

####### h7

\n" +@test html(md" >") == "
\n
\n" +@test html(md"1. Hello") == "
    \n
  1. Hello

    \n
  2. \n
\n" +@test html(md"* World") == "
    \n
  • World

    \n
  • \n
\n" +@test html(md"# title *blah*") == "

title blah

\n" +@test html(md"## title *blah*") == "

title blah

\n" +@test html(md"") == """

https://julialang.org

\n""" +@test html(md"") == """

mailto://a@example.com

\n""" +@test html(md"") == "

<https://julialang.org/not a link>

\n" +@test html(md"""""") == "

<https://julialang.org/nota link>

\n" +@test html(md"""Hello --- -World""" |> html == "

Hello

\n
\n

World

\n" -@test md"`escape`" |> html == "

escape</code>

\n" +World""") == "

Hello

\n
\n

World

\n" +@test html(md"`escape`") == "

escape</code>

\n" -@test md""" +@test html(md""" code1 code2 -""" |> html == "
code1\n\ncode2
\n" # single code block +""") == "
code1\n\ncode2
\n" # single code block -# @test md""" +# @test html(md""" # - Foo # --- -# - Bar""" |> html == "
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n" -@test md""" +# - Bar""") == "
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n" +@test html(md""" h1 === h2 --- not -== =""" |> html == "

h1

\n

h2

\n

not == =

\n" +== =""") == "

h1

\n

h2

\n

not == =

\n" # Latex output book = md""" diff --git a/test/nullable.jl b/test/nullable.jl index b3f8b82c7d95e..a17347c9a56e5 100644 --- a/test/nullable.jl +++ b/test/nullable.jl @@ -415,63 +415,61 @@ using Dates # filter for p in (_ -> true, _ -> false) - @test @inferred(filter(p, Nullable())) |> isnull_oftype(Union{}) - @test @inferred(filter(p, Nullable{Int}())) |> isnull_oftype(Int) + @test isnull_oftype(Union{})(@inferred(filter(p, Nullable()))) + @test isnull_oftype(Int)(@inferred(filter(p, Nullable{Int}()))) end @test @inferred(filter(_ -> true, Nullable(85))) === Nullable(85) -@test @inferred(filter(_ -> false, Nullable(85))) |> isnull_oftype(Int) +@test isnull_oftype(Int)(@inferred(filter(_ -> false, Nullable(85)))) @test @inferred(filter(x -> x > 0, Nullable(85))) === Nullable(85) -@test @inferred(filter(x -> x < 0, Nullable(85))) |> isnull_oftype(Int) +@test isnull_oftype(Int)(@inferred(filter(x -> x < 0, Nullable(85)))) @test get(@inferred(filter(x -> length(x) > 2, Nullable("test")))) == "test" -@test @inferred(filter(x -> length(x) > 5, Nullable("test"))) |> - isnull_oftype(String) +@test isnull_oftype(String)(@inferred(filter(x -> length(x) > 5, Nullable("test")))) + # map sqr(x) = x^2 -@test @inferred(map(sqr, Nullable())) |> isnull_oftype(Union{}) -@test @inferred(map(sqr, Nullable{Int}())) |> isnull_oftype(Int) +@test isnull_oftype(Union{})(@inferred(map(sqr, Nullable()))) +@test isnull_oftype(Int)(@inferred(map(sqr, Nullable{Int}()))) @test @inferred(map(sqr, Nullable(2))) === Nullable(4) @test @inferred(map(+, Nullable(0.0))) === Nullable(0.0) @test @inferred(map(+, Nullable(3.0, false)))=== Nullable(3.0, false) @test @inferred(map(-, Nullable(1.0))) === Nullable(-1.0) -@test @inferred(map(-, Nullable{Float64}())) |> isnull_oftype(Float64) +@test isnull_oftype(Float64)(@inferred(map(-, Nullable{Float64}()))) @test @inferred(map(sin, Nullable(1))) === Nullable(sin(1)) -@test @inferred(map(sin, Nullable{Int}())) |> isnull_oftype(Float64) +@test isnull_oftype(Float64)(@inferred(map(sin, Nullable{Int}()))) # should not throw if function wouldn't be called -@test map(x -> x ? 0 : 0.0, Nullable()) |> isnull_oftype(Union{}) +@test isnull_oftype(Union{})(map(x -> x ? 0 : 0.0, Nullable())) @test map(x -> x ? 0 : 0.0, Nullable(true)) === Nullable(0) @test map(x -> x ? 0 : 0.0, Nullable(false)) === Nullable(0.0) -@test map(x -> x ? 0 : 0.0, Nullable{Bool}()) |> isnull_oftype(Union{}) +@test isnull_oftype(Union{})(map(x -> x ? 0 : 0.0, Nullable{Bool}())) # broadcast and elementwise @test sin.(Nullable(0.0)) === Nullable(0.0) -@test sin.(Nullable{Float64}()) |> isnull_oftype(Float64) +@test isnull_oftype(Float64)(sin.(Nullable{Float64}())) @test @inferred(broadcast(sin, Nullable(0.0))) === Nullable(0.0) -@test @inferred(broadcast(sin, Nullable{Float64}())) |> isnull_oftype(Float64) +@test isnull_oftype(Float64)(@inferred(broadcast(sin, Nullable{Float64}()))) @test Nullable(8) .+ Nullable(10) === Nullable(18) @test Nullable(8) .- Nullable(10) === Nullable(-2) -@test Nullable(8) .+ Nullable{Int}() |> isnull_oftype(Int) -@test Nullable{Int}() .- Nullable(10) |> isnull_oftype(Int) +@test isnull_oftype(Int)(Nullable(8) .+ Nullable{Int}()) +@test isnull_oftype(Int)(Nullable{Int}() .- Nullable(10)) @test @inferred(broadcast(log, 10, Nullable(1.0))) === Nullable(0.0) -@test @inferred(broadcast(log, 10, Nullable{Float64}())) |> - isnull_oftype(Float64) +@test isnull_oftype(Float64)(@inferred(broadcast(log, 10, Nullable{Float64}()))) @test @inferred(broadcast(log, Nullable(10), Nullable(1.0))) === Nullable(0.0) -@test @inferred(broadcast(log, Nullable(10), Nullable{Float64}())) |> - isnull_oftype(Float64) +@test isnull_oftype(Float64)(@inferred(broadcast(log, Nullable(10), Nullable{Float64}()))) @test Nullable(2) .^ Nullable(4) === Nullable(16) -@test Nullable(2) .^ Nullable{Int}() |> isnull_oftype(Int) +@test isnull_oftype(Int)(Nullable(2) .^ Nullable{Int}()) # multi-arg broadcast @test (Nullable(1) .+ Nullable(1) .+ Nullable(1) .+ Nullable(1) .+ Nullable(1) .+ Nullable(1) === Nullable(6)) -@test (Nullable(1) .+ Nullable(1) .+ Nullable(1) .+ Nullable{Int}() .+ - Nullable(1) .+ Nullable(1) |> isnull_oftype(Int)) +@test isnull_oftype(Int)(Nullable(1) .+ Nullable(1) .+ Nullable(1) .+ Nullable{Int}() .+ + Nullable(1) .+ Nullable(1)) # these are not inferrable because there are too many arguments us = map(Nullable, 1:20) @@ -485,12 +483,9 @@ for op in (+, -, *, /, \, //, ==, <, !=, <=, ÷, %, <<, >>, ^) res = op(1, 1) @test @inferred(broadcast(op, Nullable(1), Nullable(1))) === Nullable(res) - @test @inferred(broadcast(op, Nullable{Int}(), Nullable(1))) |> - isnull_oftype(typeof(res)) - @test @inferred(broadcast(op, Nullable(1), Nullable{Int}())) |> - isnull_oftype(typeof(res)) - @test @inferred(broadcast(op, Nullable{Int}(), Nullable{Int}())) |> - isnull_oftype(typeof(res)) + @test isnull_oftype(typeof(res))(@inferred(broadcast(op, Nullable{Int}(), Nullable(1)))) + @test isnull_oftype(typeof(res))(@inferred(broadcast(op, Nullable(1), Nullable{Int}()))) + @test isnull_oftype(typeof(res))(@inferred(broadcast(op, Nullable{Int}(), Nullable{Int}()))) @test @inferred(broadcast(op, Nullable(1), 1)) === Nullable(res) @test @inferred(broadcast(op, 1, Nullable(1))) ===