From a5f4d11cdb9465b1ffa2892b3d84ee53b8962930 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 26 Feb 2010 03:05:21 -0800 Subject: tee_input: avoid instance variables, it's a struct We'll use struct members exclusively from now on instead of throwing ivars into the mix. This allows us to _unofficially_ support direct access to more members easily. Unofficial extensions may include the ability to splice(2)/tee(2) for better performance. This also makes our object size smaller across all Ruby implementations as well, too (helps Rainbows! out). --- test/unit/test_tee_input.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/unit/test_tee_input.rb b/test/unit/test_tee_input.rb index 403f698..ee81a87 100644 --- a/test/unit/test_tee_input.rb +++ b/test/unit/test_tee_input.rb @@ -71,8 +71,8 @@ class TestTeeInput < Test::Unit::TestCase ti = Unicorn::TeeInput.new(@rd, @env, @parser, @buf) assert_equal 0, @parser.content_length assert @parser.body_eof? - assert_equal StringIO, ti.instance_eval { @tmp.class } - assert_equal 0, ti.instance_eval { @tmp.pos } + assert_equal StringIO, ti.tmp.class + assert_equal 0, ti.tmp.pos assert_equal 5, ti.size assert_equal 'hello', ti.read assert_equal '', ti.read @@ -99,8 +99,8 @@ class TestTeeInput < Test::Unit::TestCase ti = Unicorn::TeeInput.new(@rd, @env, @parser, @buf) assert_equal 0, @parser.content_length assert @parser.body_eof? - assert_kind_of File, ti.instance_eval { @tmp } - assert_equal 0, ti.instance_eval { @tmp.pos } + assert_kind_of File, ti.tmp + assert_equal 0, ti.tmp.pos assert_equal Unicorn::Const::MAX_BODY + 1, ti.size end @@ -125,9 +125,9 @@ class TestTeeInput < Test::Unit::TestCase ti = Unicorn::TeeInput.new(@rd, @env, @parser, @buf) assert_equal Unicorn::Const::MAX_BODY, @parser.content_length assert ! @parser.body_eof? - assert_kind_of File, ti.instance_eval { @tmp } - assert_equal 0, ti.instance_eval { @tmp.pos } - assert_equal 1, ti.instance_eval { @tmp.size } + assert_kind_of File, ti.tmp + assert_equal 0, ti.tmp.pos + assert_equal 1, ti.tmp.size assert_equal Unicorn::Const::MAX_BODY + 1, ti.size nr = Unicorn::Const::MAX_BODY / 4 pid = fork { @@ -165,19 +165,19 @@ class TestTeeInput < Test::Unit::TestCase @wr.close ti = Unicorn::TeeInput.new(@rd, @env, @parser, @buf) assert_nil @parser.content_length - assert_nil ti.instance_eval { @size } + assert_nil ti.len assert ! @parser.body_eof? assert_equal 25, ti.size assert @parser.body_eof? - assert_equal 25, ti.instance_eval { @size } - assert_equal 0, ti.instance_eval { @tmp.pos } + assert_equal 25, ti.len + assert_equal 0, ti.tmp.pos assert_nothing_raised { ti.rewind } - assert_equal 0, ti.instance_eval { @tmp.pos } + assert_equal 0, ti.tmp.pos assert_equal 'abcdeabcdeabcdeabcde', ti.read(20) - assert_equal 20, ti.instance_eval { @tmp.pos } + assert_equal 20, ti.tmp.pos assert_nothing_raised { ti.rewind } - assert_equal 0, ti.instance_eval { @tmp.pos } - assert_kind_of File, ti.instance_eval { @tmp } + assert_equal 0, ti.tmp.pos + assert_kind_of File, ti.tmp status = nil assert_nothing_raised { pid, status = Process.waitpid2(pid) } assert status.success? @@ -203,7 +203,7 @@ class TestTeeInput < Test::Unit::TestCase } ti = Unicorn::TeeInput.new(@rd, @env, @parser, @buf) assert_nil @parser.content_length - assert_nil ti.instance_eval { @size } + assert_nil ti.len assert ! @parser.body_eof? chunks.each do |chunk| wr.write('.') -- cgit v1.2.3-24-ge0c7