rfs 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +7 -0
- data/Rakefile.rb +193 -0
- data/bin/RenameFileSet.rbw +14 -0
- data/bin/rfs.rb +214 -0
- data/bin/rfsd.rb +8 -0
- data/description.txt +24 -0
- data/lib/RenameFileSet.bak.rb +372 -0
- data/lib/errors.rb +15 -0
- data/lib/filters.rb +68 -0
- data/lib/gui.rb +216 -0
- data/lib/innate/array.rb +104 -0
- data/lib/innate/coverage.rb +315 -0
- data/lib/innate/debug.rb +12 -0
- data/lib/innate/debugger.rb +944 -0
- data/lib/innate/file.rb +5 -0
- data/lib/innate/filelines.rb +148 -0
- data/lib/innate/kernel.rb +41 -0
- data/lib/innate/metaid.rb +30 -0
- data/lib/innate/mkdirs.rb +12 -0
- data/lib/innate/regexp.rb +80 -0
- data/lib/innate/reload.rb +11 -0
- data/lib/innate/roman.rb +72 -0
- data/lib/innate/scriptlines.rb +60 -0
- data/lib/innate/string.rb +56 -0
- data/lib/innate/test/all_tests.rb +11 -0
- data/lib/innate/test/files/mkdirs_dummy.file +1 -0
- data/lib/innate/test/files/reloadtarget.rb +5 -0
- data/lib/innate/test/files/reloadtarget1.rb +5 -0
- data/lib/innate/test/files/reloadtarget2.rb +5 -0
- data/lib/innate/test/test_coverage.rb +13 -0
- data/lib/innate/test/testarray.rb +98 -0
- data/lib/innate/test/testfile.rb +15 -0
- data/lib/innate/test/testfilelines.rb +106 -0
- data/lib/innate/test/testkernel.rb +30 -0
- data/lib/innate/test/testmkdirs.rb +19 -0
- data/lib/innate/test/testregexp.rb +86 -0
- data/lib/innate/test/testreload.rb +61 -0
- data/lib/innate/test/testroman.rb +54 -0
- data/lib/innate/test/testscriptlines.rb +39 -0
- data/lib/innate/test/teststring.rb +52 -0
- data/lib/innate/test/testtitlecase.rb +20 -0
- data/lib/innate/titlecase.rb +64 -0
- data/lib/innate/tracerequire.rb +22 -0
- data/lib/namesource.rb +53 -0
- data/lib/options.rb +64 -0
- data/lib/providers.rb +93 -0
- data/lib/regexp.rb +56 -0
- data/lib/rename_functions.rb +142 -0
- data/lib/renamer.rb +210 -0
- data/lib/results.rb +83 -0
- data/lib/test/test_helper.rb +147 -0
- data/tests/dir/file1 +0 -0
- data/tests/dir/file2 +0 -0
- data/tests/dir/file3 +0 -0
- data/tests/test_helper.rb +147 -0
- data/tests/test_rename_functions.rb +605 -0
- metadata +105 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
class String
|
2
|
+
def split_with_separator(pattern)
|
3
|
+
pos = 0
|
4
|
+
result = []
|
5
|
+
separator = nil
|
6
|
+
t = self
|
7
|
+
loop do
|
8
|
+
t = t[pos...length]
|
9
|
+
m = pattern.match(t)
|
10
|
+
unless m
|
11
|
+
return result << yield(separator, t) if block_given?
|
12
|
+
return result << [separator, t]
|
13
|
+
end
|
14
|
+
if block_given?
|
15
|
+
result << yield(separator, m.pre_match)
|
16
|
+
else
|
17
|
+
result << [separator, m.pre_match]
|
18
|
+
end
|
19
|
+
separator = m[0]
|
20
|
+
pos = m.offset(0).last
|
21
|
+
end
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
def starts_with?(*s)
|
26
|
+
s.flatten.each do |t|
|
27
|
+
return t if self[0...t.length].strip == t.strip
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def starts_with_i?(*s)
|
33
|
+
s.flatten.each do |t|
|
34
|
+
return t if self[0...t.length].upcase.strip == t.upcase.strip
|
35
|
+
end
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def prefix_to?(*s)
|
40
|
+
v = strip
|
41
|
+
return false if v.length == 0
|
42
|
+
s.flatten.each do |t|
|
43
|
+
return t if t[0...v.length].strip == v
|
44
|
+
end
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def prefix_to_i?(*s)
|
49
|
+
v = strip
|
50
|
+
return false if v.length == 0
|
51
|
+
s.flatten.each do |t|
|
52
|
+
return t if t[0...v.length].upcase.strip == v.upcase
|
53
|
+
end
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'testarray'
|
2
|
+
require 'testfile'
|
3
|
+
require 'testfilelines'
|
4
|
+
require 'testkernel'
|
5
|
+
require 'testmkdirs'
|
6
|
+
require 'testregexp'
|
7
|
+
require 'testreload'
|
8
|
+
require 'testroman'
|
9
|
+
require 'testscriptlines'
|
10
|
+
require 'teststring'
|
11
|
+
require 'testtitlecase'
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'innate/coverage'
|
2
|
+
require '../array'
|
3
|
+
require '../file'
|
4
|
+
require '../filelines'
|
5
|
+
require '../kernel'
|
6
|
+
require '../mkdirs'
|
7
|
+
require '../regexp'
|
8
|
+
require '../reload'
|
9
|
+
require '../roman'
|
10
|
+
require '../scriptlines'
|
11
|
+
require '../string'
|
12
|
+
require '../titlecase'
|
13
|
+
require 'all_tests'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'innate/array'
|
3
|
+
|
4
|
+
class TestArray < Test::Unit::TestCase
|
5
|
+
def test_match_string
|
6
|
+
assert ['hello', 'bye'].match?('bye')
|
7
|
+
assert ['something', 'aoeu'].match?('something')
|
8
|
+
assert_nil ['ueao', ';e', 'ueo'].match?('zzzzz')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_match_regexp
|
12
|
+
assert ['aoeu', /z/, /a/].match?('claw')
|
13
|
+
assert [/yes/, 'no', /no/].match?('yes')
|
14
|
+
assert [/yes/, 'no', /no/].match?('no')
|
15
|
+
assert_nil ['aoeu', /z/, /a/].match?('xxxx')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_rows
|
19
|
+
a = %w{ % & * ** + +@
|
20
|
+
- -@ / < << <=
|
21
|
+
<=> == === =~ > >=
|
22
|
+
>> [] ^ __id__ __send__ abs
|
23
|
+
between? ceil chr class clone coerce
|
24
|
+
denominator display div divmod downto dup
|
25
|
+
eql? equal? extend floor freeze frozen?
|
26
|
+
gcd gcd2 gcdlcm hash id id2name
|
27
|
+
inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables
|
28
|
+
integer? is_a? kind_of? lcm method methods
|
29
|
+
modulo next nil? nonzero? numerator object_id
|
30
|
+
power! prec prec_f prec_i private_methods protected_methods
|
31
|
+
public_methods quo rdiv remainder require require_gem
|
32
|
+
require_gem_with_options respond_to? round rpower send singleton_method_added
|
33
|
+
singleton_methods size step succ taint tainted?
|
34
|
+
times to_a to_bn to_f to_i to_int
|
35
|
+
to_r to_s to_sym truncate type untaint
|
36
|
+
upto zero? | ~}
|
37
|
+
|
38
|
+
s = "% & * ** + +@ \n" +
|
39
|
+
"- -@ / < << <= \n" +
|
40
|
+
"<=> == === =~ > >= \n" +
|
41
|
+
">> [] ^ __id__ __send__ abs \n" +
|
42
|
+
"between? ceil chr class clone coerce \n" +
|
43
|
+
"denominator display div divmod downto dup \n" +
|
44
|
+
"eql? equal? extend floor freeze frozen? \n" +
|
45
|
+
"gcd gcd2 gcdlcm hash id id2name \n" +
|
46
|
+
"inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables \n" +
|
47
|
+
"integer? is_a? kind_of? lcm method methods \n" +
|
48
|
+
"modulo next nil? nonzero? numerator object_id \n" +
|
49
|
+
"power! prec prec_f prec_i private_methods protected_methods \n" +
|
50
|
+
"public_methods quo rdiv remainder require require_gem \n" +
|
51
|
+
"require_gem_with_options respond_to? round rpower send singleton_method_added\n" +
|
52
|
+
"singleton_methods size step succ taint tainted? \n" +
|
53
|
+
"times to_a to_bn to_f to_i to_int \n" +
|
54
|
+
"to_r to_s to_sym truncate type untaint \n" +
|
55
|
+
"upto zero? | ~ "
|
56
|
+
|
57
|
+
assert_equal s, a.rows(130, 2, ' ')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_columns
|
61
|
+
a = %w{ % & * ** + +@
|
62
|
+
- -@ / < << <=
|
63
|
+
<=> == === =~ > >=
|
64
|
+
>> [] ^ __id__ __send__ abs
|
65
|
+
between? ceil chr class clone coerce
|
66
|
+
denominator display div divmod downto dup
|
67
|
+
eql? equal? extend floor freeze frozen?
|
68
|
+
gcd gcd2 gcdlcm hash id id2name
|
69
|
+
inspect instance_eval instance_of? instance_variable_get instance_variable_set instance_variables
|
70
|
+
integer? is_a? kind_of? lcm method methods
|
71
|
+
modulo next nil? nonzero? numerator object_id
|
72
|
+
power! prec prec_f prec_i private_methods protected_methods
|
73
|
+
public_methods quo rdiv remainder require require_gem
|
74
|
+
require_gem_with_options respond_to? round rpower send singleton_method_added
|
75
|
+
singleton_methods size step succ taint tainted?
|
76
|
+
times to_a to_bn to_f to_i to_int
|
77
|
+
to_r to_s to_sym truncate type untaint
|
78
|
+
upto zero? | ~}
|
79
|
+
|
80
|
+
s = "% === clone gcd kind_of? private_methods singleton_methods to_sym \n" +
|
81
|
+
"& =~ coerce gcd2 lcm protected_methods size truncate\n" +
|
82
|
+
"* > denominator gcdlcm method public_methods step type \n" +
|
83
|
+
"** >= display hash methods quo succ untaint \n" +
|
84
|
+
"+ >> div id modulo rdiv taint upto \n" +
|
85
|
+
"+@ [] divmod id2name next remainder tainted? zero? \n" +
|
86
|
+
"- ^ downto inspect nil? require times | \n" +
|
87
|
+
"-@ __id__ dup instance_eval nonzero? require_gem to_a ~ \n" +
|
88
|
+
"/ __send__ eql? instance_of? numerator require_gem_with_options to_bn \n" +
|
89
|
+
"< abs equal? instance_variable_get object_id respond_to? to_f \n" +
|
90
|
+
"<< between? extend instance_variable_set power! round to_i \n" +
|
91
|
+
"<= ceil floor instance_variables prec rpower to_int \n" +
|
92
|
+
"<=> chr freeze integer? prec_f send to_r \n" +
|
93
|
+
"== class frozen? is_a? prec_i singleton_method_added to_s "
|
94
|
+
|
95
|
+
assert_equal s, a.columns(130, 2, ' ')
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'innate/file'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestFile < Test::Unit::TestCase
|
5
|
+
def test_absolute_path?
|
6
|
+
assert_equal './hello', File.absolute_path?('./hello')
|
7
|
+
assert_equal 'F:/som/eo/the/r/path.abc', File.absolute_path?('F:/som/eo/the/r/path.abc')
|
8
|
+
assert_equal 'f:/som/eo/the/r/path.abc', File.absolute_path?('f:/som/eo/the/r/path.abc')
|
9
|
+
assert_equal '../some path/here/../or/./there.rb', File.absolute_path?('../some path/here/../or/./there.rb')
|
10
|
+
assert_equal '/some path/here/../or/./there.rb', File.absolute_path?('/some path/here/../or/./there.rb')
|
11
|
+
assert_nil File.absolute_path?('some path/here/../or/./there.rb')
|
12
|
+
assert_nil File.absolute_path?('somefile')
|
13
|
+
assert_nil File.absolute_path?('someruby.rb')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# this first line is here for testing.
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'cursor/indexed'
|
5
|
+
require 'innate/filelines'
|
6
|
+
|
7
|
+
class TestFileLines < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@file = File.open __FILE__
|
10
|
+
@fl = FileLines.new __FILE__
|
11
|
+
@first = "# this first line is here for testing.\n"
|
12
|
+
@last = "# this last line is here for testing."
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@file.close
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_each
|
20
|
+
@fl.each do |l|
|
21
|
+
assert_equal @file.readline, l
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_range
|
26
|
+
assert_equal @file.readlines[5...15], @fl[5...15]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_index
|
30
|
+
assert_equal @file.readlines[17], @fl[17]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_values_at
|
34
|
+
assert_equal @file.readlines.values_at(0..7, 9, 20...60), @fl.values_at(0..7, 9, 20...60)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_values_at2
|
38
|
+
assert_equal @file.readlines.values_at(0..7, 9, 20...-60), @fl.values_at(0..7, 9, 20...-60)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_enumerable
|
42
|
+
a = @file.readlines.reverse.to_cursor
|
43
|
+
@fl.reverse_each do |l|
|
44
|
+
assert_equal a.read1next, l
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_length
|
49
|
+
assert_equal @file.readlines.length, @fl.length
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_size
|
53
|
+
assert_equal @file.readlines.length, @fl.size
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_known_lines
|
57
|
+
assert_equal @first, @fl[0]
|
58
|
+
assert_equal @last, @fl[@fl.length - 1]
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_old_at
|
62
|
+
assert_nil @fl.at_before_file_lines(0)
|
63
|
+
# init on first use:
|
64
|
+
@fl.length
|
65
|
+
assert_equal 0, @fl.at_before_file_lines(0)
|
66
|
+
test_known_lines
|
67
|
+
assert_kind_of String, @fl.at_before_file_lines(0)
|
68
|
+
assert_kind_of Fixnum, @fl.at_before_file_lines(1)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_neg_index
|
72
|
+
assert_equal @file.readlines, @fl[0..-1]
|
73
|
+
@file.rewind
|
74
|
+
assert_equal @file.readlines[40..-10], @fl[40..-10]
|
75
|
+
@file.rewind
|
76
|
+
assert_equal @file.readlines[50...-17], @fl[50...-17]
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_neg_index2
|
80
|
+
assert_equal @file.readlines[50...-17], @fl[50...-17]
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_neg_int_index
|
84
|
+
assert_equal @file.readlines.last, @fl[-1]
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_neg_first_index
|
88
|
+
assert_equal @file.readlines[-10..-1], @fl[-10..-1]
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_first
|
92
|
+
assert_equal @first, @fl.first
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_last
|
96
|
+
assert_equal @last, @fl.last
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_collect
|
100
|
+
assert_equal @file.readlines, @fl.collect
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# no line break after next line please:
|
106
|
+
# this last line is here for testing.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'innate/kernel'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'cursor/indexed'
|
4
|
+
|
5
|
+
class TestKernel < Test::Unit::TestCase
|
6
|
+
def test_find_in_path
|
7
|
+
#this assumes that the lib exists in ..../site_ruby/innate/kernel.rb
|
8
|
+
assert_equal File.expand_path('../kernel.rb').downcase, find_in_path('innate/kernel').downcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_each_loaded_file
|
12
|
+
c = $".to_cursor
|
13
|
+
each_loaded_file do |f|
|
14
|
+
assert_match Regexp.new(Regexp.escape(c.read1next)), f
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_each_caller
|
19
|
+
c = -1
|
20
|
+
each_caller do |file, line, method| # <- the below test wants the line number of this line
|
21
|
+
c += 1
|
22
|
+
if c == 0
|
23
|
+
assert_equal File.expand_path(__FILE__), File.expand_path(file)
|
24
|
+
assert_equal 20, line
|
25
|
+
assert_equal 'test_each_caller', method
|
26
|
+
end
|
27
|
+
end
|
28
|
+
assert_equal c, caller.length
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'innate/mkdirs'
|
3
|
+
|
4
|
+
class TestMkdirs < Test::Unit::TestCase
|
5
|
+
def test_mkdirs
|
6
|
+
assert File.mkdirs('.')
|
7
|
+
assert !File.mkdirs('files/mkdirs_dummy.file')
|
8
|
+
begin
|
9
|
+
assert File.mkdirs('files/fa/ke/direct/ory')
|
10
|
+
assert File.directory?('files/fa/ke/direct/ory')
|
11
|
+
ensure
|
12
|
+
Dir.delete 'files/fa/ke/direct/ory'
|
13
|
+
Dir.delete 'files/fa/ke/direct'
|
14
|
+
Dir.delete 'files/fa/ke'
|
15
|
+
Dir.delete 'files/fa'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'innate/regexp'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'innate/roman'
|
4
|
+
|
5
|
+
class TestMatchData < Test::Unit::TestCase
|
6
|
+
def test_display
|
7
|
+
assert_equal '(hello)', /hello/.match('hello').display
|
8
|
+
assert_equal '(the(next)word)', /the(next)word/.match('thenextword').display
|
9
|
+
assert_equal 'the(next)word', /next/.match('thenextword').display
|
10
|
+
assert_equal 'the ((3)rd) wave', /(\d)../.match('the 3rd wave').display
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_display_nested
|
14
|
+
assert_equal 'the(( )(ne)(xt) ((le)(ve)l))!', /( )(..)(..) ((le)(..).)/.match('the next level!').display
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_display_levels
|
18
|
+
assert_equal 'the (ne)(xt) ((le)(ve)l)!', /( )(..)(..) ((le)(..).)/.match('the next level!').display(2)
|
19
|
+
assert_equal 'the (ne)(xt) ((le)vel)!', /( )(..)(..) ((le)(..).)/.match('the next level!').display(2, 6)
|
20
|
+
assert_equal 'the next (level)!', /( )(..)(..) ((le)(..).)/.match('the next level!').display(4, 5)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_display_other_delim
|
24
|
+
assert_equal 'the->-> <-->ne<-->xt<- ->->le<-->ve<-l<-<-!', /( )(..)(..) ((le)(..).)/.match('the next level!').display(0, nil, '->', '<-')
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_display_problem
|
28
|
+
r = /^\(\?([imx]*)(-[imx]+)?:(.*?)#{Regexp.escape 'etc'}(.*)\)$/
|
29
|
+
m = r.match(/"etc"/mix.to_s)
|
30
|
+
assert_equal '((?(mix):(")etc(")))', m.display
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_replace_capture
|
35
|
+
assert_equal 'a new word', /a(n old) word/.match('an old word').replace_capture(1, ' new')
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_sub
|
39
|
+
assert_equal 'a new word', /a(n old) word/.match('an old word').sub(' new')
|
40
|
+
assert_equal 'a new word', /n old/.match('an old word').sub(' new')
|
41
|
+
assert_equal 'a new word', /(?:a)(n ((o)l)d) word/.match('an old word').sub(' new')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_sub_nil
|
45
|
+
assert_equal 'a new word', /a(n old) word/.match('an old word').sub(' new', nil)
|
46
|
+
assert_equal 'a new word', /n old/.match('an old word').sub(' new', nil)
|
47
|
+
assert_equal 'a new word', /(?:a)(n ((o)l)d) word/.match('an old word').sub(' new', nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_sub_other
|
51
|
+
assert_equal 'a new word', /a(n old) word/.match('an old word').sub(' new', 1)
|
52
|
+
assert_equal 'a new word', /n (o)ld/.match('an old word').sub(' new', 0)
|
53
|
+
assert_equal 'a new word', /n (o)ld/.match('an old word').sub(' new', 10)
|
54
|
+
assert_equal 'a new word', /n old/.match('an old word').sub(' new', 10)
|
55
|
+
assert_equal 'an newd word', /(?:a)(n ((o)l)d) word/.match('an old word').sub(' new', 2)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class TestRegexp < Test::Unit::TestCase
|
60
|
+
def test_interpolate
|
61
|
+
assert_equal '(?-mix:roman)', /roman/.to_s
|
62
|
+
assert_equal '(?-mix:this is real [R][om][an] (N)(?>um)()eralce)', /this is real romance/.interpolate('roman', '[R][om][an] (N)(?>um)()eral').to_s
|
63
|
+
assert_equal '(?m-ix:"etcetera")', /"etc"/m.interpolate('etc', 'etcetera').to_s
|
64
|
+
assert_equal '(?i-mx:"etcetera")', /"etc"/i.interpolate('etc', 'etcetera').to_s
|
65
|
+
assert_equal '(?x-mi:"etcetera")', /"etc"/x.interpolate('etc', 'etcetera').to_s
|
66
|
+
assert_equal '(?mi-x:"etcetera")', /"etc"/mi.interpolate('etc', 'etcetera').to_s
|
67
|
+
assert_equal '(?mx-i:"etcetera")', /"etc"/mx.interpolate('etc', 'etcetera').to_s
|
68
|
+
assert_equal '(?ix-m:"etcetera")', /"etc"/ix.interpolate('etc', 'etcetera').to_s
|
69
|
+
assert_equal '(?mix:"etcetera")', /"etc"/mix.interpolate('etc', 'etcetera').to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_interpolate_none
|
73
|
+
assert_equal '(?-mix:yahoo)', /yahoo/.interpolate('cowboy', 'codfish').to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_breakdown
|
77
|
+
assert_equal ['book '], /book/.match('bookmark').breakdown
|
78
|
+
assert_equal ['book ', ' k '], /boo(k)/.match('bookmark').breakdown
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_display_breakdown
|
82
|
+
assert_equal "S: |bookmark|\n0: |book |\n1: | k |",
|
83
|
+
/boo(k)/.match('bookmark').display_breakdown
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|