Sha256: bfd28c635cd69339807cb12fb8a2654834fd0c0df1e39c2b786bc12761942d30

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

require 'spec_helper'
module Finitio
  describe Syntax, "attribute" do

    subject{
      Syntax.parse(input, root: "attribute")
    }

    describe 'compilation result' do
      let(:compiled){
        subject.compile(type_factory)
      }

      context 'a: .Integer' do
        let(:input){ 'a: .Integer' }

        it 'compiles to an Attribute' do
          compiled.should be_a(Attribute)
          compiled.name.should eq(:a)
          compiled.type.should be_a(BuiltinType)
          compiled.type.ruby_type.should be(Integer)
        end
      end
    end

    describe 'AST' do
      let(:ast){
        subject.to_ast
      }

      let(:input){ 'a: .Integer' }

      it{ ast.should eq([:attribute, "a", [:builtin_type, "Integer"]]) }
    end
    

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/syntax/nodes/test_attribute.rb
finitio-0.4.0 spec/unit/syntax/nodes/test_attribute.rb