Skip to content

Commit 280c2fc

Browse files
committed
Add Val(x)
Introduced in JuliaLang/julia#22475
1 parent bdf61d8 commit 280c2fc

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/Compat.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ if VERSION < v"0.6.0-pre.beta.455"
607607
isless(x::Dates.OtherPeriod, y::Dates.FixedPeriod) = throw(MethodError(isless, (x, y)))
608608
end
609609

610+
# https://github.com/JuliaLang/julia/pull/22475
611+
if VERSION < v"0.7.0-DEV.843"
612+
import Base: Val
613+
(::Type{Val})(x) = (Base.@_pure_meta; Val{x}())
614+
end
615+
610616
include("deprecated.jl")
611617

612618
# https://github.com/JuliaLang/julia/pull/21746

test/runtests.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,28 +338,28 @@ end
338338
# Val
339339
begin
340340
local firstlast
341-
firstlast(::Type{Val{true}}) = "First"
342-
firstlast(::Type{Val{false}}) = "Last"
341+
firstlast(::Val{true}) = "First"
342+
firstlast(::Val{false}) = "Last"
343343

344-
@test firstlast(Val{true}) == "First"
345-
@test firstlast(Val{false}) == "Last"
344+
@test firstlast(Val(true)) == "First"
345+
@test firstlast(Val(false)) == "Last"
346346
end
347347

348348
# qr, qrfact, qrfact!
349349
let A = [1.0 2.0; 3.0 4.0]
350-
Q, R = qr(A, Val{false})
350+
Q, R = qr(A, Val(false))
351351
@test Q*R A
352-
Q, R, p = qr(A, Val{true})
352+
Q, R, p = qr(A, Val(true))
353353
@test Q*R A[:,p]
354-
F = qrfact(A, Val{false})
354+
F = qrfact(A, Val(false))
355355
@test F[:Q]*F[:R] A
356-
F = qrfact(A, Val{true})
356+
F = qrfact(A, Val(true))
357357
@test F[:Q]*F[:R] A[:,F[:p]]
358358
A_copy = copy(A)
359-
F = qrfact!(A_copy, Val{false})
359+
F = qrfact!(A_copy, Val(false))
360360
@test F[:Q]*F[:R] A
361361
A_copy = copy(A)
362-
F = qrfact!(A_copy, Val{true})
362+
F = qrfact!(A_copy, Val(true))
363363
@test F[:Q]*F[:R] A[:,F[:p]]
364364
end
365365

@@ -1397,11 +1397,11 @@ for A in (Hermitian(randn(5,5) + 10I),
13971397
@test istriu(chol(A))
13981398
@test chol(A) F[:U]
13991399

1400-
F = cholfact(A, Val{true})
1400+
F = cholfact(A, Val(true))
14011401
@test F[:U]'F[:U] A[F[:p], F[:p]]
14021402
@test F[:L]*F[:L]' A[F[:p], F[:p]]
14031403
Ac = copy(A)
1404-
F = cholfact!(Ac, Val{true})
1404+
F = cholfact!(Ac, Val(true))
14051405
@test F[:U]'F[:U] A[F[:p], F[:p]]
14061406
@test F[:L]*F[:L]' A[F[:p], F[:p]]
14071407
end

0 commit comments

Comments
 (0)