Sha256: ab19ed6911a861ac811a5962faa56ef2a79e327ba17fdba81bc78ecb1192f82c
Contents?: true
Size: 805 Bytes
Versions: 4
Compression:
Stored size: 805 Bytes
Contents
require 'spec_helper' require 'dentaku/ast/arithmetic' require 'dentaku/token' describe Dentaku::AST::Addition do let(:five) { Dentaku::AST::Logical.new Dentaku::Token.new(:numeric, 5) } let(:six) { Dentaku::AST::Logical.new Dentaku::Token.new(:numeric, 6) } let(:t) { Dentaku::AST::Numeric.new Dentaku::Token.new(:logical, true) } it 'performs addition' do node = described_class.new(five, six) expect(node.value).to eq 11 end it 'requires numeric operands' do expect { described_class.new(five, t) }.to raise_error(RuntimeError, /requires numeric operands/) expression = Dentaku::AST::Multiplication.new(five, five) group = Dentaku::AST::Grouping.new(expression) expect { described_class.new(group, five) }.not_to raise_error end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dentaku-2.0.6 | spec/ast/addition_spec.rb |
dentaku-2.0.5 | spec/ast/addition_spec.rb |
dentaku-2.0.4 | spec/ast/addition_spec.rb |
dentaku-2.0.3 | spec/ast/addition_spec.rb |