Skip to content

Commit

Permalink
Move env.jl test to separate test file
Browse files Browse the repository at this point in the history
(cherry picked from commit 30afe08)
ref #18012
  • Loading branch information
dhoegh authored and tkelman committed Aug 20, 2016
1 parent 6538aad commit ede7231
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function choosetests(choices = [])
"priorityqueue", "file", "read", "mmap", "version", "resolve",
"pollfd", "mpfr", "broadcast", "complex", "socket",
"floatapprox", "datafmt", "reflection", "regex", "float16",
"combinatorics", "sysinfo", "rounding", "ranges", "mod2pi",
"combinatorics", "sysinfo", "env", "rounding", "ranges", "mod2pi",
"euler", "show", "lineedit", "replcompletions", "repl",
"replutil", "sets", "test", "goto", "llvmcall", "grisu",
"nullable", "meta", "stacktraces", "profile", "libgit2", "docs",
Expand Down
32 changes: 32 additions & 0 deletions test/env.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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"
31 changes: 0 additions & 31 deletions test/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,3 @@
sprint(Base.Sys.cpu_summary)
@test Base.Sys.uptime() > 0
Base.Sys.loadavg()

@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"

0 comments on commit ede7231

Please sign in to comment.