lookout 2.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/README +645 -0
- data/Rakefile +9 -0
- data/lib/lookout.rb +34 -0
- data/lib/lookout/aphonic.rb +40 -0
- data/lib/lookout/benchmark.rb +11 -0
- data/lib/lookout/diff.rb +10 -0
- data/lib/lookout/diff/algorithms.rb +5 -0
- data/lib/lookout/diff/algorithms/difflib.rb +38 -0
- data/lib/lookout/diff/algorithms/difflib/position.rb +92 -0
- data/lib/lookout/diff/algorithms/difflib/position/to.rb +47 -0
- data/lib/lookout/diff/formats.rb +7 -0
- data/lib/lookout/diff/formats/hash.rb +53 -0
- data/lib/lookout/diff/formats/inline.rb +39 -0
- data/lib/lookout/diff/formats/unified.rb +57 -0
- data/lib/lookout/diff/group.rb +61 -0
- data/lib/lookout/diff/groups.rb +34 -0
- data/lib/lookout/diff/match.rb +36 -0
- data/lib/lookout/diff/operation.rb +33 -0
- data/lib/lookout/diff/operations.rb +36 -0
- data/lib/lookout/diff/operations/delete.rb +9 -0
- data/lib/lookout/diff/operations/equal.rb +27 -0
- data/lib/lookout/diff/operations/insert.rb +9 -0
- data/lib/lookout/diff/operations/replace.rb +9 -0
- data/lib/lookout/diff/range.rb +91 -0
- data/lib/lookout/equality.rb +178 -0
- data/lib/lookout/expectation.rb +50 -0
- data/lib/lookout/expectations.rb +62 -0
- data/lib/lookout/expectations/behavior.rb +20 -0
- data/lib/lookout/expectations/state.rb +29 -0
- data/lib/lookout/mock.rb +18 -0
- data/lib/lookout/mock/method.rb +70 -0
- data/lib/lookout/mock/method/arguments.rb +33 -0
- data/lib/lookout/mock/method/arguments/any.rb +11 -0
- data/lib/lookout/mock/method/arguments/anything.rb +11 -0
- data/lib/lookout/mock/method/arguments/list.rb +15 -0
- data/lib/lookout/mock/method/arguments/none.rb +11 -0
- data/lib/lookout/mock/method/arguments/one.rb +11 -0
- data/lib/lookout/mock/method/calls.rb +11 -0
- data/lib/lookout/mock/method/calls/class.rb +21 -0
- data/lib/lookout/mock/method/calls/exactly.rb +28 -0
- data/lib/lookout/mock/method/calls/instance.rb +25 -0
- data/lib/lookout/mock/method/calls/lower.rb +22 -0
- data/lib/lookout/mock/method/calls/upper.rb +22 -0
- data/lib/lookout/mock/methods.rb +12 -0
- data/lib/lookout/mock/object.rb +12 -0
- data/lib/lookout/object.rb +11 -0
- data/lib/lookout/output.rb +21 -0
- data/lib/lookout/rake/tasks.rb +36 -0
- data/lib/lookout/rake/tasks/gem.rb +49 -0
- data/lib/lookout/rake/tasks/tags.rb +16 -0
- data/lib/lookout/rake/tasks/test.rb +46 -0
- data/lib/lookout/rake/tasks/test/loader.rb +19 -0
- data/lib/lookout/recorder.rb +45 -0
- data/lib/lookout/recorder/not.rb +11 -0
- data/lib/lookout/recorder/tape.rb +21 -0
- data/lib/lookout/recorders.rb +6 -0
- data/lib/lookout/recorders/reception.rb +47 -0
- data/lib/lookout/recorders/state.rb +35 -0
- data/lib/lookout/result.rb +23 -0
- data/lib/lookout/results.rb +46 -0
- data/lib/lookout/results/error.rb +18 -0
- data/lib/lookout/results/error/exception.rb +36 -0
- data/lib/lookout/results/error/exception/backtrace.rb +41 -0
- data/lib/lookout/results/failure.rb +16 -0
- data/lib/lookout/results/failures.rb +6 -0
- data/lib/lookout/results/failures/behavior.rb +4 -0
- data/lib/lookout/results/failures/state.rb +4 -0
- data/lib/lookout/results/fulfilled.rb +9 -0
- data/lib/lookout/runners.rb +5 -0
- data/lib/lookout/runners/console.rb +22 -0
- data/lib/lookout/stub.rb +16 -0
- data/lib/lookout/stub/method.rb +105 -0
- data/lib/lookout/stub/methods.rb +18 -0
- data/lib/lookout/stub/object.rb +11 -0
- data/lib/lookout/ui.rb +7 -0
- data/lib/lookout/ui/console.rb +36 -0
- data/lib/lookout/ui/silent.rb +12 -0
- data/lib/lookout/version.rb +5 -0
- data/lib/lookout/xml.rb +17 -0
- data/test/unit/examples.rb +169 -0
- data/test/unit/lookout.rb +7 -0
- data/test/unit/lookout/diff.rb +4 -0
- data/test/unit/lookout/diff/algorithms/difflib.rb +56 -0
- data/test/unit/lookout/diff/algorithms/difflib/position.rb +92 -0
- data/test/unit/lookout/diff/algorithms/difflib/position/to.rb +12 -0
- data/test/unit/lookout/diff/formats/inline.rb +17 -0
- data/test/unit/lookout/diff/formats/unified.rb +67 -0
- data/test/unit/lookout/diff/group.rb +4 -0
- data/test/unit/lookout/diff/groups.rb +102 -0
- data/test/unit/lookout/diff/match.rb +5 -0
- data/test/unit/lookout/diff/operations.rb +22 -0
- data/test/unit/lookout/diff/operations/delete.rb +45 -0
- data/test/unit/lookout/diff/operations/equal.rb +45 -0
- data/test/unit/lookout/diff/operations/insert.rb +45 -0
- data/test/unit/lookout/diff/operations/replace.rb +45 -0
- data/test/unit/lookout/diff/range.rb +50 -0
- data/test/unit/lookout/equality.rb +113 -0
- data/test/unit/lookout/expectation.rb +39 -0
- data/test/unit/lookout/expectations.rb +58 -0
- data/test/unit/lookout/expectations/behavior.rb +35 -0
- data/test/unit/lookout/expectations/state.rb +29 -0
- data/test/unit/lookout/mock.rb +4 -0
- data/test/unit/lookout/mock/method.rb +143 -0
- data/test/unit/lookout/mock/method/arguments.rb +57 -0
- data/test/unit/lookout/mock/method/arguments/any.rb +11 -0
- data/test/unit/lookout/recorder.rb +11 -0
- data/test/unit/lookout/results.rb +30 -0
- data/test/unit/lookout/results/error.rb +7 -0
- data/test/unit/lookout/results/failures/behavior.rb +7 -0
- data/test/unit/lookout/results/failures/state.rb +7 -0
- data/test/unit/lookout/results/fulfilled.rb +7 -0
- data/test/unit/lookout/runners/console.rb +4 -0
- data/test/unit/lookout/stub.rb +4 -0
- data/test/unit/lookout/stub/method.rb +48 -0
- data/test/unit/lookout/ui/formatters/exception.rb +5 -0
- data/test/unit/lookout/ui/formatters/exception/backtrace.rb +11 -0
- data/test/unit/lookout/xml.rb +55 -0
- metadata +496 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect [] do
|
5
|
+
Lookout::Diff::Groups.
|
6
|
+
new(Lookout::Diff::Operations.
|
7
|
+
new(Lookout::Diff::Algorithms::Difflib.new('', ''))).to_a
|
8
|
+
end
|
9
|
+
|
10
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abc', 0..2),
|
11
|
+
Lookout::Diff::Range.new('abc', 0..2)))] do
|
12
|
+
Lookout::Diff::Groups.
|
13
|
+
new(Lookout::Diff::Operations.
|
14
|
+
new(Lookout::Diff::Algorithms::Difflib.new('abc', 'abc'))).to_a
|
15
|
+
end
|
16
|
+
|
17
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abcdefg', 4..6),
|
18
|
+
Lookout::Diff::Range.new('abcdefg', 4..6)))] do
|
19
|
+
Lookout::Diff::Groups.
|
20
|
+
new(Lookout::Diff::Operations.
|
21
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
22
|
+
new('abcdefg',
|
23
|
+
'abcdefg'))).to_a
|
24
|
+
end
|
25
|
+
|
26
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('Abcdefg', 0..0),
|
27
|
+
Lookout::Diff::Range.new('abcdefg', 0..0)),
|
28
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('Abcdefg', 1..3),
|
29
|
+
Lookout::Diff::Range.new('abcdefg', 1..3)))] do
|
30
|
+
Lookout::Diff::Groups.
|
31
|
+
new(Lookout::Diff::Operations.
|
32
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
33
|
+
new('Abcdefg',
|
34
|
+
'abcdefg'))).to_a
|
35
|
+
end
|
36
|
+
|
37
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('Abcdefgh', 0..0),
|
38
|
+
Lookout::Diff::Range.new('abcdefgh', 0..0)),
|
39
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('Abcdefgh', 1..3),
|
40
|
+
Lookout::Diff::Range.new('abcdefgh', 1..3)))] do
|
41
|
+
Lookout::Diff::Groups.
|
42
|
+
new(Lookout::Diff::Operations.
|
43
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
44
|
+
new('Abcdefgh',
|
45
|
+
'abcdefgh'))).to_a
|
46
|
+
end
|
47
|
+
|
48
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abcdefgHijklmno', 4..6),
|
49
|
+
Lookout::Diff::Range.new('abcdefghijklmno', 4..6)),
|
50
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('abcdefgHijklmno', 7..7),
|
51
|
+
Lookout::Diff::Range.new('abcdefghijklmno', 7..7)),
|
52
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abcdefgHijklmno', 8..10),
|
53
|
+
Lookout::Diff::Range.new('abcdefghijklmno', 8..10)))] do
|
54
|
+
Lookout::Diff::Groups.
|
55
|
+
new(Lookout::Diff::Operations.
|
56
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
57
|
+
new('abcdefgHijklmno',
|
58
|
+
'abcdefghijklmno'))).to_a
|
59
|
+
end
|
60
|
+
|
61
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 0..0),
|
62
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 0..0)),
|
63
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('123456789abcdefghijk', 1..1),
|
64
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 1..1)),
|
65
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 2..4),
|
66
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 2..4))),
|
67
|
+
Lookout::Diff::Group.new(Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 8..10),
|
68
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 8..10)),
|
69
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('123456789abcdefghijk', 11..11),
|
70
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 11..11)),
|
71
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 12..12),
|
72
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 12..12)),
|
73
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('123456789abcdefghijk', 13..15),
|
74
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 13...13)),
|
75
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 16..16),
|
76
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 13..13)),
|
77
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('123456789abcdefghijk', 17..17),
|
78
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 14..14)),
|
79
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('123456789abcdefghijk', 18..19),
|
80
|
+
Lookout::Diff::Range.new('1i3456789abXdhYjk', 15..16)))] do
|
81
|
+
Lookout::Diff::Groups.
|
82
|
+
new(Lookout::Diff::Operations.
|
83
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
84
|
+
new('123456789abcdefghijk',
|
85
|
+
'1i3456789abXdhYjk'))).to_a
|
86
|
+
end
|
87
|
+
|
88
|
+
expect [Lookout::Diff::Group.new(Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new(%w[one two three four], 0...0),
|
89
|
+
Lookout::Diff::Range.new(%w[zero one tree four], 0..0)),
|
90
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new(%w[one two three four], 0..0),
|
91
|
+
Lookout::Diff::Range.new(%w[zero one tree four], 1..1)),
|
92
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new(%w[one two three four], 1..2),
|
93
|
+
Lookout::Diff::Range.new(%w[zero one tree four], 2..2)),
|
94
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new(%w[one two three four], 3..3),
|
95
|
+
Lookout::Diff::Range.new(%w[zero one tree four], 3..3)))] do
|
96
|
+
Lookout::Diff::Groups.
|
97
|
+
new(Lookout::Diff::Operations.
|
98
|
+
new(Lookout::Diff::Algorithms::Difflib.
|
99
|
+
new(%w[one two three four],
|
100
|
+
%w[zero one tree four]))).to_a
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect [] do
|
5
|
+
Lookout::Diff::Operations.new(Lookout::Diff::Algorithms::Difflib.new('',
|
6
|
+
'')).to_a
|
7
|
+
end
|
8
|
+
|
9
|
+
expect [Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('qabxcd', 0..0),
|
10
|
+
Lookout::Diff::Range.new('abycdf', 0...0)),
|
11
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('qabxcd', 1..2),
|
12
|
+
Lookout::Diff::Range.new('abycdf', 0..1)),
|
13
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('qabxcd', 3..3),
|
14
|
+
Lookout::Diff::Range.new('abycdf', 2..2)),
|
15
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('qabxcd', 4..5),
|
16
|
+
Lookout::Diff::Range.new('abycdf', 3..4)),
|
17
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('qabxcd', 6...6),
|
18
|
+
Lookout::Diff::Range.new('abycdf', 5..5))] do
|
19
|
+
Lookout::Diff::Operations.new(Lookout::Diff::Algorithms::Difflib.new('qabxcd',
|
20
|
+
'abycdf')).to_a
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
6
|
+
Lookout::Diff::Range.new('', 0...0)).foldable? 0
|
7
|
+
end
|
8
|
+
|
9
|
+
expect false do
|
10
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('ab', 0..1),
|
11
|
+
Lookout::Diff::Range.new('ab', 0..1)).foldable? 1
|
12
|
+
end
|
13
|
+
|
14
|
+
expect Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
15
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
16
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
17
|
+
Lookout::Diff::Range.new('', 0...0)) >> 1
|
18
|
+
end
|
19
|
+
|
20
|
+
expect Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('abc', 0..2),
|
21
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
22
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('abc', 0..2),
|
23
|
+
Lookout::Diff::Range.new('abc', 0..2)) >> 1
|
24
|
+
end
|
25
|
+
|
26
|
+
expect Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
27
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
28
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
29
|
+
Lookout::Diff::Range.new('', 0...0)) << 1
|
30
|
+
end
|
31
|
+
|
32
|
+
expect Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('abc', 0..2),
|
33
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
34
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('abc', 0..2),
|
35
|
+
Lookout::Diff::Range.new('abc', 0..2)) << 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect mock.to.receive.
|
39
|
+
delete(Lookout::Diff::Operations::Delete.
|
40
|
+
new(Lookout::Diff::Range.new('', 0...0),
|
41
|
+
Lookout::Diff::Range.new('a', 0...0))).once do |o|
|
42
|
+
Lookout::Diff::Operations::Delete.new(Lookout::Diff::Range.new('', 0...0),
|
43
|
+
Lookout::Diff::Range.new('a', 0...0)).apply(o)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('', 0...0),
|
6
|
+
Lookout::Diff::Range.new('', 0...0)).foldable? 0
|
7
|
+
end
|
8
|
+
|
9
|
+
expect true do
|
10
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('ab', 0..1),
|
11
|
+
Lookout::Diff::Range.new('ab', 0..1)).foldable? 1
|
12
|
+
end
|
13
|
+
|
14
|
+
expect Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('', 0...0),
|
15
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
16
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('', 0...0),
|
17
|
+
Lookout::Diff::Range.new('', 0...0)) >> 1
|
18
|
+
end
|
19
|
+
|
20
|
+
expect Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abc', 2..2),
|
21
|
+
Lookout::Diff::Range.new('abc', 2..2)) do
|
22
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abc', 0..2),
|
23
|
+
Lookout::Diff::Range.new('abc', 0..2)) >> 1
|
24
|
+
end
|
25
|
+
|
26
|
+
expect Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('', 0...0),
|
27
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
28
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('', 0...0),
|
29
|
+
Lookout::Diff::Range.new('', 0...0)) << 1
|
30
|
+
end
|
31
|
+
|
32
|
+
expect Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abc', 0..0),
|
33
|
+
Lookout::Diff::Range.new('abc', 0..0)) do
|
34
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('abc', 0..2),
|
35
|
+
Lookout::Diff::Range.new('abc', 0..2)) << 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect mock.to.receive.
|
39
|
+
equal(Lookout::Diff::Operations::Equal.
|
40
|
+
new(Lookout::Diff::Range.new('a', 0..0),
|
41
|
+
Lookout::Diff::Range.new('a', 0..0))).once do |o|
|
42
|
+
Lookout::Diff::Operations::Equal.new(Lookout::Diff::Range.new('a', 0..0),
|
43
|
+
Lookout::Diff::Range.new('a', 0..0)).apply(o)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
6
|
+
Lookout::Diff::Range.new('', 0...0)).foldable? 0
|
7
|
+
end
|
8
|
+
|
9
|
+
expect false do
|
10
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('ab', 0..1),
|
11
|
+
Lookout::Diff::Range.new('ab', 0..1)).foldable? 1
|
12
|
+
end
|
13
|
+
|
14
|
+
expect Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
15
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
16
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
17
|
+
Lookout::Diff::Range.new('', 0...0)) >> 1
|
18
|
+
end
|
19
|
+
|
20
|
+
expect Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('abc', 0..2),
|
21
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
22
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('abc', 0..2),
|
23
|
+
Lookout::Diff::Range.new('abc', 0..2)) >> 1
|
24
|
+
end
|
25
|
+
|
26
|
+
expect Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
27
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
28
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
29
|
+
Lookout::Diff::Range.new('', 0...0)) << 1
|
30
|
+
end
|
31
|
+
|
32
|
+
expect Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('abc', 0..2),
|
33
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
34
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('abc', 0..2),
|
35
|
+
Lookout::Diff::Range.new('abc', 0..2)) << 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect mock.to.receive.
|
39
|
+
insert(Lookout::Diff::Operations::Insert.
|
40
|
+
new(Lookout::Diff::Range.new('', 0...0),
|
41
|
+
Lookout::Diff::Range.new('a', 0...0))).once do |o|
|
42
|
+
Lookout::Diff::Operations::Insert.new(Lookout::Diff::Range.new('', 0...0),
|
43
|
+
Lookout::Diff::Range.new('a', 0...0)).apply(o)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect false do
|
5
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
6
|
+
Lookout::Diff::Range.new('', 0...0)).foldable? 0
|
7
|
+
end
|
8
|
+
|
9
|
+
expect false do
|
10
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('ab', 0..1),
|
11
|
+
Lookout::Diff::Range.new('ab', 0..1)).foldable? 1
|
12
|
+
end
|
13
|
+
|
14
|
+
expect Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
15
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
16
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
17
|
+
Lookout::Diff::Range.new('', 0...0)) >> 1
|
18
|
+
end
|
19
|
+
|
20
|
+
expect Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('abc', 0..2),
|
21
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
22
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('abc', 0..2),
|
23
|
+
Lookout::Diff::Range.new('abc', 0..2)) >> 1
|
24
|
+
end
|
25
|
+
|
26
|
+
expect Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
27
|
+
Lookout::Diff::Range.new('', 0...0)) do
|
28
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
29
|
+
Lookout::Diff::Range.new('', 0...0)) << 1
|
30
|
+
end
|
31
|
+
|
32
|
+
expect Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('abc', 0..2),
|
33
|
+
Lookout::Diff::Range.new('abc', 0..2)) do
|
34
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('abc', 0..2),
|
35
|
+
Lookout::Diff::Range.new('abc', 0..2)) << 1
|
36
|
+
end
|
37
|
+
|
38
|
+
expect mock.to.receive.
|
39
|
+
replace(Lookout::Diff::Operations::Replace.
|
40
|
+
new(Lookout::Diff::Range.new('', 0...0),
|
41
|
+
Lookout::Diff::Range.new('a', 0...0))).once do |o|
|
42
|
+
Lookout::Diff::Operations::Replace.new(Lookout::Diff::Range.new('', 0...0),
|
43
|
+
Lookout::Diff::Range.new('a', 0...0)).apply(o)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect Lookout::Diff::Range.new('').to.be.empty?
|
5
|
+
expect Lookout::Diff::Range.new('a', 0..-1).to.be.empty?
|
6
|
+
expect Lookout::Diff::Range.new('a', 0...0).to.be.empty?
|
7
|
+
expect Lookout::Diff::Range.new('a', 0..0).not.to.be.empty?
|
8
|
+
|
9
|
+
expect Lookout::Diff::Range.new('').to.have.size.equal?(0)
|
10
|
+
expect Lookout::Diff::Range.new('a', 0...0).to.have.size.equal?(0)
|
11
|
+
expect Lookout::Diff::Range.new('a', 0..0).to.have.size.equal?(1)
|
12
|
+
|
13
|
+
expect Lookout::Diff::Range.new('a', 0..0).not.to.be.
|
14
|
+
begins_before?(Lookout::Diff::Range.new('a', 0..1))
|
15
|
+
expect Lookout::Diff::Range.new('a', 0..0).to.be.
|
16
|
+
begins_before?(Lookout::Diff::Range.new('a', 1..1))
|
17
|
+
|
18
|
+
expect Lookout::Diff::Range.new('a', 0..0).not.to.be.
|
19
|
+
ends_after?(Lookout::Diff::Range.new('a', 0..1))
|
20
|
+
expect Lookout::Diff::Range.new('a', 1..1).to.be.
|
21
|
+
ends_after?(Lookout::Diff::Range.new('a', 0..0))
|
22
|
+
|
23
|
+
expect Lookout::Diff::Range.new('abc', 2..2) do
|
24
|
+
Lookout::Diff::Range.new('abc').begin_after(Lookout::Diff::Range.new('abc', 0..1))
|
25
|
+
end
|
26
|
+
|
27
|
+
expect Lookout::Diff::Range.new('abc', 0..0) do
|
28
|
+
Lookout::Diff::Range.new('abc').end_before(Lookout::Diff::Range.new('abc', 1..2))
|
29
|
+
end
|
30
|
+
|
31
|
+
expect Lookout::Diff::Range.new('abc', 1..2) do
|
32
|
+
Lookout::Diff::Range.new('abc').at(1..2)
|
33
|
+
end
|
34
|
+
|
35
|
+
expect 'a' do
|
36
|
+
Lookout::Diff::Range.new(%w[a b c])[0]
|
37
|
+
end
|
38
|
+
|
39
|
+
expect 'b' do
|
40
|
+
Lookout::Diff::Range.new(%w[a b c], 2..2)[1]
|
41
|
+
end
|
42
|
+
|
43
|
+
expect ['b', 1] do
|
44
|
+
result = []
|
45
|
+
Lookout::Diff::Range.new(%w[a b c], 1..1).each_with_index do |c, i|
|
46
|
+
result = [c, i]
|
47
|
+
end
|
48
|
+
result
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
Expectations do
|
4
|
+
expect nil do
|
5
|
+
Lookout::Equality.diff('abc', 1)
|
6
|
+
end
|
7
|
+
|
8
|
+
expect '[-A-]{+a+}bc' do
|
9
|
+
Lookout::Equality.diff('abc', 'Abc')
|
10
|
+
end
|
11
|
+
|
12
|
+
expect 'a[-B-]{+b+}c' do
|
13
|
+
Lookout::Equality.diff('abc', 'aBc')
|
14
|
+
end
|
15
|
+
|
16
|
+
expect 'ab[-C-]{+c+}' do
|
17
|
+
Lookout::Equality.diff('abc', 'abC')
|
18
|
+
end
|
19
|
+
|
20
|
+
expect <<EOD.chomp do
|
21
|
+
@@ -1,2 +1,2 @@
|
22
|
+
-def
|
23
|
+
+abc
|
24
|
+
ghi
|
25
|
+
EOD
|
26
|
+
Lookout::Equality.diff("abc\nghi", "def\nghi")
|
27
|
+
end
|
28
|
+
|
29
|
+
expect nil do
|
30
|
+
Lookout::Equality.diff(%w[abc], 'def')
|
31
|
+
end
|
32
|
+
|
33
|
+
expect nil do
|
34
|
+
Lookout::Equality.diff(%w[abc], %w[def])
|
35
|
+
end
|
36
|
+
|
37
|
+
expect <<EOD.chomp do
|
38
|
+
@@ -1,2 +1,2 @@
|
39
|
+
-def
|
40
|
+
+abc
|
41
|
+
ghi
|
42
|
+
EOD
|
43
|
+
Lookout::Equality.diff(%w[abc ghi], %w[def ghi])
|
44
|
+
end
|
45
|
+
|
46
|
+
expect nil do
|
47
|
+
Lookout::Equality.diff({'abc' => 1}, 'def')
|
48
|
+
end
|
49
|
+
|
50
|
+
expect nil do
|
51
|
+
Lookout::Equality.diff({'abc' => 1}, {'def' => 1})
|
52
|
+
end
|
53
|
+
|
54
|
+
expect <<EOD.chomp do
|
55
|
+
-"def" => 1
|
56
|
+
+"abc" => 1
|
57
|
+
EOD
|
58
|
+
Lookout::Equality.diff({'abc' => 1, 'ghi' => 2}, {'def' => 1, 'ghi' => 2})
|
59
|
+
end
|
60
|
+
|
61
|
+
expect true do
|
62
|
+
Lookout::Equality.equal? String, 'foo'
|
63
|
+
end
|
64
|
+
|
65
|
+
expect true do
|
66
|
+
Lookout::Equality.equal? 'foo', 'foo'
|
67
|
+
end
|
68
|
+
|
69
|
+
expect true do
|
70
|
+
Lookout::Equality.equal? String, String
|
71
|
+
end
|
72
|
+
|
73
|
+
expect false do
|
74
|
+
Lookout::Equality.equal? String, 0
|
75
|
+
end
|
76
|
+
|
77
|
+
expect true do
|
78
|
+
object = Object.new
|
79
|
+
Lookout::Equality.equal? object, object
|
80
|
+
end
|
81
|
+
|
82
|
+
expect false do
|
83
|
+
Lookout::Equality.equal? Object.new, Object.new
|
84
|
+
end
|
85
|
+
|
86
|
+
expect true do
|
87
|
+
Lookout::Equality.equal? 1..5, 3
|
88
|
+
end
|
89
|
+
|
90
|
+
expect true do
|
91
|
+
Lookout::Equality.equal? 1..5, (1..5)
|
92
|
+
end
|
93
|
+
|
94
|
+
expect false do
|
95
|
+
Lookout::Equality.equal? 1..5, 6
|
96
|
+
end
|
97
|
+
|
98
|
+
expect true do
|
99
|
+
Lookout::Equality.equal?(/foo/, 'foo')
|
100
|
+
end
|
101
|
+
|
102
|
+
expect true do
|
103
|
+
Lookout::Equality.equal?(/foo/, /foo/)
|
104
|
+
end
|
105
|
+
|
106
|
+
expect false do
|
107
|
+
Lookout::Equality.equal?(/foo/, 'bar')
|
108
|
+
end
|
109
|
+
|
110
|
+
expect false do
|
111
|
+
Lookout::Equality.equal?(/foo/, /bar/)
|
112
|
+
end
|
113
|
+
end
|