to_source 0.2.9 → 0.2.11

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.
Files changed (71) hide show
  1. data/Changelog.md +13 -0
  2. data/LICENSE +21 -0
  3. data/README.md +6 -22
  4. data/TODO +3 -3
  5. data/lib/to_source.rb +68 -3
  6. data/lib/to_source/buffer.rb +40 -0
  7. data/lib/to_source/command.rb +44 -0
  8. data/lib/to_source/emitter.rb +76 -0
  9. data/lib/to_source/emitter/access.rb +20 -0
  10. data/lib/to_source/emitter/actual_arguments.rb +46 -0
  11. data/lib/to_source/emitter/alias.rb +18 -0
  12. data/lib/to_source/emitter/assignment.rb +77 -0
  13. data/lib/to_source/emitter/attribute_assignment.rb +19 -0
  14. data/lib/to_source/emitter/begin.rb +51 -0
  15. data/lib/to_source/emitter/binary_operator.rb +36 -0
  16. data/lib/to_source/emitter/binary_operator_method.rb +29 -0
  17. data/lib/to_source/emitter/block.rb +22 -0
  18. data/lib/to_source/emitter/block_argument.rb +16 -0
  19. data/lib/to_source/emitter/block_pass.rb +16 -0
  20. data/lib/to_source/emitter/class.rb +29 -0
  21. data/lib/to_source/emitter/concat_arguments.rb +20 -0
  22. data/lib/to_source/emitter/default_arguments.rb +15 -0
  23. data/lib/to_source/emitter/define.rb +61 -0
  24. data/lib/to_source/emitter/defined.rb +17 -0
  25. data/lib/to_source/emitter/element_assignment.rb +20 -0
  26. data/lib/to_source/emitter/element_reference.rb +16 -0
  27. data/lib/to_source/emitter/empty_body.rb +12 -0
  28. data/lib/to_source/emitter/ensure.rb +23 -0
  29. data/lib/to_source/emitter/ensure_body.rb +18 -0
  30. data/lib/to_source/emitter/execute_string.rb +13 -0
  31. data/lib/to_source/emitter/formal_arguments.rb +120 -0
  32. data/lib/to_source/emitter/if.rb +51 -0
  33. data/lib/to_source/emitter/iter.rb +20 -0
  34. data/lib/to_source/emitter/keyword_value.rb +43 -0
  35. data/lib/to_source/emitter/literal.rb +239 -0
  36. data/lib/to_source/emitter/match3.rb +17 -0
  37. data/lib/to_source/emitter/module.rb +21 -0
  38. data/lib/to_source/emitter/multiple_assignment.rb +23 -0
  39. data/lib/to_source/emitter/nth_ref.rb +15 -0
  40. data/lib/to_source/emitter/op_assign1.rb +19 -0
  41. data/lib/to_source/emitter/op_assign2.rb +19 -0
  42. data/lib/to_source/emitter/pattern_arguments.rb +17 -0
  43. data/lib/to_source/emitter/receiver_case.rb +35 -0
  44. data/lib/to_source/emitter/rescue.rb +21 -0
  45. data/lib/to_source/emitter/rescue_condition.rb +56 -0
  46. data/lib/to_source/emitter/scope.rb +17 -0
  47. data/lib/to_source/emitter/scope_name.rb +16 -0
  48. data/lib/to_source/emitter/scoped_name.rb +17 -0
  49. data/lib/to_source/emitter/send.rb +47 -0
  50. data/lib/to_source/emitter/send_with_arguments.rb +62 -0
  51. data/lib/to_source/emitter/singleton_class.rb +23 -0
  52. data/lib/to_source/emitter/splat.rb +17 -0
  53. data/lib/to_source/emitter/splat_when.rb +16 -0
  54. data/lib/to_source/emitter/static.rb +33 -0
  55. data/lib/to_source/emitter/super.rb +47 -0
  56. data/lib/to_source/emitter/to_array.rb +15 -0
  57. data/lib/to_source/emitter/to_string.rb +17 -0
  58. data/lib/to_source/emitter/toplevel.rb +15 -0
  59. data/lib/to_source/emitter/unary_operator_method.rb +20 -0
  60. data/lib/to_source/emitter/unless.rb +16 -0
  61. data/lib/to_source/emitter/until.rb +20 -0
  62. data/lib/to_source/emitter/util.rb +19 -0
  63. data/lib/to_source/emitter/when.rb +38 -0
  64. data/lib/to_source/emitter/while.rb +20 -0
  65. data/lib/to_source/emitter/yield.rb +19 -0
  66. data/lib/to_source/emitter/z_super.rb +17 -0
  67. data/lib/to_source/state.rb +60 -0
  68. data/spec/unit/to_source/{visitor/class_methods → class_methods}/run_spec.rb +84 -33
  69. data/to_source.gemspec +14 -12
  70. metadata +106 -11
  71. data/lib/to_source/visitor.rb +0 -1890
