to_source 0.2.13 → 0.2.14
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/Changelog.md +14 -8
- data/TODO +1 -0
- data/lib/to_source/emitter/assignment.rb +2 -0
- data/lib/to_source/emitter/binary_operator.rb +12 -2
- data/lib/to_source/emitter/binary_operator_method.rb +12 -2
- data/spec/unit/to_source/class_methods/run_spec.rb +23 -15
- data/to_source.gemspec +1 -1
- metadata +1 -1
data/Changelog.md
CHANGED
@@ -1,35 +1,41 @@
|
|
1
|
-
# v0.2.
|
1
|
+
# v0.2.14 2013-01-09
|
2
|
+
|
3
|
+
* [fixed] Emit send with arguments and body correctly
|
4
|
+
|
5
|
+
[Compare v0.2.13..v0.2.14](https://github.com/mbj/to_source/compare/v0.2.13...v0.2.14)
|
6
|
+
|
7
|
+
# v0.2.13 2013-01-09
|
2
8
|
|
3
9
|
* [fixed] Emit send with arguments and body correctly
|
4
10
|
|
5
11
|
[Compare v0.2.12..v0.2.13](https://github.com/mbj/to_source/compare/v0.2.12...v0.2.13)
|
6
12
|
|
7
|
-
# v0.2.12 2013-01-
|
13
|
+
# v0.2.12 2013-01-09
|
8
14
|
|
9
15
|
* [fixed] Emit edge cases with dynamic literals correctly
|
10
16
|
|
11
17
|
[Compare v0.2.11..v0.2.12](https://github.com/mbj/to_source/compare/v0.2.11...v0.2.12)
|
12
18
|
|
13
|
-
# v0.2.11 2013-01-
|
19
|
+
# v0.2.11 2013-01-09
|
14
20
|
|
15
21
|
* [fixed] Allow all nodes to be entrypoints
|
16
22
|
|
17
23
|
[Compare v0.2.10..v0.2.11](https://github.com/mbj/to_source/compare/v0.2.10...v0.2.11)
|
18
24
|
|
19
|
-
# v0.2.10 2013-01-
|
25
|
+
# v0.2.10 2013-01-07
|
20
26
|
|
21
27
|
* [Changed] Rewrote internals compleatly, no outer API change
|
22
28
|
* [fixed] Emit indentation of complex nested structures with rescue statements correctly
|
23
29
|
|
24
30
|
[Compare v0.2.9..v0.2.10](https://github.com/mbj/to_source/compare/v0.2.9...v0.2.10)
|
25
31
|
|
26
|
-
# v0.2.9 2013-01-
|
32
|
+
# v0.2.9 2013-01-04
|
27
33
|
|
28
34
|
* [fixed] Handle regexp literals containing slashes in non shash delimiters %r(/) correctly
|
29
35
|
|
30
36
|
[Compare v0.2.8..v0.2.9](https://github.com/mbj/to_source/compare/v0.2.8...v0.2.9)
|
31
37
|
|
32
|
-
# v0.2.8 2013-01-
|
38
|
+
# v0.2.8 2013-01-03
|
33
39
|
|
34
40
|
* [Changed] Emit many times more ugly code, but correctnes > beautifulnes
|
35
41
|
* [fixed] Emit break with parantheses
|
@@ -38,13 +44,13 @@
|
|
38
44
|
|
39
45
|
[Compare v0.2.7..v0.2.8](https://github.com/mbj/to_source/compare/v0.2.7...v0.2.8)
|
40
46
|
|
41
|
-
# v0.2.7 2013-01-
|
47
|
+
# v0.2.7 2013-01-02
|
42
48
|
|
43
49
|
* [fixed] Emit super with blocks correctly
|
44
50
|
|
45
51
|
[Compare v0.2.6..v0.2.7](https://github.com/mbj/to_source/compare/v0.2.6...v0.2.7)
|
46
52
|
|
47
|
-
# v0.2.6 2013-01-
|
53
|
+
# v0.2.6 2013-01-01
|
48
54
|
|
49
55
|
* [fixed] Emit super vs super() correctly
|
50
56
|
|
data/TODO
CHANGED
@@ -49,6 +49,7 @@ module ToSource
|
|
49
49
|
class AssignmentOperator < self
|
50
50
|
|
51
51
|
def dispatch
|
52
|
+
emit('(')
|
52
53
|
visit(node.left)
|
53
54
|
space
|
54
55
|
emit(self.class::SYMBOL)
|
@@ -56,6 +57,7 @@ module ToSource
|
|
56
57
|
emit('(')
|
57
58
|
visit(node.right.value)
|
58
59
|
emit(')')
|
60
|
+
emit(')')
|
59
61
|
end
|
60
62
|
|
61
63
|
class Or < self
|
@@ -6,11 +6,21 @@ module ToSource
|
|
6
6
|
|
7
7
|
def dispatch
|
8
8
|
emit('(')
|
9
|
-
|
10
|
-
emit(')')
|
9
|
+
emit_left
|
11
10
|
space
|
12
11
|
emit(self.class::SYMBOL)
|
13
12
|
space
|
13
|
+
emit_right
|
14
|
+
emit(')')
|
15
|
+
end
|
16
|
+
|
17
|
+
def emit_left
|
18
|
+
emit('(')
|
19
|
+
visit(node.left)
|
20
|
+
emit(')')
|
21
|
+
end
|
22
|
+
|
23
|
+
def emit_right
|
14
24
|
emit('(')
|
15
25
|
visit(node.right)
|
16
26
|
emit(')')
|
@@ -6,16 +6,26 @@ module ToSource
|
|
6
6
|
|
7
7
|
def dispatch
|
8
8
|
emit('(')
|
9
|
-
|
10
|
-
emit(')')
|
9
|
+
emit_left
|
11
10
|
space
|
12
11
|
emit(node.name)
|
13
12
|
space
|
13
|
+
emit_right
|
14
|
+
emit(')')
|
15
|
+
end
|
16
|
+
|
17
|
+
def emit_right
|
14
18
|
emit('(')
|
15
19
|
visit(right)
|
16
20
|
emit(')')
|
17
21
|
end
|
18
22
|
|
23
|
+
def emit_left
|
24
|
+
emit('(')
|
25
|
+
visit(left)
|
26
|
+
emit(')')
|
27
|
+
end
|
28
|
+
|
19
29
|
def left
|
20
30
|
node.receiver
|
21
31
|
end
|
@@ -654,65 +654,73 @@ describe ToSource,'.to_source' do
|
|
654
654
|
end
|
655
655
|
end
|
656
656
|
|
657
|
-
context 'binary operators' do
|
657
|
+
context 'binary operators methods' do
|
658
658
|
%w(+ - * / & | && || << >> == === != <= < <=> > >= =~ !~ ^ **).each do |operator|
|
659
659
|
context "on literals #{operator}" do
|
660
|
-
assert_source "(1) #{operator} (2)"
|
660
|
+
assert_source "((1) #{operator} (2))"
|
661
661
|
end
|
662
662
|
|
663
663
|
context "on self #{operator}" do
|
664
|
-
assert_source "(self) #{operator} (b)"
|
664
|
+
assert_source "((self) #{operator} (b))"
|
665
665
|
end
|
666
666
|
|
667
|
-
context "on
|
668
|
-
assert_source "(a) #{operator} (b)"
|
667
|
+
context "on send #{operator}" do
|
668
|
+
assert_source "((a) #{operator} (b))"
|
669
669
|
end
|
670
670
|
end
|
671
671
|
|
672
672
|
context 'binary operator and keywords' do
|
673
|
-
assert_source '(a) || (break(foo))'
|
673
|
+
assert_source '((a) || (break(foo)))'
|
674
|
+
end
|
675
|
+
|
676
|
+
context 'sending methods to result of binary operator' do
|
677
|
+
assert_source '((a) || (b)).foo'
|
674
678
|
end
|
675
679
|
|
676
680
|
context 'nested binary operators' do
|
677
|
-
assert_source '(a) || ((b) || (c))'
|
681
|
+
assert_source '((a) || (((b) || (c))))'
|
678
682
|
end
|
679
683
|
end
|
680
684
|
|
681
685
|
{ :or => :'||', :and => :'&&' }.each do |word, symbol|
|
682
686
|
context "word form form equivalency of #{word} and #{symbol}" do
|
683
|
-
assert_converts "(a) #{symbol} (break(foo))", "a #{word} break foo"
|
687
|
+
assert_converts "((a) #{symbol} (break(foo)))", "a #{word} break foo"
|
684
688
|
end
|
685
689
|
end
|
686
690
|
|
687
691
|
context 'expansion of shortcuts' do
|
688
692
|
context 'on += operator' do
|
689
|
-
assert_converts 'a = (a) + (2)', 'a += 2'
|
693
|
+
assert_converts 'a = ((a) + (2))', 'a += 2'
|
690
694
|
end
|
691
695
|
|
692
696
|
context 'on -= operator' do
|
693
|
-
assert_converts 'a = (a) - (2)', 'a -= 2'
|
697
|
+
assert_converts 'a = ((a) - (2))', 'a -= 2'
|
694
698
|
end
|
695
699
|
|
696
700
|
context 'on **= operator' do
|
697
|
-
assert_converts 'a = (a) ** (2)', 'a **= 2'
|
701
|
+
assert_converts 'a = ((a) ** (2))', 'a **= 2'
|
698
702
|
end
|
699
703
|
|
700
704
|
context 'on *= operator' do
|
701
|
-
assert_converts 'a = (a) * (2)', 'a *= 2'
|
705
|
+
assert_converts 'a = ((a) * (2))', 'a *= 2'
|
702
706
|
end
|
703
707
|
|
704
708
|
context 'on /= operator' do
|
705
|
-
assert_converts 'a = (a) / (2)', 'a /= 2'
|
709
|
+
assert_converts 'a = ((a) / (2))', 'a /= 2'
|
706
710
|
end
|
707
711
|
end
|
708
712
|
|
709
713
|
context 'shortcuts' do
|
710
714
|
context 'on &&= operator' do
|
711
|
-
assert_source 'a &&= (b)'
|
715
|
+
assert_source '(a &&= (b))'
|
712
716
|
end
|
713
717
|
|
714
718
|
context 'on ||= operator' do
|
715
|
-
assert_source 'a ||= (2)'
|
719
|
+
assert_source '(a ||= (2))'
|
720
|
+
end
|
721
|
+
|
722
|
+
context 'calling methods on shortcuts' do
|
723
|
+
assert_source '(a ||= (2)).bar'
|
716
724
|
end
|
717
725
|
end
|
718
726
|
|
data/to_source.gemspec
CHANGED