Sha256: a31e884a491ad145b816570633602fcba85b5a587f238ec6beecc451d6d349d2

Contents?: true

Size: 896 Bytes

Versions: 19

Compression:

Stored size: 896 Bytes

Contents

require 'spec_helper'
module Finitio
  module Syntax
    describe Expr, "to_proc_source" do

      def source(src)
        Syntax.parse(src, { root: :expr, memoize: true }).to_proc_source
      end

      context "on literals" do

        it 'returns an empty array' do
          expect(source("true")).to eq("true")
        end
      end

      context "on a single identifier" do

        it 'works' do
          expect(source("foo")).to eq("foo")
        end
      end
        
      context "on a comparison" do

        it 'works' do
          expect(source("foo == bar")).to eq(%Q{foo.==(bar)})
        end
      end

      context "on a OO call" do

        it 'works' do
          expect(source("foo.bar")).to eq(%Q{foo.fetch(:bar)})
        end

        it 'works' do
          expect(source("foo.bar.baz")).to eq(%Q{foo.fetch(:bar).fetch(:baz)})
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.11.4 spec/syntax/expr/test_to_proc_source.rb
finitio-0.11.3 spec/syntax/expr/test_to_proc_source.rb
finitio-0.11.2 spec/syntax/expr/test_to_proc_source.rb
finitio-0.11.1 spec/syntax/expr/test_to_proc_source.rb
finitio-0.10.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.9.1 spec/syntax/expr/test_to_proc_source.rb
finitio-0.9.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.8.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.7.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.7.0.pre.rc4 spec/syntax/expr/test_to_proc_source.rb
finitio-0.7.0.pre.rc3 spec/syntax/expr/test_to_proc_source.rb
finitio-0.7.0.pre.rc2 spec/syntax/expr/test_to_proc_source.rb
finitio-0.7.0.pre.rc1 spec/syntax/expr/test_to_proc_source.rb
finitio-0.6.1 spec/syntax/expr/test_to_proc_source.rb
finitio-0.6.0 spec/syntax/expr/test_to_proc_source.rb
finitio-0.5.2 spec/syntax/expr/test_to_proc_source.rb
finitio-0.5.1 spec/syntax/expr/test_to_proc_source.rb
finitio-0.5.0 spec/syntax/expr/test_to_proc_source.rb