@@ -0,0 +1,17 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Splat < self
4
+
5
+ handle(Rubinius::AST::SplatValue)
6
+ handle(Rubinius::AST::RescueSplat)
7
+
8
+ private
9
+
10
+ def dispatch
11
+ emit('*')
12
+ visit(node.value)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module ToSource
2
+ class Emitter
3
+ class SplatWhen < self
4
+
5
+ handle(Rubinius::AST::SplatWhen)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('*')
11
+ visit(node.condition)
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,33 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Static < self
4
+
5
+ private
6
+
7
+ def dispatch
8
+ emit(self.class::SYMBOL)
9
+ end
10
+
11
+ class Next < self
12
+ handle(Rubinius::AST::Next)
13
+ SYMBOL = :next
14
+ end
15
+
16
+ class CurrentException < self
17
+ handle(Rubinius::AST::CurrentException)
18
+ SYMBOL = :'$!'
19
+ end
20
+
21
+ class Self < self
22
+ handle(Rubinius::AST::Self)
23
+ SYMBOL = :self
24
+ end
25
+
26
+ class File < self
27
+ handle(Rubinius::AST::File)
28
+ SYMBOL = :__FILE__
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Super < self
4
+
5
+ handle(Rubinius::AST::Super)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('super')
11
+ emit_arguments
12
+ emit_block
13
+ end
14
+
15
+ def emit_arguments
16
+ emit('(')
17
+ emitter = visit(node.arguments)
18
+ emit_block_pass(emitter)
19
+ emit(')')
20
+ end
21
+
22
+ def block
23
+ node.block
24
+ end
25
+
26
+ def block?
27
+ !!block
28
+ end
29
+
30
+ def block_pass?
31
+ block.kind_of?(Rubinius::AST::BlockPass19)
32
+ end
33
+
34
+ def emit_block_pass(emitter)
35
+ return unless block? and block_pass?
36
+ emit(', ') if emitter.any?
37
+ visit(block)
38
+ end
39
+
40
+ def emit_block
41
+ return unless block? and !block_pass?
42
+ visit(block)
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ module ToSource
2
+ class Emitter
3
+ class ToArray < self
4
+
5
+ handle(Rubinius::AST::ToArray)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ visit(node.value)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module ToSource
2
+ class Emitter
3
+ class ToString < self
4
+
5
+ handle(Rubinius::AST::ToString)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('#{')
11
+ visit(node.value)
12
+ emit('}')
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Toplevel < self
4
+
5
+ handle(Rubinius::AST::ToplevelClassName)
6
+ handle(Rubinius::AST::ToplevelConstant)
7
+
8
+ def dispatch
9
+ emit('::')
10
+ emit(node.name)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module ToSource
2
+ class Emitter
3
+ class UnaryOperatorMethod < self
4
+
5
+ UNARY_MAPPING = {
6
+ :-@ => :-,
7
+ :+@ => :+,
8
+ }.freeze
9
+
10
+ private
11
+
12
+ def dispatch
13
+ name = node.name
14
+ emit(UNARY_MAPPING.fetch(name, name))
15
+ visit(node.receiver)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Unless < self
4
+
5
+ def dispatch
6
+ emit('unless ')
7
+ visit(node.condition)
8
+ indent
9
+ visit(node.else)
10
+ unindent
11
+ emit_end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Until < self
4
+
5
+ handle(Rubinius::AST::Until)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('until ')
11
+ visit(node.condition)
12
+ indent
13
+ visit(node.body)
14
+ unindent
15
+ emit_end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Util < self
4
+ class DelimitedBody < self
5
+
6
+ private
7
+
8
+ def dispatch
9
+ max = node.length - 1
10
+ node.each_with_index do |member, index|
11
+ visit(member)
12
+ emit(', ') if index < max
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ module ToSource
2
+ class Emitter
3
+ class When < self
4
+
5
+ handle(Rubinius::AST::When)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('when ')
11
+ emit_single
12
+ emit_conditions
13
+ emit_splat
14
+ indent
15
+ visit(node.body)
16
+ unindent
17
+ end
18
+
19
+ def emit_single
20
+ single = node.single
21
+ visit(single) if single
22
+ end
23
+
24
+ def emit_splat
25
+ splat = node.splat
26
+ return unless splat
27
+ visit(splat)
28
+ end
29
+
30
+ def emit_conditions
31
+ conditions = node.conditions
32
+ return unless conditions
33
+ run(Util::DelimitedBody, conditions.body)
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ module ToSource
2
+ class Emitter
3
+ class While < self
4
+
5
+ handle(Rubinius::AST::While)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('while ')
11
+ visit(node.condition)
12
+ indent
13
+ visit(node.body)
14
+ unindent
15
+ emit_end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module ToSource
2
+ class Emitter
3
+ class Yield < self
4
+
5
+ handle(Rubinius::AST::Yield)
6
+
7
+ def dispatch
8
+ emit('yield')
9
+ arguments = node.arguments
10
+ unless arguments.array.empty?
11
+ emit('(')
12
+ visit(node.arguments)
13
+ emit(')')
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module ToSource
2
+ class Emitter
3
+ class ZSuper < self
4
+
5
+ handle(Rubinius::AST::ZSuper)
6
+
7
+ private
8
+
9
+ def dispatch
10
+ emit('super')
11
+ block = node.block
12
+ visit(block) if block
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ module ToSource
2
+ class State
3
+
4
+ attr_reader :last
5
+ attr_reader :identation
6
+ attr_reader :buffer
7
+
8
+ def initialize
9
+ @last = Command::NULL
10
+ @indentation = 0
11
+ @buffer = []
12
+ end
13
+
14
+ def execute(command)
15
+ command.run(self)
16
+ @last = command
17
+ end
18
+
19
+ def last_keyword?
20
+ last.kind_of?(Command::Token::Keyword)
21
+ end
22
+
23
+ def write(string)
24
+ @buffer << string
25
+ end
26
+
27
+ def space
28
+ write(' ')
29
+ end
30
+
31
+ def push(command)
32
+ indent
33
+ write(command.content)
34
+ end
35
+
36
+ def indent
37
+ return unless blank?
38
+ write(' ' * @indentation)
39
+ end
40
+
41
+ def blank?
42
+ buffer.last == "\n"
43
+ end
44
+
45
+ def new_line
46
+ write("\n")
47
+ end
48
+
49
+ def source
50
+ buffer.join('')
51
+ end
52
+
53
+ def shift(width)
54
+ @indentation += width
55
+ @indentation = 0 if @indentation < 0
56
+ new_line
57
+ end
58
+
59
+ end
60
+ end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ToSource::Visitor,'.run' do
4
- subject { described_class.run(node) }
5
-
3
+ describe ToSource,'.to_source' do
6
4
  def compress(code)
7
5
  lines = code.split("\n")
8
6
  match = /\A( *)/.match(lines.first)
@@ -13,16 +11,32 @@ describe ToSource::Visitor,'.run' do
13
11
  joined = stripped.join("\n")
14
12
  end
15
13
 
14
+ def assert_round_trip(code)
15
+ node = code.to_ast
16
+ generated = ToSource.to_source(node)
17
+ generated.should eql(code)
18
+ # This is nonsense but I had a case where it helps?
19
+ second_node = generated.to_ast
20
+ second = ToSource.to_source(second_node)
21
+ second.should eql(code)
22
+ end
23
+
24
+ def assert_entrypoints(node)
25
+ node.instance_variables.each do |ivar|
26
+ value = node.instance_variable_get(ivar)
27
+ next unless value.kind_of?(Rubinius::AST::Node)
28
+ ToSource.to_source(value)
29
+ assert_entrypoints(value)
30
+ end
31
+ end
32
+
16
33
  shared_examples_for 'a source generation method' do
17
34
  it 'should create original source' do
18
- should eql(compress(expected_source))
35
+ assert_round_trip(compress(expected_source))
19
36
  end
20
37
 
21
- it 'should be able to round trip generated source also' do
22
- generated = subject
23
- ast = subject.to_ast
24
- second = described_class.run(ast)
25
- generated.should eql(second)
38
+ it 'should be able to use all wrapped nodes as entrypoints' do
39
+ assert_entrypoints(expected_source.to_ast)
26
40
  end
