Sha256: 9e68e982a28dc93cbb19dc0b763ee475d3ec36b72d42cd7333b6495bf87c02df

Contents?: true

Size: 973 Bytes

Versions: 15

Compression:

Stored size: 973 Bytes

Contents

require 'spec_helper'
module WLang
  class Compiler
    describe StrconcatFlattener do

      def optimize(source)
        StrconcatFlattener.new.call(source)
      end

      it 'cleans singleton' do
        source   = [:strconcat, [:static, "Hello World!"]]
        expected = [:static, "Hello World!"]
        optimize(source).should eq(expected)
      end

      it 'does nothing on single :strconcat' do
        source   = [:strconcat, [:static, "Hello "], [:static, "World"]]
        expected = [:strconcat, [:static, "Hello "], [:static, "World"]]
        optimize(source).should eq(expected)
      end

      it 'flattens :strconcat' do
        source   = [:strconcat, [:strconcat, [:static, "Hello "], [:static, "World"]], [:static, "!"]]
        expected = [:strconcat, [:static, "Hello "], [:static, "World"], [:static, "!"]]
        optimize(source).should eq(expected)
      end

    end # describe StrconcatFlattener
  end # class Compiler
end # module WLang

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wlang-3.0.1 spec/unit/compiler/test_strconcat_flattener.rb
wlang-3.0.0 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.3.1 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.3.0 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.2.4 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.2.3 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.2.2 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.2.1 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.2.0 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.1.2 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.1.1 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.1.0 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.0.1 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.0.0 spec/unit/compiler/test_strconcat_flattener.rb
wlang-2.0.0.beta spec/unit/compiler/test_strconcat_flattener.rb