to_source 0.2.6 → 0.2.7

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.
@@ -1,7 +1,15 @@
1
+ # v0.2.7 2013-01-2
2
+
3
+ * [fixed] Emit super with blocks correctly
4
+
5
+ [Compare v0.2.6..v0.2.7](https://github.com/mbj/to_source/compare/v0.2.6...v0.2.7)
6
+
1
7
  # v0.2.6 2013-01-1
2
8
 
3
9
  * [fixed] Emit super vs super() correctly
4
10
 
11
+ [Compare v0.2.5..v0.2.6](https://github.com/mbj/to_source/compare/v0.2.5...v0.2.6)
12
+
5
13
  # v0.2.5 2012-12-14
6
14
 
7
15
  * [fixed] Emit unary operators correctly
@@ -11,6 +19,8 @@
11
19
  * [fixed] Emit nested binary operators correctly.
12
20
  * [fixed] Emit element reference on self correctly. self[foo].
13
21
 
22
+ [Compare v0.2.4..v0.2.5](https://github.com/mbj/to_source/compare/v0.2.4...v0.2.5)
23
+
14
24
  # v0.2.4 2012-12-07
15
25
 
16
26
  * [feature] Allow to emit pattern variables as root node
@@ -889,6 +889,9 @@ module ToSource
889
889
  #
890
890
  def z_super(node)
891
891
  emit('super')
892
+ if node.block
893
+ dispatch(node.block)
894
+ end
892
895
  end
893
896
 
894
897
  # Emit super
@@ -900,13 +903,12 @@ module ToSource
900
903
  # @api private
901
904
  #
902
905
  def super(node)
903
- z_super(node)
906
+ emit('super')
904
907
  # Stupid hack to ensure super() is emitted, this lib needs a redesign!
905
908
  arguments = node.arguments
906
- empty = arguments.array.empty? && !arguments.splat && !node.block.kind_of?(Rubinius::AST::BlockPass19)
907
- emit('(') if empty
909
+ empty = arguments.array.empty? && !arguments.splat && !node.block
910
+ emit('()') if empty
908
911
  arguments(node)
909
- emit(')') if empty
910
912
  end
911
913
 
912
914
  # Emit concat args
@@ -484,18 +484,50 @@ describe ToSource::Visitor,'.run' do
484
484
  assert_source 'super'
485
485
  end
486
486
 
487
+ context 'without arguments and block' do
488
+ assert_source <<-RUBY
489
+ super do
490
+ foo
491
+ end
492
+ RUBY
493
+ end
494
+
487
495
  context 'with explicit zero arguments' do
488
496
  assert_source 'super()'
489
497
  end
490
498
 
499
+ context 'with explicit zero arguments and block' do
500
+ assert_source <<-RUBY
501
+ super() do
502
+ foo
503
+ end
504
+ RUBY
505
+ end
506
+
491
507
  context 'with argument' do
492
508
  assert_source 'super(a)'
493
509
  end
494
510
 
511
+ context 'with argument and block' do
512
+ assert_source <<-RUBY
513
+ super(a) do
514
+ foo
515
+ end
516
+ RUBY
517
+ end
518
+
495
519
  context 'with arguments' do
496
520
  assert_source 'super(a, b)'
497
521
  end
498
522
 
523
+ context 'with arguments and block' do
524
+ assert_source <<-RUBY
525
+ super(a, b) do
526
+ foo
527
+ end
528
+ RUBY
529
+ end
530
+
499
531
  context 'with block argument' do
500
532
  assert_source 'super(&block)'
501
533
  end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'to_source'
4
- s.version = '0.2.6'
4
+ s.version = '0.2.7'
5
5
  s.authors = ['Josep M. Bach', 'Markus Schirp']
6
6
  s.email = ['josep.m.bach@gmail.com', 'mbj@seonic.net']
7
7
  s.homepage = 'http://github.com/txus/to_source'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: