Sha256: a15229b42f9de7056bf88cc09267a89733f45442e3f30c03c687a10f12062381

Contents?: true

Size: 897 Bytes

Versions: 19

Compression:

Stored size: 897 Bytes

Contents

require 'lib/spec_helper'
require 'support/rewriters_helper'
require 'opal/rewriters/numblocks'

RSpec.describe Opal::Rewriters::Numblocks do
  include RewritersHelper
  extend RewritersHelper # s() in example scope

  correct_names = proc do |ast|
    case ast
    when Opal::AST::Node
      ast.children.map do |i|
        correct_names.(i)
      end.yield_self { |children| s(ast.type, *children) }
    when :arg1 then :_1
    when :arg2 then :_2
    when :arg3 then :_3
    else
      ast
    end
  end

  include_examples 'it rewrites source-to-AST', <<~ENDSOURCE, correct_names.(ast_of(<<~ENDDEST))
    proc do
      _1
    end
  ENDSOURCE
    proc do |arg1|
      arg1
    end
  ENDDEST

  include_examples 'it rewrites source-to-AST', <<~ENDSOURCE, correct_names.(ast_of(<<~ENDDEST))
    proc do
      _3
    end
  ENDSOURCE
    proc do |arg1, arg2, arg3|
      arg3
    end
  ENDDEST
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/lib/rewriters/numblocks_spec.rb
opal-1.8.2 spec/lib/rewriters/numblocks_spec.rb
opal-1.8.1 spec/lib/rewriters/numblocks_spec.rb
opal-1.8.0 spec/lib/rewriters/numblocks_spec.rb
opal-1.8.0.beta1 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.4 spec/lib/rewriters/numblocks_spec.rb
opal-1.8.0.alpha1 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.3 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.2 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.1 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.0 spec/lib/rewriters/numblocks_spec.rb
opal-1.7.0.rc1 spec/lib/rewriters/numblocks_spec.rb
opal-1.6.1 spec/lib/rewriters/numblocks_spec.rb
opal-1.6.0 spec/lib/rewriters/numblocks_spec.rb
opal-1.6.0.rc1 spec/lib/rewriters/numblocks_spec.rb
opal-1.6.0.alpha1 spec/lib/rewriters/numblocks_spec.rb
opal-1.5.1 spec/lib/rewriters/numblocks_spec.rb
opal-1.5.0 spec/lib/rewriters/numblocks_spec.rb
opal-1.5.0.rc1 spec/lib/rewriters/numblocks_spec.rb