ruby-changes:3976
From: ko1@a...
Date: Thu, 14 Feb 2008 14:03:28 +0900 (JST)
Subject: [ruby-changes:3976] akr - Ruby:r15466 (trunk): more tests for embedding regexps.
akr 2008-02-14 14:03:07 +0900 (Thu, 14 Feb 2008) New Revision: 15466 Modified files: trunk/test/ruby/test_m17n.rb Log: more tests for embedding regexps. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_m17n.rb?r1=15466&r2=15465&diff_format=u Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 15465) +++ test/ruby/test_m17n.rb (revision 15466) @@ -450,6 +450,42 @@ r = /\xc2\xa1/e assert_raise(ArgumentError) { /\xc2\xa1#{r}/s } + + r1 = Regexp.new('foo'.force_encoding("ascii-8bit")) + r2 = eval('/bar#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::US_ASCII, r2.encoding) + + r1 = Regexp.new('foo'.force_encoding("us-ascii")) + r2 = eval('/bar#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::US_ASCII, r2.encoding) + + r1 = Regexp.new('foo'.force_encoding("ascii-8bit")) + r2 = eval('/bar#{r1}/'.force_encoding('us-ascii')) + assert_equal(Encoding::US_ASCII, r2.encoding) + + r1 = Regexp.new('foo'.force_encoding("us-ascii")) + r2 = eval('/bar#{r1}/'.force_encoding('us-ascii')) + assert_equal(Encoding::US_ASCII, r2.encoding) + + r1 = Regexp.new('\xa1'.force_encoding("ascii-8bit")) + r2 = eval('/bar#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::ASCII_8BIT, r2.encoding) + + r1 = Regexp.new('\xa1'.force_encoding("ascii-8bit")) + r2 = eval('/bar#{r1}/'.force_encoding('us-ascii')) + assert_equal(Encoding::ASCII_8BIT, r2.encoding) + + r1 = Regexp.new('foo'.force_encoding("ascii-8bit")) + r2 = eval('/\xa1#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::ASCII_8BIT, r2.encoding) + + r1 = Regexp.new('foo'.force_encoding("us-ascii")) + r2 = eval('/\xa1#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::ASCII_8BIT, r2.encoding) + + r1 = Regexp.new('\xa1'.force_encoding("ascii-8bit")) + r2 = eval('/\xa1#{r1}/'.force_encoding('ascii-8bit')) + assert_equal(Encoding::ASCII_8BIT, r2.encoding) end def test_regexp_embed_preprocess -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/