* test/with_diffent_ofs.rb (DifferentOFS): test suite for test
suites affected by $,. * test/digest/test_digest_extend.rb (TestDigestExtend): should not assume $, invariant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
36feefecb9
commit
7df8b94926
@ -1,4 +1,10 @@
|
|||||||
Sat Dec 25 22:04:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Dec 25 22:08:04 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/with_diffent_ofs.rb (DifferentOFS): test suite for test
|
||||||
|
suites affected by $,.
|
||||||
|
|
||||||
|
* test/digest/test_digest_extend.rb (TestDigestExtend): should not
|
||||||
|
assume $, invariant.
|
||||||
|
|
||||||
* test/csv/test_data_converters.rb, test/csv/test_table.rb: don't
|
* test/csv/test_data_converters.rb, test/csv/test_table.rb: don't
|
||||||
not call setup within tests.
|
not call setup within tests.
|
||||||
|
@ -2,19 +2,8 @@ require "test/unit"
|
|||||||
|
|
||||||
require "csv"
|
require "csv"
|
||||||
|
|
||||||
class TestCSV < Test::Unit::TestCase
|
require_relative "../with_diffent_ofs.rb"
|
||||||
module DifferentOFS
|
|
||||||
def setup
|
|
||||||
super
|
|
||||||
@ofs, $, = $,, "-"
|
|
||||||
end
|
|
||||||
def teardown
|
|
||||||
$, = @ofs
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.with_diffrent_ofs
|
class TestCSV < Test::Unit::TestCase
|
||||||
const_set(:DifferentOFS, Class.new(self).class_eval {include DifferentOFS}).name
|
include DifferentOFS
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'digest'
|
require 'digest'
|
||||||
|
require_relative '../with_diffent_ofs.rb'
|
||||||
|
|
||||||
class TestDigestExtend < Test::Unit::TestCase
|
class TestDigestExtend < Test::Unit::TestCase
|
||||||
|
include DifferentOFS
|
||||||
|
|
||||||
class MyDigest < Digest::Class
|
class MyDigest < Digest::Class
|
||||||
def initialize(*arg)
|
def initialize(*arg)
|
||||||
super
|
super
|
||||||
@ -20,7 +23,7 @@ class TestDigestExtend < Test::Unit::TestCase
|
|||||||
alias << update
|
alias << update
|
||||||
|
|
||||||
def finish
|
def finish
|
||||||
(@buf.join.length % 256).chr
|
(@buf.join('').length % 256).chr
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@ -39,8 +42,8 @@ class TestDigestExtend < Test::Unit::TestCase
|
|||||||
assert_equal('', Digest.hexencode(''))
|
assert_equal('', Digest.hexencode(''))
|
||||||
assert_equal('0102', Digest.hexencode("\1\2"))
|
assert_equal('0102', Digest.hexencode("\1\2"))
|
||||||
assert_equal(
|
assert_equal(
|
||||||
(0..0xff).to_a.map { |c| sprintf("%02x", c ) }.join,
|
(0..0xff).to_a.map { |c| sprintf("%02x", c ) }.join(''),
|
||||||
Digest.hexencode((0..0xff).to_a.map { |c| c.chr }.join)
|
Digest.hexencode((0..0xff).to_a.map { |c| c.chr }.join(''))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
22
test/with_diffent_ofs.rb
Normal file
22
test/with_diffent_ofs.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
module DifferentOFS
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
@ofs, $, = $,, "-"
|
||||||
|
end
|
||||||
|
def teardown
|
||||||
|
$, = @ofs
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
mod = Module.new do
|
||||||
|
def with_diffrent_ofs
|
||||||
|
const_set(:DifferentOFS, Class.new(self).class_eval {include DifferentOFS}).name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class << self; self; end.class_eval do
|
||||||
|
define_method(:included) do |klass|
|
||||||
|
super(klass)
|
||||||
|
klass.extend(mod)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user