27
41
  end
28
42
 
@@ -45,6 +59,7 @@ describe ToSource::Visitor,'.run' do
45
59
  context 'simple' do
46
60
  assert_source <<-RUBY
47
61
  class TestClass
62
+
48
63
  end
49
64
  RUBY
50
65
  end
@@ -60,6 +75,7 @@ describe ToSource::Visitor,'.run' do
60
75
  context 'scoped' do
61
76
  assert_source <<-RUBY
62
77
  class SomeNameSpace::TestClass
78
+
63
79
  end
64
80
  RUBY
65
81
  end
@@ -67,6 +83,7 @@ describe ToSource::Visitor,'.run' do
67
83
  context 'deeply scoped' do
68
84
  assert_source <<-RUBY
69
85
  class Some::Name::Space::TestClass
86
+
70
87
  end
71
88
  RUBY
72
89
  end
@@ -74,6 +91,7 @@ describe ToSource::Visitor,'.run' do
74
91
  context 'with subclass' do
75
92
  assert_source <<-RUBY
76
93
  class TestClass < Object
94
+
77
95
  end
78
96
  RUBY
79
97
  end
@@ -81,6 +99,7 @@ describe ToSource::Visitor,'.run' do
81
99
  context 'with scoped superclass' do
82
100
  assert_source <<-RUBY
83
101
  class TestClass < SomeNameSpace::Object
102
+
84
103
  end
85
104
  RUBY
86
105
  end
@@ -98,6 +117,7 @@ describe ToSource::Visitor,'.run' do
98
117
  context 'toplevel' do
99
118
  assert_source <<-RUBY
100
119
  class ::TestClass
120
+
101
121
  end
102
122
  RUBY
103
123
  end
@@ -107,6 +127,7 @@ describe ToSource::Visitor,'.run' do
107
127
  context 'simple' do
108
128
  assert_source <<-RUBY
109
129
  module TestModule
130
+
110
131
  end
111
132
  RUBY
112
133
  end
@@ -114,6 +135,7 @@ describe ToSource::Visitor,'.run' do
114
135
  context 'scoped' do
115
136
  assert_source <<-RUBY
116
137
  module SomeNameSpace::TestModule
138
+
117
139
  end
