Revision caff424ef73c130466be633815be25b9708c30e7 authored by Jane Herriman on 27 March 2017, 12:55:30 UTC, committed by Tony Kelman on 27 March 2017, 12:55:30 UTC
1 parent 55f4417
env.jl
# This file is a part of Julia. License is MIT: http://julialang.org/license
@test !("f=a=k=e=n=a=m=e" ∈ keys(ENV))
# issue #10994
@test_throws ArgumentError ENV["bad\0name"] = "ok"
@test_throws ArgumentError ENV["okname"] = "bad\0val"
@test_throws ArgumentError Sys.set_process_title("bad\0title")
withenv("bad"=>"dog") do
@test_throws ArgumentError ENV["bad\0cat"]
end
# issue #11170
withenv("TEST"=>"nonempty") do
@test ENV["TEST"] == "nonempty"
end
withenv("TEST"=>"") do
@test ENV["TEST"] == ""
end
let c = collect(ENV)
@test isa(c, Vector)
@test length(ENV) == length(c)
@test isempty(ENV) || first(ENV) in c
end
# test for non-existent keys
key = randstring(25)
@test !haskey(ENV,key)
@test_throws KeyError ENV[key]
@test get(ENV,key,"default") == "default"
# Test for #17956
@test length(ENV) > 1
k1, k2 = "__test__", "__test1__"
withenv(k1=>k1, k2=>k2) do
b_k1, b_k2 = false, false
for (k, v) in ENV
if k==k1
b_k1=true
elseif k==k2
b_k2=true
end
end
@test b_k1 && b_k2
io = IOBuffer()
show(io, ENV)
s = String(take!(io))
@test contains(s, "$k1=$k1")
@test contains(s, "$k2=$k2")
@test pop!(ENV, k1) == k1
@test !haskey(ENV, k1)
ENV[k1] = k1
@test pop!(ENV, k1) == k1
@test pop!(ENV, k1, "not_there") == "not_there"
ENV[k1] = k1
@test delete!(ENV, k1) == ENV
@test !haskey(ENV, k1)
end
# Test for #10853
@test withenv(Dict{Any,Any}()...) do; true; end
# Test for #18141
for (k, v) in ENV
if length(v) > 0
@test v[end] != '\0'
end
end
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...