You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.5 KiB
137 lines
4.5 KiB
9 years ago
|
From 7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
||
|
Date: Mon, 4 Jul 2016 13:11:44 +0200
|
||
|
Subject: [PATCH 1/2] DRY Downloader.
|
||
|
|
||
|
---
|
||
|
activesupport/test/multibyte_conformance_test.rb | 18 ------------------
|
||
|
.../test/multibyte_grapheme_break_conformance_test.rb | 19 ++-----------------
|
||
|
.../test/multibyte_normalization_conformance_test.rb | 18 ------------------
|
||
|
activesupport/test/multibyte_test_helpers.rb | 18 ++++++++++++++++++
|
||
|
4 files changed, 20 insertions(+), 53 deletions(-)
|
||
|
|
||
|
diff --git a/activesupport/test/multibyte_conformance_test.rb b/activesupport/test/multibyte_conformance_test.rb
|
||
|
index 9fca47a..709c63a 100644
|
||
|
--- a/activesupport/test/multibyte_conformance_test.rb
|
||
|
+++ b/activesupport/test/multibyte_conformance_test.rb
|
||
|
@@ -6,24 +6,6 @@
|
||
|
require 'tmpdir'
|
||
|
|
||
|
class MultibyteConformanceTest < ActiveSupport::TestCase
|
||
|
- class Downloader
|
||
|
- def self.download(from, to)
|
||
|
- unless File.exist?(to)
|
||
|
- unless File.exist?(File.dirname(to))
|
||
|
- system "mkdir -p #{File.dirname(to)}"
|
||
|
- end
|
||
|
- open(from) do |source|
|
||
|
- File.open(to, 'w') do |target|
|
||
|
- source.each_line do |l|
|
||
|
- target.write l
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- true
|
||
|
- end
|
||
|
- end
|
||
|
-
|
||
|
include MultibyteTestHelpers
|
||
|
|
||
|
UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd"
|
||
|
diff --git a/activesupport/test/multibyte_grapheme_break_conformance_test.rb b/activesupport/test/multibyte_grapheme_break_conformance_test.rb
|
||
|
index 6e2f02a..45e1976 100644
|
||
|
--- a/activesupport/test/multibyte_grapheme_break_conformance_test.rb
|
||
|
+++ b/activesupport/test/multibyte_grapheme_break_conformance_test.rb
|
||
|
@@ -1,29 +1,14 @@
|
||
|
# encoding: utf-8
|
||
|
|
||
|
require 'abstract_unit'
|
||
|
+require 'multibyte_test_helpers'
|
||
|
|
||
|
require 'fileutils'
|
||
|
require 'open-uri'
|
||
|
require 'tmpdir'
|
||
|
|
||
|
class MultibyteGraphemeBreakConformanceTest < ActiveSupport::TestCase
|
||
|
- class Downloader
|
||
|
- def self.download(from, to)
|
||
|
- unless File.exist?(to)
|
||
|
- $stderr.puts "Downloading #{from} to #{to}"
|
||
|
- unless File.exist?(File.dirname(to))
|
||
|
- system "mkdir -p #{File.dirname(to)}"
|
||
|
- end
|
||
|
- open(from) do |source|
|
||
|
- File.open(to, 'w') do |target|
|
||
|
- source.each_line do |l|
|
||
|
- target.write l
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
+ include MultibyteTestHelpers
|
||
|
|
||
|
TEST_DATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd/auxiliary"
|
||
|
TEST_DATA_FILE = '/GraphemeBreakTest.txt'
|
||
|
diff --git a/activesupport/test/multibyte_normalization_conformance_test.rb b/activesupport/test/multibyte_normalization_conformance_test.rb
|
||
|
index 0d31c95..ad2e651 100644
|
||
|
--- a/activesupport/test/multibyte_normalization_conformance_test.rb
|
||
|
+++ b/activesupport/test/multibyte_normalization_conformance_test.rb
|
||
|
@@ -8,24 +8,6 @@
|
||
|
require 'tmpdir'
|
||
|
|
||
|
class MultibyteNormalizationConformanceTest < ActiveSupport::TestCase
|
||
|
- class Downloader
|
||
|
- def self.download(from, to)
|
||
|
- unless File.exist?(to)
|
||
|
- $stderr.puts "Downloading #{from} to #{to}"
|
||
|
- unless File.exist?(File.dirname(to))
|
||
|
- system "mkdir -p #{File.dirname(to)}"
|
||
|
- end
|
||
|
- open(from) do |source|
|
||
|
- File.open(to, 'w') do |target|
|
||
|
- source.each_line do |l|
|
||
|
- target.write l
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
- end
|
||
|
-
|
||
|
include MultibyteTestHelpers
|
||
|
|
||
|
UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd"
|
||
|
diff --git a/activesupport/test/multibyte_test_helpers.rb b/activesupport/test/multibyte_test_helpers.rb
|
||
|
index 58cf548..709586e 100644
|
||
|
--- a/activesupport/test/multibyte_test_helpers.rb
|
||
|
+++ b/activesupport/test/multibyte_test_helpers.rb
|
||
|
@@ -1,4 +1,22 @@
|
||
|
module MultibyteTestHelpers
|
||
|
+ class Downloader
|
||
|
+ def self.download(from, to)
|
||
|
+ unless File.exist?(to)
|
||
|
+ unless File.exist?(File.dirname(to))
|
||
|
+ system "mkdir -p #{File.dirname(to)}"
|
||
|
+ end
|
||
|
+ open(from) do |source|
|
||
|
+ File.open(to, 'w') do |target|
|
||
|
+ source.each_line do |l|
|
||
|
+ target.write l
|
||
|
+ end
|
||
|
+ end
|
||
|
+ end
|
||
|
+ end
|
||
|
+ true
|
||
|
+ end
|
||
|
+ end
|
||
|
+
|
||
|
UNICODE_STRING = 'こにちわ'.freeze
|
||
|
ASCII_STRING = 'ohayo'.freeze
|
||
|
BYTE_STRING = "\270\236\010\210\245".force_encoding("ASCII-8BIT").freeze
|
||
|
--
|
||
|
2.9.0
|
||
|
|