118
140
  RUBY
119
141
  end
@@ -121,6 +143,7 @@ describe ToSource::Visitor,'.run' do
121
143
  context 'deeply scoped' do
122
144
  assert_source <<-RUBY
123
145
  module Some::Name::Space::TestModule
146
+
124
147
  end
125
148
  RUBY
126
149
  end
@@ -594,56 +617,62 @@ describe ToSource::Visitor,'.run' do
594
617
  context 'binary operators' do
595
618
  %w(+ - * / & | && || << >> == === != <= < <=> > >= =~ !~ ^ **).each do |operator|
596
619
  context "on literals #{operator}" do
597
- assert_source "((1) #{operator} (2))"
620
+ assert_source "(1) #{operator} (2)"
598
621
  end
599
622
 
600
623
  context "on self #{operator}" do
601
- assert_source "((self) #{operator} (b))"
624
+ assert_source "(self) #{operator} (b)"
602
625
  end
603
626
 
604
627
  context "on calls #{operator}" do
605
- assert_source "((a) #{operator} (b))"
628
+ assert_source "(a) #{operator} (b)"
606
629
  end
607
630
  end
608
631
 
609
632
  context 'binary operator and keywords' do
610
- assert_source '((a) || (break(foo)))'
633
+ assert_source '(a) || (break(foo))'
611
634
  end
612
635
 
613
636
  context 'nested binary operators' do
614
- assert_source '((a) || (((b) || (c))))'
637
+ assert_source '(a) || ((b) || (c))'
638
+ end
639
+ end
640
+
641
+ { :or => :'||', :and => :'&&' }.each do |word, symbol|
642
+ context "word form form equivalency of #{word} and #{symbol}" do
643
+ assert_converts "(a) #{symbol} (break(foo))", "a #{word} break foo"
615
644
  end
616
645
  end
617
646
 
618
647
  context 'expansion of shortcuts' do
619
648
  context 'on += operator' do
620
- assert_converts 'a = ((a) + (2))', 'a += 2'
649
+ assert_converts 'a = (a) + (2)', 'a += 2'
621
650
  end
622
651
 
623
652
  context 'on -= operator' do
624
- assert_converts 'a = ((a) - (2))', 'a -= 2'
653
+ assert_converts 'a = (a) - (2)', 'a -= 2'
625
654
  end
626
655
 
627
656
  context 'on **= operator' do
628
- assert_converts 'a = ((a) ** (2))', 'a **= 2'
657
+ assert_converts 'a = (a) ** (2)', 'a **= 2'
629
658
  end
630
659
 
631
660
  context 'on *= operator' do
632
- assert_converts 'a = ((a) * (2))', 'a *= 2'
661
+ assert_converts 'a = (a) * (2)', 'a *= 2'
633
662
  end
634
663
 
635
664
  context 'on /= operator' do
636
- assert_converts 'a = ((a) / (2))', 'a /= 2'
665
+ assert_converts 'a = (a) / (2)', 'a /= 2'
637
666
  end
638
667
  end
639
668
 
640
669
  context 'shortcuts' do
641
670
  context 'on &&= operator' do
642
- assert_source '(a &&= (b))'
671
+ assert_source 'a &&= (b)'
643
672
  end
644
673
 
645
674
  context 'on ||= operator' do
646
- assert_source '(a ||= (2))'
675
+ assert_source 'a ||= (2)'
647
676
  end
648
677
  end
649
678
 
@@ -854,9 +883,19 @@ describe ToSource::Visitor,'.run' do
854
883
  end
855
884
 
856
885
  context 'rescue' do
886
+ context 'as block' do
887
+ assert_source <<-RUBY
888
+ begin
889
+ foo
890
+ foo
891
+ rescue
892
+ bar
893
+ end
894
+ RUBY
895
+ end
857
896
  context 'without rescue condition' do
858
897
  assert_source <<-RUBY
