diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb b/web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb new file mode 100644 index 000000000..2aa3dab2c --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby-env/test/env_test.rb @@ -0,0 +1,121 @@ +## +# ENV test +# + +if Object.const_defined?(:MTest) + class ENVTest < MTest::Unit::TestCase + def test_env_class + assert_equal(Object, ENV.class) + end + + def setup + @env_hash = ENV.to_hash + ENV.clear + end + + def teardown + ENV.clear + @env_hash.each do |k, v| + ENV[k] = v + end + end + + def set_dummy_env + ENV['FOO'] = 'bar' + end + + def test_size_empty + assert_equal(0, ENV.size) + end + + def test_keys_empty + assert_empty(ENV.keys) + end + + def test_values_empty + assert_empty(ENV.values) + end + + def test_env_to_s_empty + assert_equal("ENV", ENV.to_s) + end + + def test_env_inspect_empty + assert_equal("{}", ENV.inspect) + end + + def test_env_to_hash_empty + assert_equal({}, ENV.to_hash) + end + + def test_env_get_val + set_dummy_env + assert_equal('bar', ENV['FOO']) + end + + def test_env_keys + set_dummy_env + assert_equal(['FOO'], ENV.keys) + end + + def test_env_values + set_dummy_env + assert_equal(['bar'], ENV.values) + end + + def test_env_to_s + set_dummy_env + assert_equal("ENV", ENV.to_s) + end + + def test_env_has_key + set_dummy_env + assert_true ENV.has_key?("FOO") + assert_false ENV.has_key?("BAR") + end + + def test_env_inspect + set_dummy_env + assert_equal("{\"FOO\"=>\"bar\"}", ENV.inspect) + end + + def test_env_delete + set_dummy_env + old = ENV['FOO'] + ret = ENV.delete('FOO') + assert_equal(0, ENV.size) + assert_equal(old, ret) + assert_equal(nil, ENV.delete('nosuchenv')) + end + + def test_env_subst_nil + set_dummy_env + ENV['FOO'] = nil + assert_equal(0, ENV.size) + end + + def test_env_store + ENV['a'] = 'b' + assert_equal 'b', ENV['a'] + + ENV['a'] = 'c' + assert_equal 'c', ENV['a'] + + ENV['a'] = nil + assert_equal nil, ENV['a'] + + ENV['b'] = nil + assert_equal nil, ENV['b'] + assert_equal 0, ENV.size + end + end + + if $ok_test + MTest::Unit.new.mrbtest + else + MTest::Unit.new.run + end +else + $asserts << "test skip of mruby-env/test/env_test.rb" if $asserts +end + |