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-dir/test/dir.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-dir/test/dir.rb')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby-dir/test/dir.rb | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby-dir/test/dir.rb b/web/server/h2o/libh2o/deps/mruby-dir/test/dir.rb new file mode 100644 index 000000000..cb1f1e31b --- /dev/null +++ b/web/server/h2o/libh2o/deps/mruby-dir/test/dir.rb @@ -0,0 +1,128 @@ +assert('Dir') do + assert_equal(Class, Dir.class) +end + +assert('DirTest.setup') do + DirTest.setup +end + +assert('Dir.chdir') do + assert_equal 0, Dir.chdir(DirTest.sandbox) +end + +assert('Dir.entries') do + a = Dir.entries(DirTest.sandbox) + assert_true a.include? "a" + assert_true a.include? "b" +end + +assert('Dir.exist?') do + assert_true Dir.exist?(DirTest.sandbox) + assert_false Dir.exist?(DirTest.sandbox + "/nosuchdir") +end + +assert('Dir.foreach') do + a = [] + Dir.foreach(DirTest.sandbox) { |s| a << s } + assert_true a.include? "a" + assert_true a.include? "b" +end + +assert('Dir.getwd') do + s = Dir.getwd + assert_true s.kind_of? String +end + +assert('Dir.mkdir') do + m1 = DirTest.sandbox + "/mkdir1" + m2 = DirTest.sandbox + "/mkdir2" + assert_equal 0, Dir.mkdir(m1) + assert_equal 0, Dir.mkdir(m2, 0765) +end + +assert('Dir.delete') do + s = DirTest.sandbox + "/delete" + Dir.mkdir(s) + assert_true Dir.exist?(s) + + Dir.delete(s) + assert_false Dir.exist?(s) +end + +assert('Dir.open') do + a = [] + Dir.open(DirTest.sandbox) { |d| + d.each { |s| a << s } + } + assert_true a.include? "a" + assert_true a.include? "b" +end + +assert('Dir#initialize and Dir#close') do + d = Dir.new(".") + assert_true d.instance_of? Dir + assert_nil d.close +end + +assert('Dir#close') do + d = Dir.new(".") +end + +assert('Dir#each') do + a = [] + d = Dir.open(DirTest.sandbox) + d.each { |s| a << s } + d.close + assert_true a.include? "a" + assert_true a.include? "b" +end + +assert('Dir#read') do + a = [] + d = Dir.open(DirTest.sandbox) + while s = d.read + a << s + end + d.close + assert_true a.include? "a" + assert_true a.include? "b" +end + +assert('Dir#rewind') do + d = Dir.open(DirTest.sandbox) + while d.read; end + + assert_equal d, d.rewind + + a = [] + while s = d.read + a << s + end + d.close + assert_true a.include? "a" + assert_true a.include? "b" +end + +# Note: behaviors of seekdir(3) and telldir(3) are so platform-dependent +# that we cannot write portable tests here. + +assert('Dir#tell') do + n = nil + Dir.open(DirTest.sandbox) { |d| + n = d.tell + } + assert_true n.is_a? Integer +end + +assert('Dir#seek') do + d1 = Dir.open(DirTest.sandbox) + d1.read + n = d1.tell + d1.read + d2 = d1.seek(n) + assert_equal d1, d2 +end + +assert('DirTest.teardown') do + DirTest.teardown +end |