diff options
Diffstat (limited to 'debian/vendor-h2o/deps/mruby-require/test')
6 files changed, 0 insertions, 311 deletions
diff --git a/debian/vendor-h2o/deps/mruby-require/test/d/required.rb b/debian/vendor-h2o/deps/mruby-require/test/d/required.rb deleted file mode 100644 index d6218cd..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/d/required.rb +++ /dev/null @@ -1,19 +0,0 @@ -# global variables -$gvar0 = 1 -$gvar1 = 1 - -# toplevel local variables -lvar0 = 1 -lvar1 = 1 - -# define a procedure -def proc0 - :proc0 -end - -# define a new method of an existing class. -class MrubyRequireClass - def foo - :foo - end -end diff --git a/debian/vendor-h2o/deps/mruby-require/test/require.rb b/debian/vendor-h2o/deps/mruby-require/test/require.rb deleted file mode 100644 index 95e1ef0..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/require.rb +++ /dev/null @@ -1,28 +0,0 @@ -assert("Kernel.require") do - # see d/required.rb - $gvar1 = 0 - lvar1 = 0 - class MrubyRequireClass; end - - assert_true require(File.join(File.dirname(__FILE__), "d", "required.rb")) - - # Kernel.require can create a global variable - assert_equal 1, $gvar0 - - # Kernel.require can change value of a global variable - assert_equal 1, $gvar1 - - # Kernel.require cannot create a local variable - assert_raise(NoMethodError) do - lvar0 - end - - # Kernel.require cannot change value of a local variable - assert_equal 0, lvar1 - - # Kernel.require can define a toplevel procedure - assert_equal :proc0, proc0 - - # Kernel.require can add a method to an existing class - assert_equal :foo, MrubyRequireClass.new.foo -end diff --git a/debian/vendor-h2o/deps/mruby-require/test/test.rb b/debian/vendor-h2o/deps/mruby-require/test/test.rb deleted file mode 100644 index 0886cab..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/test.rb +++ /dev/null @@ -1,34 +0,0 @@ -$" = [] # init - -assert "Kernel#_load_rb_str" do - assert_equal true, self.methods.include?(:_load_rb_str) - assert_equal false, Object.const_defined?(:LOAD_RB_STR_TEST) - _load_rb_str("LOAD_RB_STR_TEST = 1") - assert_equal true, Object.const_defined?(:LOAD_RB_STR_TEST) -end - -assert "$LOAD_PATH check" do - assert_equal Array, $LOAD_PATH.class -end - -assert '$" check' do - assert_equal [], $" -end - -assert('load - error check') do - assert_raise TypeError, "load(nil) should raise TypeError" do - load nil - end - assert_raise LoadError, "load('notfound') should raise LoadError" do - load 'notfound' - end -end - -assert('require - error check') do - assert_raise TypeError, "require(nil) should raise TypeError" do - require nil - end - assert_raise LoadError, "require('notfound') should raise LoadError" do - require "notfound" - end -end diff --git a/debian/vendor-h2o/deps/mruby-require/test/test2.rb b/debian/vendor-h2o/deps/mruby-require/test/test2.rb deleted file mode 100644 index b66b9fd..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/test2.rb +++ /dev/null @@ -1,139 +0,0 @@ -$dir = File.join(Dir.tmpdir, "mruby-require-test-#{Time.now.to_i}.#{Time.now.usec}") - -def test_setup - Dir.mkdir($dir) unless File.exist?($dir) - - File.open(File.join($dir, "test.rb"), "w") do |fp| - fp.puts "$require_test_variable = 123" - end - - File.open(File.join($dir, "test_dir.rb"), "w") do |fp| - fp.puts "$test_dir = 'test_dir'" - end - Dir.mkdir(File.join($dir, "test_dir")) - File.open(File.join($dir, "test_dir", "test_dir.rb"), "w") do |fp| - fp.puts "$test_dir2 = 'test_dir/test_dir'" - end - - File.open(File.join($dir, "test_conf.conf"), "w") do |fp| - fp.puts "$test_conf = 'test_conf'" - end - - File.open(File.join($dir, "empty.rb"), "w") - - test_reset -end - -def test_reset - $require_test_variable = nil - $test_dir = nil - $test_dir2 = nil - $test_conf = nil - $LOAD_PATH = [$dir] - $" = [] -end - -def remove_file_recursive(path) - if File.directory? path - Dir.entries(path).each do |entry| - next if ['.', '..'].include?(entry) - remove_file_recursive File.join(path, entry) - end - Dir.unlink path - else - File.unlink path - end -end - -def test_cleanup - if $dir && File.exist?($dir) - remove_file_recursive $dir - end -end - -##### -test_setup -##### - -assert("require 'test' should be success") do - test_reset - - assert_true require("test"), "require returns true when success" - assert_equal [File.join($dir, "test.rb")], $" - assert_equal 123, $require_test_variable - $require_test_variable = 789 - assert_false require("test"), "2nd require should returns false" - assert_equal 789, $require_test_variable - - test_reset - - assert_true require("test.rb"), "require should be success with '.rb'" - assert_equal [File.join($dir, "test.rb")], $" -end - -assert("require with absolute path should be success") do - test_reset - assert_true require(File.join($dir, "test")) - assert_equal [File.join($dir, "test.rb")], $" - - test_reset - assert_true require(File.join($dir, "test.rb")) - assert_equal [File.join($dir, "test.rb")], $" -end - -assert("require with absolute path && empty load_path") do - test_reset - $LOAD_PATH = [] - - assert_raise LoadError, "cannot load test.rb" do - require "test" - end - assert_equal true, require(File.join($dir, "test")) -end - -assert("require 'test_dir' should be success") do - test_reset - - assert_true require("test_dir"), "require 'test_dir' should be load 'test_dir.rb'" - assert_equal [File.join($dir, "test_dir.rb")], $" - assert_true require("test_dir/test_dir"), "require 'test_dir/test_dir' should be success" - assert_equal 'test_dir/test_dir', $test_dir2 -end - -assert("require 'test_conf' should be fail") do - test_reset - - assert_raise LoadError, "require 'test_conf.conf' should be fail" do - require("test_conf.conf") - end - assert_raise LoadError, "require method can't load *.conf" do - require File.join($dir, "test_conf.conf") - end -end - -assert("require 'empty' should be success") do - test_reset - - assert_true require("empty") - assert_equal 0, File.size(File.join($dir, "empty.rb")) -end - -assert("load 'test.rb' should be success") do - test_reset - - assert_true load(File.join($dir, "test.rb")) - assert_equal 123, $require_test_variable - assert_true $".empty? -end - -assert("load 'test_conf.conf' should be success") do - test_reset - - assert_equal true, load(File.join($dir, "test_conf.conf")) - assert_equal "test_conf", $test_conf -end - - -##### -test_cleanup -##### diff --git a/debian/vendor-h2o/deps/mruby-require/test/test_context.rb b/debian/vendor-h2o/deps/mruby-require/test/test_context.rb deleted file mode 100644 index 0011747..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/test_context.rb +++ /dev/null @@ -1,33 +0,0 @@ -$dir = File.join(Dir.tmpdir, "mruby-require-test-#{Time.now.to_i}.#{Time.now.usec}") - -def test_setup - Dir.mkdir($dir) unless File.exist?($dir) - - File.open(File.join($dir, "foo.rb"), "w") do |f| - f.puts "$require_context = self" - end -end - -def test_cleanup - if $dir && File.exist?($dir) - Dir.entries($dir).each do |e| - next if ['.', '..'].include? e - File.unlink File.join($dir,e) - end - Dir.unlink $dir - end -end - - -##### -test_setup -##### - -assert("require context") do - require File.join($dir, 'foo.rb') - assert_equal self, $require_context -end - -##### -test_cleanup -##### diff --git a/debian/vendor-h2o/deps/mruby-require/test/test_nest_loop.rb b/debian/vendor-h2o/deps/mruby-require/test/test_nest_loop.rb deleted file mode 100644 index c5a4b18..0000000 --- a/debian/vendor-h2o/deps/mruby-require/test/test_nest_loop.rb +++ /dev/null @@ -1,58 +0,0 @@ -$dir = File.join(Dir.tmpdir, "mruby-require-test-#{Time.now.to_i}.#{Time.now.usec}") - -def test_setup - Dir.mkdir($dir) - - File.open(File.join($dir, "loop1.rb"), "w") do |fp| - fp.puts "require 'loop2.rb'" - fp.puts "$loop1 = 'loop1'" - end - File.open(File.join($dir, "loop2.rb"), "w") do |fp| - fp.puts "require 'loop1.rb'" - fp.puts "$loop2 = 'loop2'" - end - - $require_test_count = 10 - (1..$require_test_count-1).each do |i| - File.open(File.join($dir, "#{i+1}.rb"), "w") do |fp| - fp.puts "require '#{i}'" - fp.puts "s = 0" - (0..100).each{|num| fp.puts "s += #{num}" } - end - end - File.open(File.join($dir, "1.rb"), "w") do |fp| - fp.puts "$require_test_0 = 123" - end - - $LOAD_PATH = [$dir] -end - -def test_cleanup - if $dir && File.exist?($dir) - Dir.entries($dir).each do |e| - next if ['.', '..'].include? e - File.unlink File.join($dir,e) - end - Dir.unlink $dir - end -end - -##### -test_setup -##### - -assert("require loop check") do - require 'loop1' - assert_equal 'loop1', $loop1 - assert_equal 'loop2', $loop2 -end - -assert("require nest") do - before = $".size - require "#{$require_test_count}" - assert_equal before + $require_test_count, $".size -end - -##### -test_cleanup -##### |