[前][次][番号順一覧][スレッド一覧]

ruby-changes:43404

From: naruse <ko1@a...>
Date: Tue, 21 Jun 2016 16:14:09 +0900 (JST)
Subject: [ruby-changes:43404] naruse:r55478 (trunk): It takes still too many memory...

naruse	2016-06-21 16:14:03 +0900 (Tue, 21 Jun 2016)

  New Revision: 55478

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55478

  Log:
    It takes still too many memory...
    
    /usr/bin/time -l make RUBYOPT=-w TESTS='-v ruby/enc/test_case_comprehensive.rb' test-all
    ruby -v: ruby 2.4.0dev (2016-06-21 trunk 55473) [x86_64-freebsd10.3]
           27.74 real        27.57 user         0.16 sys
        115308  maximum resident set size
             5  average shared memory size
             4  average unshared data size
           128  average unshared stack size
         28443  page reclaims
             0  page faults
             0  swaps
             2  block input operations
             0  block output operations
             0  messages sent
             0  messages received
             0  signals received
            93  voluntary context switches
          1123  involuntary context switches

  Modified files:
    trunk/test/ruby/enc/test_case_comprehensive.rb
Index: test/ruby/enc/test_case_comprehensive.rb
===================================================================
--- test/ruby/enc/test_case_comprehensive.rb	(revision 55477)
+++ test/ruby/enc/test_case_comprehensive.rb	(revision 55478)
@@ -1,3 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L1
+# frozen_string_literal: true
 # Copyright 息 2016 Martin J. D端rst (duerst@i...)
 
 require "test/unit"
@@ -36,7 +37,7 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L37
       end
       next if /\A(?:[\#@]|\s*\z)|Surrogate/.match?(line)
       data = line.chomp.split('#')[0].split(/;\s*/, 15)
-      code = data[0].to_i(16).chr('UTF-8')
+      code = data[0].to_i(16).chr(Encoding::UTF_8)
       yield code, data
     end
   end
@@ -130,6 +131,22 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L131
     @@tests ||= []
   end
 
+  def self.generate_unicode_case_mapping_tests (encoding)
+    all_tests.each do |test|
+      attributes = test.attributes.map(&:to_s).join '-'
+      attributes.prepend '_' unless attributes.empty?
+      define_method "test_#{encoding}_#{test.method_name}#{attributes}" do
+        @@codepoints.each do |code|
+          source = code.encode(encoding) * 5
+          target = "#{test.first_data[code]}#{test.follow_data[code]*4}".encode(encoding)
+          result = source.__send__(test.method_name, *test.attributes)
+          assert_equal target, target,
+            proc{"from #{code*5} (#{source.dump}) expected #{target.dump} but was #{result.dump}"}
+        end
+      end
+    end
+  end
+
   def self.generate_case_mapping_tests (encoding)
     all_tests
     # preselect codepoints to speed up testing for small encodings
@@ -261,13 +278,13 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L278
   generate_case_mapping_tests 'ISO-8859-1'
   generate_case_mapping_tests 'US-ASCII'
   generate_case_mapping_tests 'ASCII-8BIT'
-  generate_case_mapping_tests 'UTF-8'
-  generate_case_mapping_tests 'UTF-16BE'
-  generate_case_mapping_tests 'UTF-16LE'
-  generate_case_mapping_tests 'UTF-32BE'
-  generate_case_mapping_tests 'UTF-32LE'
   generate_case_mapping_tests 'ISO-8859-11'
   generate_case_mapping_tests 'ISO-8859-8'
   generate_case_mapping_tests 'ISO-8859-6'
   generate_case_mapping_tests 'Windows-1255'
+  generate_unicode_case_mapping_tests 'UTF-8'
+  generate_unicode_case_mapping_tests 'UTF-16BE'
+  generate_unicode_case_mapping_tests 'UTF-16LE'
+  generate_unicode_case_mapping_tests 'UTF-32BE'
+  generate_unicode_case_mapping_tests 'UTF-32LE'
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]