859
- def foo
898
+ begin
860
899
  bar
861
900
  rescue
862
901
  baz
@@ -864,10 +903,22 @@ describe ToSource::Visitor,'.run' do
864
903
  RUBY
865
904
  end
866
905
 
906
+ context 'within a block' do
907
+ assert_source <<-RUBY
908
+ foo do
909
+ begin
910
+ bar
911
+ rescue
912
+ baz
913
+ end
914
+ end
915
+ RUBY
916
+ end
917
+
867
918
  context 'with rescue condition' do
868
919
  context 'without assignment' do
869
920
  assert_source <<-RUBY
870
- def foo
921
+ begin
871
922
  bar
872
923
  rescue SomeError
873
924
  baz
@@ -877,7 +928,7 @@ describe ToSource::Visitor,'.run' do
877
928
 
878
929
  context 'with assignment' do
879
930
  assert_source <<-RUBY
880
- def foo
931
+ begin
881
932
  bar
882
933
  rescue SomeError => exception
883
934
  baz
@@ -889,7 +940,7 @@ describe ToSource::Visitor,'.run' do
889
940
  context 'with multivalued rescue condition' do
890
941
  context 'without assignment' do
891
942
  assert_source <<-RUBY
892
- def foo
943
+ begin
893
944
  bar
894
945
  rescue SomeError, SomeOtherError
895
946
  baz
@@ -899,7 +950,7 @@ describe ToSource::Visitor,'.run' do
899
950
 
900
951
  context 'with assignment' do
901
952
  assert_source <<-RUBY
902
- def foo
953
+ begin
903
954
  bar
904
955
  rescue SomeError, SomeOther => exception
905
956
  baz
@@ -910,7 +961,7 @@ describe ToSource::Visitor,'.run' do
910
961
 
911
962
  context 'with multiple rescue conditions' do
912
963
  assert_source <<-RUBY
913
- def foo
964
+ begin
914
965
  foo
915
966
  rescue SomeError
916
967
  bar
@@ -923,7 +974,7 @@ describe ToSource::Visitor,'.run' do
923
974
  context 'with normal and splat condition' do
924
975
  context 'without assignment' do
925
976
  assert_source <<-RUBY
926
- def foo
977
+ begin
927
978
  bar
928
979
  rescue SomeError, *bar
929
980
  baz
@@ -933,7 +984,7 @@ describe ToSource::Visitor,'.run' do
933
984
 
934
985
  context 'with assignment' do
935
986
  assert_source <<-RUBY
936
- def foo
987
+ begin
937
988
  bar
938
989
  rescue SomeError, *bar => exception
939
990
  baz
@@ -945,7 +996,7 @@ describe ToSource::Visitor,'.run' do
945
996
  context 'with splat condition' do
946
997
  context 'without assignment' do
947
998
  assert_source <<-RUBY
948
- def foo
999
+ begin
949
1000
  bar
950
1001
  rescue *bar
951
1002
  baz
@@ -955,7 +1006,7 @@ describe ToSource::Visitor,'.run' do
955
1006
 
956
1007
  context 'with assignment' do
957
1008
  assert_source <<-RUBY
958
- def foo
1009
+ begin
959
1010
  bar
960
1011
  rescue *bar => exception
961
1012
  baz
@@ -971,7 +1022,7 @@ describe ToSource::Visitor,'.run' do
971
1022
 
972
1023
  context 'ensure' do
973
1024
  assert_source <<-RUBY
974
- def foo
1025
+ begin
975
1026
  bar
976
1027
  ensure
977
1028
  baz
@@ -981,7 +1032,7 @@ describe ToSource::Visitor,'.run' do
981
1032
 
982
1033
  context 'return' do
983
1034
  context 'with expression' do
984
- assert_source 'return 9'
1035
+ assert_source 'return(9)'
985
1036
  end
986
1037
 
987
1038
  context 'without expression' do