Sha256: 222b8b4410ff9969ab02b963322792db1992fc284161bf5d797cbdb6206a9325

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

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

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

    let(:ast){
      subject.to_ast
    }

    context 'with definitions and a type' do
      let(:input){ "Int = .Integer\n{r: Int}" }

      it 'has the expected AST' do
        ast.should eq([
          :system,
          [:type_def, "Int", [:builtin_type, "Integer"]],
          [:tuple_type, [:heading, [:attribute, "r", [:type_ref, "Int"]]]]
        ])
      end
    end

    context 'with definitions only' do
      let(:input){ "Int = .Integer" }

      it 'has the expected AST' do
        ast.should eq([
          :system,
          [:type_def, "Int", [:builtin_type, "Integer"]]
        ])
      end
    end

    context 'with a type only' do
      let(:input){ "{r: .Integer}" }

      it 'has the expected AST' do
        ast.should eq([
          :system,
          [:tuple_type, [:heading, [:attribute, "r", [:builtin_type, "Integer"]]]]
        ])
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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