tbpgr_utils 0.0.116 → 0.0.117
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +51 -0
- data/README.md +13 -1
- data/Rakefile +8 -8
- data/lib/attributes_initializable.rb +3 -3
- data/lib/eval_helper/attr_init_class_code.rb +1 -1
- data/lib/eval_helper/times_code.rb +2 -2
- data/lib/markdown/heading.rb +32 -32
- data/lib/open_classes/array/kernel_send.rb +15 -0
- data/lib/open_classes/array/to_table.rb +1 -1
- data/lib/open_classes/array.rb +1 -0
- data/lib/open_classes/kernel/aa_ancestors.rb +16 -16
- data/lib/open_classes/kernel/p_evals.rb +42 -42
- data/lib/open_classes/string/heading_helper.rb +1 -1
- data/lib/open_classes/string/stripe.rb +1 -1
- data/lib/open_classes/string/to_hatena_heading.rb +35 -35
- data/lib/open_classes/string/to_markdown_heading.rb +37 -37
- data/lib/open_classes/string/to_space2_heading.rb +35 -35
- data/lib/open_classes/string/to_space4_heading.rb +35 -35
- data/lib/open_classes/string/to_tab_heading.rb +35 -35
- data/lib/simple_tournament.rb +57 -57
- data/lib/tbpgr_utils/version.rb +1 -1
- data/rubocop-todo.yml +33 -33
- data/spec/markdown/heading_spec.rb +4 -4
- data/spec/markdown/ol_spec.rb +1 -1
- data/spec/markdown/ul_spec.rb +1 -1
- data/spec/open_classes/array/kernel_send_spec.rb +43 -0
- data/spec/open_classes/array/together_at_spec.rb +61 -61
- data/spec/open_classes/array/together_clear_spec.rb +51 -51
- data/spec/open_classes/array/together_concat_spec.rb +53 -53
- data/spec/open_classes/array/together_delete_at_spec.rb +78 -78
- data/spec/open_classes/array/together_delete_if_spec.rb +61 -61
- data/spec/open_classes/array/together_delete_spec.rb +80 -80
- data/spec/open_classes/array/together_fill_spec.rb +79 -79
- data/spec/open_classes/array/together_map_spec.rb +171 -171
- data/spec/open_classes/array/together_spec.rb +51 -51
- data/spec/open_classes/array/together_with_index_spec.rb +51 -51
- data/spec/open_classes/object/any_of_spec.rb +72 -72
- data/spec/set_variables_code_spec.rb +2 -1
- data/tbpgr_utils.gemspec +27 -27
- metadata +41 -26
@@ -1,35 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'active_support/core_ext/object/inclusion'
|
3
|
-
require 'open_classes/string/heading_helper'
|
4
|
-
|
5
|
-
class String
|
6
|
-
include HeadingHelper
|
7
|
-
# Space4
|
8
|
-
SPACE4 = ' '
|
9
|
-
|
10
|
-
# create heading string with Emmet-like syntax.
|
11
|
-
#
|
12
|
-
# ==== Examples
|
13
|
-
#
|
14
|
-
# > case
|
15
|
-
#
|
16
|
-
# 'hoge>hige'.to_space4_heading # => 'hoge\n hige'
|
17
|
-
#
|
18
|
-
# + case
|
19
|
-
#
|
20
|
-
# 'hoge+hige'.to_space4_heading # => 'hoge\nhige'
|
21
|
-
#
|
22
|
-
# ^ case
|
23
|
-
#
|
24
|
-
# 'hoge>hige^hege'.to_space4_heading # => 'hoge\n hige\nhege'
|
25
|
-
#
|
26
|
-
def to_space4_heading
|
27
|
-
heading = to_heading
|
28
|
-
to_space4 heading
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/core_ext/object/inclusion'
|
3
|
+
require 'open_classes/string/heading_helper'
|
4
|
+
|
5
|
+
class String
|
6
|
+
include HeadingHelper
|
7
|
+
# Space4
|
8
|
+
SPACE4 = ' '
|
9
|
+
|
10
|
+
# create heading string with Emmet-like syntax.
|
11
|
+
#
|
12
|
+
# ==== Examples
|
13
|
+
#
|
14
|
+
# > case
|
15
|
+
#
|
16
|
+
# 'hoge>hige'.to_space4_heading # => 'hoge\n hige'
|
17
|
+
#
|
18
|
+
# + case
|
19
|
+
#
|
20
|
+
# 'hoge+hige'.to_space4_heading # => 'hoge\nhige'
|
21
|
+
#
|
22
|
+
# ^ case
|
23
|
+
#
|
24
|
+
# 'hoge>hige^hege'.to_space4_heading # => 'hoge\n hige\nhege'
|
25
|
+
#
|
26
|
+
def to_space4_heading
|
27
|
+
heading = to_heading
|
28
|
+
to_space4 heading
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def to_space4(heading)
|
33
|
+
to_head(heading, SPACE4)
|
34
|
+
end
|
35
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'active_support/core_ext/object/inclusion'
|
3
|
-
require 'open_classes/string/heading_helper'
|
4
|
-
|
5
|
-
class String
|
6
|
-
include HeadingHelper
|
7
|
-
# Tab
|
8
|
-
TAB = "\t"
|
9
|
-
|
10
|
-
# create heading string with Emmet-like syntax.
|
11
|
-
#
|
12
|
-
# ==== Examples
|
13
|
-
#
|
14
|
-
# > case
|
15
|
-
#
|
16
|
-
# 'hoge>hige'.to_tab_heading # => 'hoge\n\thige'
|
17
|
-
#
|
18
|
-
# + case
|
19
|
-
#
|
20
|
-
# 'hoge+hige'.to_tab_heading # => 'hoge\nhige'
|
21
|
-
#
|
22
|
-
# ^ case
|
23
|
-
#
|
24
|
-
# 'hoge>hige^hege'.to_tab_heading # => 'hoge\n\thige\nhege'
|
25
|
-
#
|
26
|
-
def to_tab_heading
|
27
|
-
heading = to_heading
|
28
|
-
to_tab heading
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'active_support/core_ext/object/inclusion'
|
3
|
+
require 'open_classes/string/heading_helper'
|
4
|
+
|
5
|
+
class String
|
6
|
+
include HeadingHelper
|
7
|
+
# Tab
|
8
|
+
TAB = "\t"
|
9
|
+
|
10
|
+
# create heading string with Emmet-like syntax.
|
11
|
+
#
|
12
|
+
# ==== Examples
|
13
|
+
#
|
14
|
+
# > case
|
15
|
+
#
|
16
|
+
# 'hoge>hige'.to_tab_heading # => 'hoge\n\thige'
|
17
|
+
#
|
18
|
+
# + case
|
19
|
+
#
|
20
|
+
# 'hoge+hige'.to_tab_heading # => 'hoge\nhige'
|
21
|
+
#
|
22
|
+
# ^ case
|
23
|
+
#
|
24
|
+
# 'hoge>hige^hege'.to_tab_heading # => 'hoge\n\thige\nhege'
|
25
|
+
#
|
26
|
+
def to_tab_heading
|
27
|
+
heading = to_heading
|
28
|
+
to_tab heading
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def to_tab(heading)
|
33
|
+
to_head(heading, TAB)
|
34
|
+
end
|
35
|
+
end
|
data/lib/simple_tournament.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# SimpleTournament
|
4
|
-
class SimpleTournament
|
5
|
-
attr_reader :tournament, :number, :matches
|
6
|
-
|
7
|
-
# initialize tournament by number
|
8
|
-
def initialize(number)
|
9
|
-
@number = number
|
10
|
-
@matches = []
|
11
|
-
cnt = 0
|
12
|
-
@tournament = []
|
13
|
-
while number >= (2**cnt)
|
14
|
-
tournament << Array.new(2**cnt)
|
15
|
-
cnt += 1
|
16
|
-
end
|
17
|
-
diff = number - (2**(cnt - 1))
|
18
|
-
@tournament << Array.new(diff * 2) unless (diff == 0)
|
19
|
-
end
|
20
|
-
|
21
|
-
# apply challengers to tournament
|
22
|
-
def apply_challengers(challengers)
|
23
|
-
fail 'incorrect challengers size. challengers must equals tournament.size' unless challengers.size == @number
|
24
|
-
@tournament.reverse_each do |outer|
|
25
|
-
outer.each_with_index do |v, i|
|
26
|
-
poped = challengers.pop
|
27
|
-
return @tournament if poped.nil?
|
28
|
-
outer[i] = poped
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# start tournament match. set result to tournament, matches
|
34
|
-
def start_match(proc)
|
35
|
-
@tournament.reverse_each.with_index do |outer, outer_index|
|
36
|
-
outer.reverse_each.with_index do |inner, inner_index|
|
37
|
-
next if inner_index.odd?
|
38
|
-
next if inner_index == outer.size - 1
|
39
|
-
rets = proc.call outer[-(inner_index + 1)], outer[-(inner_index + 2)], outer_index
|
40
|
-
winner = rets.first
|
41
|
-
@matches << rets.last
|
42
|
-
set_winner(winner, outer_index)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# SimpleTournament
|
4
|
+
class SimpleTournament
|
5
|
+
attr_reader :tournament, :number, :matches
|
6
|
+
|
7
|
+
# initialize tournament by number
|
8
|
+
def initialize(number)
|
9
|
+
@number = number
|
10
|
+
@matches = []
|
11
|
+
cnt = 0
|
12
|
+
@tournament = []
|
13
|
+
while number >= (2**cnt)
|
14
|
+
tournament << Array.new(2**cnt)
|
15
|
+
cnt += 1
|
16
|
+
end
|
17
|
+
diff = number - (2**(cnt - 1))
|
18
|
+
@tournament << Array.new(diff * 2) unless (diff == 0)
|
19
|
+
end
|
20
|
+
|
21
|
+
# apply challengers to tournament
|
22
|
+
def apply_challengers(challengers)
|
23
|
+
fail 'incorrect challengers size. challengers must equals tournament.size' unless challengers.size == @number
|
24
|
+
@tournament.reverse_each do |outer|
|
25
|
+
outer.each_with_index do |v, i|
|
26
|
+
poped = challengers.pop
|
27
|
+
return @tournament if poped.nil?
|
28
|
+
outer[i] = poped
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# start tournament match. set result to tournament, matches
|
34
|
+
def start_match(proc)
|
35
|
+
@tournament.reverse_each.with_index do |outer, outer_index|
|
36
|
+
outer.reverse_each.with_index do |inner, inner_index|
|
37
|
+
next if inner_index.odd?
|
38
|
+
next if inner_index == outer.size - 1
|
39
|
+
rets = proc.call outer[-(inner_index + 1)], outer[-(inner_index + 2)], outer_index
|
40
|
+
winner = rets.first
|
41
|
+
@matches << rets.last
|
42
|
+
set_winner(winner, outer_index)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def set_winner(winner, outer_index)
|
50
|
+
@tournament[0..-(outer_index + 1)].reverse_each do |replace_outer|
|
51
|
+
replace_outer.reverse_each.with_index do |reverse_inner, reverse_inner_index|
|
52
|
+
next unless reverse_inner.nil?
|
53
|
+
return replace_outer[-(reverse_inner_index + 1)] = winner
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/tbpgr_utils/version.rb
CHANGED
data/rubocop-todo.yml
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-05-04 11:22:42 +0900 using RuboCop version 0.21.0.
|
2
3
|
# The point is for the user to remove these configuration records
|
3
|
-
# one by one as the
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
4
7
|
|
5
|
-
|
8
|
+
# Offense count: 2
|
9
|
+
AccessorMethodName:
|
6
10
|
Enabled: false
|
7
11
|
|
8
|
-
|
12
|
+
# Offense count: 4
|
13
|
+
AmbiguousRegexpLiteral:
|
9
14
|
Enabled: false
|
10
15
|
|
11
|
-
|
16
|
+
# Offense count: 1
|
17
|
+
DoubleNegation:
|
12
18
|
Enabled: false
|
13
19
|
|
14
|
-
|
20
|
+
# Offense count: 3
|
21
|
+
# Configuration parameters: NamePrefixBlacklist.
|
22
|
+
PredicateName:
|
15
23
|
Enabled: false
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
EmptyLinesAroundAccessModifier:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Encoding:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Eval:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Lambda:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
MethodLength:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
NestedTernaryOperator:
|
36
|
-
Enabled: false
|
25
|
+
# Offense count: 2
|
26
|
+
RegexpLiteral:
|
27
|
+
MaxSlashes: 0
|
37
28
|
|
38
|
-
|
29
|
+
# Offense count: 2
|
30
|
+
SelfAssignment:
|
39
31
|
Enabled: false
|
40
32
|
|
41
|
-
|
33
|
+
# Offense count: 11
|
34
|
+
# Configuration parameters: Methods.
|
35
|
+
SingleLineBlockParams:
|
42
36
|
Enabled: false
|
43
37
|
|
44
|
-
|
38
|
+
# Offense count: 2
|
39
|
+
SpaceBeforeFirstArg:
|
45
40
|
Enabled: false
|
46
41
|
|
47
|
-
|
42
|
+
# Offense count: 447
|
43
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
44
|
+
TrailingComma:
|
48
45
|
Enabled: false
|
49
46
|
|
50
|
-
|
47
|
+
# Offense count: 33
|
48
|
+
UnusedBlockArgument:
|
51
49
|
Enabled: false
|
52
50
|
|
53
|
-
|
51
|
+
# Offense count: 276
|
52
|
+
UnusedMethodArgument:
|
54
53
|
Enabled: false
|
55
54
|
|
56
|
-
|
55
|
+
# Offense count: 1
|
56
|
+
UselessAccessModifier:
|
57
57
|
Enabled: false
|
@@ -4,13 +4,13 @@ require 'markdown/heading'
|
|
4
4
|
|
5
5
|
describe MarkdownString do
|
6
6
|
[*1..6].each do |i|
|
7
|
-
context "heading#{i
|
7
|
+
context "heading#{i}" do
|
8
8
|
cases = [
|
9
9
|
{
|
10
10
|
case_no: 1,
|
11
11
|
case_title: 'normal case',
|
12
|
-
input: "heading#{i
|
13
|
-
expected: "#{'#' * i} heading#{i
|
12
|
+
input: "heading#{i}",
|
13
|
+
expected: "#{'#' * i} heading#{i}",
|
14
14
|
},
|
15
15
|
{
|
16
16
|
case_no: 2,
|
@@ -41,7 +41,7 @@ describe MarkdownString do
|
|
41
41
|
# nothing
|
42
42
|
|
43
43
|
# -- when --
|
44
|
-
actual = MarkdownString.send "heading#{i
|
44
|
+
actual = MarkdownString.send "heading#{i}", c[:input]
|
45
45
|
|
46
46
|
# -- then --
|
47
47
|
expect(actual).to eq(c[:expected])
|
data/spec/markdown/ol_spec.rb
CHANGED
data/spec/markdown/ul_spec.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
context :kernel_send do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'valid case',
|
11
|
+
input: [*1..3],
|
12
|
+
method_name: :Rational,
|
13
|
+
expected: [(1 / 1), (2 / 1), (3 / 1)],
|
14
|
+
},
|
15
|
+
]
|
16
|
+
|
17
|
+
cases.each do |c|
|
18
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
19
|
+
begin
|
20
|
+
case_before c
|
21
|
+
|
22
|
+
# -- given --
|
23
|
+
# nothing
|
24
|
+
|
25
|
+
# -- when/then --
|
26
|
+
actual = c[:input].kernel_send c[:method_name]
|
27
|
+
|
28
|
+
expect(actual).to eq(c[:expected])
|
29
|
+
ensure
|
30
|
+
case_after c
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def case_before(c)
|
35
|
+
# implement each case before
|
36
|
+
end
|
37
|
+
|
38
|
+
def case_after(c)
|
39
|
+
# implement each case after
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,61 +1,61 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'tbpgr_utils'
|
4
|
-
|
5
|
-
describe Array do
|
6
|
-
context :together_at do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'valid case',
|
11
|
-
inputs: [[1, 2, 3], %w
|
12
|
-
index: 2,
|
13
|
-
method_name: :together_at,
|
14
|
-
expected: [3, 'three'],
|
15
|
-
},
|
16
|
-
{
|
17
|
-
case_no: 2,
|
18
|
-
case_title: 'contain nil case',
|
19
|
-
inputs: [[1, 2, 3], %w
|
20
|
-
index: 2,
|
21
|
-
method_name: :together_at,
|
22
|
-
expected: [3, nil],
|
23
|
-
},
|
24
|
-
{
|
25
|
-
case_no: 3,
|
26
|
-
case_title: 'valid case',
|
27
|
-
inputs: [[1, 2, 3], %w
|
28
|
-
index: 2,
|
29
|
-
method_name: :tat,
|
30
|
-
expected: [3, 'three'],
|
31
|
-
},
|
32
|
-
]
|
33
|
-
|
34
|
-
cases.each do |c|
|
35
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
36
|
-
begin
|
37
|
-
case_before c
|
38
|
-
|
39
|
-
# -- given --
|
40
|
-
# nothing
|
41
|
-
|
42
|
-
# -- when --
|
43
|
-
actual = c[:inputs].send c[:method_name], c[:index]
|
44
|
-
|
45
|
-
# -- then --
|
46
|
-
expect(actual).to eq(c[:expected])
|
47
|
-
ensure
|
48
|
-
case_after c
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def case_before(c)
|
53
|
-
# implement each case before
|
54
|
-
end
|
55
|
-
|
56
|
-
def case_after(c)
|
57
|
-
# implement each case after
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
context :together_at do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'valid case',
|
11
|
+
inputs: [[1, 2, 3], %w(one two three)],
|
12
|
+
index: 2,
|
13
|
+
method_name: :together_at,
|
14
|
+
expected: [3, 'three'],
|
15
|
+
},
|
16
|
+
{
|
17
|
+
case_no: 2,
|
18
|
+
case_title: 'contain nil case',
|
19
|
+
inputs: [[1, 2, 3], %w(one two)],
|
20
|
+
index: 2,
|
21
|
+
method_name: :together_at,
|
22
|
+
expected: [3, nil],
|
23
|
+
},
|
24
|
+
{
|
25
|
+
case_no: 3,
|
26
|
+
case_title: 'valid case',
|
27
|
+
inputs: [[1, 2, 3], %w(one two three)],
|
28
|
+
index: 2,
|
29
|
+
method_name: :tat,
|
30
|
+
expected: [3, 'three'],
|
31
|
+
},
|
32
|
+
]
|
33
|
+
|
34
|
+
cases.each do |c|
|
35
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
36
|
+
begin
|
37
|
+
case_before c
|
38
|
+
|
39
|
+
# -- given --
|
40
|
+
# nothing
|
41
|
+
|
42
|
+
# -- when --
|
43
|
+
actual = c[:inputs].send c[:method_name], c[:index]
|
44
|
+
|
45
|
+
# -- then --
|
46
|
+
expect(actual).to eq(c[:expected])
|
47
|
+
ensure
|
48
|
+
case_after c
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def case_before(c)
|
53
|
+
# implement each case before
|
54
|
+
end
|
55
|
+
|
56
|
+
def case_after(c)
|
57
|
+
# implement each case after
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'tbpgr_utils'
|
4
|
-
|
5
|
-
describe Array do
|
6
|
-
context :together_clear do
|
7
|
-
cases = [
|
8
|
-
{
|
9
|
-
case_no: 1,
|
10
|
-
case_title: 'valid case',
|
11
|
-
inputs: [[1, 2, 3], %w
|
12
|
-
method_name: :together_clear,
|
13
|
-
expected: [[], []],
|
14
|
-
},
|
15
|
-
{
|
16
|
-
case_no: 2,
|
17
|
-
case_title: 'valid case',
|
18
|
-
inputs: [[1, 2, 3], %w
|
19
|
-
method_name: :tclear,
|
20
|
-
expected: [[], []],
|
21
|
-
},
|
22
|
-
]
|
23
|
-
|
24
|
-
cases.each do |c|
|
25
|
-
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
26
|
-
begin
|
27
|
-
case_before c
|
28
|
-
|
29
|
-
# -- given --
|
30
|
-
# nothing
|
31
|
-
|
32
|
-
# -- when --
|
33
|
-
actual = c[:inputs].send c[:method_name]
|
34
|
-
|
35
|
-
# -- then --
|
36
|
-
expect(actual).to eq(c[:expected])
|
37
|
-
ensure
|
38
|
-
case_after c
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def case_before(c)
|
43
|
-
# implement each case before
|
44
|
-
end
|
45
|
-
|
46
|
-
def case_after(c)
|
47
|
-
# implement each case after
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
context :together_clear do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'valid case',
|
11
|
+
inputs: [[1, 2, 3], %w(one two three)],
|
12
|
+
method_name: :together_clear,
|
13
|
+
expected: [[], []],
|
14
|
+
},
|
15
|
+
{
|
16
|
+
case_no: 2,
|
17
|
+
case_title: 'valid case',
|
18
|
+
inputs: [[1, 2, 3], %w(one two three)],
|
19
|
+
method_name: :tclear,
|
20
|
+
expected: [[], []],
|
21
|
+
},
|
22
|
+
]
|
23
|
+
|
24
|
+
cases.each do |c|
|
25
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
26
|
+
begin
|
27
|
+
case_before c
|
28
|
+
|
29
|
+
# -- given --
|
30
|
+
# nothing
|
31
|
+
|
32
|
+
# -- when --
|
33
|
+
actual = c[:inputs].send c[:method_name]
|
34
|
+
|
35
|
+
# -- then --
|
36
|
+
expect(actual).to eq(c[:expected])
|
37
|
+
ensure
|
38
|
+
case_after c
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def case_before(c)
|
43
|
+
# implement each case before
|
44
|
+
end
|
45
|
+
|
46
|
+
def case_after(c)
|
47
|
+
# implement each case after
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|