Sha256: 77973423c702e8c0b642460872c25ae01d37396944432515485955834a25f194

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

require 'helper'

describe Temple::Filters::StaticAnalyzer do
  before do
    @filter = Temple::Filters::StaticAnalyzer.new
    @generator = Temple::Generator.new
  end

  if Temple::StaticAnalyzer.available?
    it 'should convert :dynamic to :static if code is static' do
      @filter.call([:dynamic, '"#{"hello"}#{100}"']
      ).should.equal [:static, 'hello100']
    end

    it 'should not convert :dynamic if code is dynamic' do
      exp = [:dynamic, '"#{hello}#{100}"']
      @filter.call(exp).should.equal(exp)
    end

    it 'should not change number of newlines in generated code' do
      exp = [:dynamic, "[100,\n200,\n]"]
      @filter.call(exp).should.equal([:multi, [:static, '[100, 200]'], [:newline], [:newline]])

      @generator.call(@filter.call(exp)).count("\n").
        should.equal(@generator.call(exp).count("\n"))
    end
  else
    it 'should do nothing' do
      [
        [:dynamic, '"#{"hello"}#{100}"'],
        [:dynamic, '"#{hello}#{100}"'],
      ].each do |exp|
        @filter.call(exp).should.equal(exp)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/filters/test_static_analyzer.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/filters/test_static_analyzer.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/filters/test_static_analyzer.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/temple-0.8.2/test/filters/test_static_analyzer.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/temple-0.8.2/test/filters/test_static_analyzer.rb
temple-0.9.0 test/filters/test_static_analyzer.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/temple-0.8.0/test/filters/test_static_analyzer.rb
temple-0.8.2 test/filters/test_static_analyzer.rb
temple-0.8.1 test/filters/test_static_analyzer.rb
temple-0.8.0 test/filters/test_static_analyzer.rb