Sha256: 8f396e670b1537ec96d048f166b43bc4d5d5f06caff9d663ec2ddbdaa561aeb6

Contents?: true

Size: 883 Bytes

Versions: 13

Compression:

Stored size: 883 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/combinators'

require 'dentaku/token'

describe Dentaku::AST::And do
  let(:t) { Dentaku::AST::Logical.new Dentaku::Token.new(:logical, true)  }
  let(:f) { Dentaku::AST::Logical.new Dentaku::Token.new(:logical, false) }

  let(:five) { Dentaku::AST::Numeric.new Dentaku::Token.new(:numeric, 5) }

  it 'performs logical AND' do
    node = described_class.new(t, f)
    expect(node.value).to eq(false)
  end

  it 'requires logical operands' do
    expect {
      described_class.new(t, five)
    }.to raise_error(Dentaku::NodeError, /requires logical operands/)

    expression = Dentaku::AST::LessThanOrEqual.new(five, five)
    expect {
      described_class.new(t, expression)
    }.not_to raise_error

    expression = Dentaku::AST::Or.new(t, f)
    expect {
      described_class.new(t, expression)
    }.not_to raise_error
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
dentaku-3.5.4 spec/ast/and_spec.rb
dentaku-3.5.3 spec/ast/and_spec.rb
dentaku-3.5.2 spec/ast/and_spec.rb
dentaku_zevo-3.5.2 spec/ast/and_spec.rb
dentaku-3.5.1 spec/ast/and_spec.rb
dentaku-3.5.0 spec/ast/and_spec.rb
dentaku-3.4.2 spec/ast/and_spec.rb
dentaku-3.4.1 spec/ast/and_spec.rb
dentaku-3.4.0 spec/ast/and_spec.rb
dentaku-3.3.4 spec/ast/and_spec.rb
dentaku-3.3.3 spec/ast/and_spec.rb
dentaku-3.3.2 spec/ast/and_spec.rb
dentaku-3.3.1 spec/ast/and_spec.rb