Sha256: 0c34a150f11ae5c005ed4623ab1e99d6823bb68c4266e90e7cc4ea3a324aab14

Contents?: true

Size: 973 Bytes

Versions: 6

Compression:

Stored size: 973 Bytes

Contents

# frozen_string_literal: true

require_relative '..\..\spec_helper'
require_relative '..\..\..\lib\dendroid\syntax\terminal'
require_relative '..\..\..\lib\dendroid\syntax\non_terminal'
require_relative '..\..\..\lib\dendroid\syntax\rule'

describe Dendroid::Syntax::Rule do
  let(:num_symb) { Dendroid::Syntax::Terminal.new('NUMBER') }
  let(:expr_symb) { Dendroid::Syntax::NonTerminal.new('expression') }

  subject { described_class.new(expr_symb) }

  context 'Initialization:' do
    it 'is initialized with a non-terminal' do
      expect { described_class.new(expr_symb) }.not_to raise_error
    end

    it 'knows its head (aka lhs)' do
      expect(subject.head).to eq(expr_symb)
    end
  end # context

  context 'Errors:' do
    it 'fails when initialized with a terminal' do
      msg = "Terminal symbol 'NUMBER' may not be on left-side of a rule."
      expect { described_class.new(num_symb) }.to raise_error(StandardError, msg)
    end
  end
end # describe

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dendroid-0.1.00 spec/dendroid/syntax/rule_spec.rb
dendroid-0.0.12 spec/dendroid/syntax/rule_spec.rb
dendroid-0.0.11 spec/dendroid/syntax/rule_spec.rb
dendroid-0.0.10 spec/dendroid/syntax/rule_spec.rb
dendroid-0.0.9 spec/dendroid/syntax/rule_spec.rb
dendroid-0.0.8 spec/dendroid/syntax/rule_spec.rb