Sha256: acacd4057bb6d0a2edd313df6e022ecd5b36bfe5a4e886d340f11ce043f5a58c
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Function::Binary, '#type' do subject { object.type } let(:object) { described_class.new(*operands) } let(:described_class) { Class.new(Function::Numeric) } let(:operands) do types.map { |type| double(type: type, frozen?: true) } end before do described_class.class_eval { include Function::Binary } end context 'when the operands are from the same class' do let(:types) { [Types::Integer, Types::Integer] } it { should be(Types::Integer) } end context 'when the operands are sibling classes' do let(:types) { [Types::Integer, Types::Float] } it { should be(Types::Numeric) } end context 'when the operands are parent and child' do let(:types) { [Types::Numeric, Types::Integer] } it { should be(Types::Numeric) } end context 'when the operands are not related' do let(:types) { [Types::String, Types::Integer] } it { should be_nil } end context 'when an operand is a primitive' do let(:operands) do [ double(type: Types::Integer, frozen?: true), 1, ] end it { should be(Types::Integer) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axiom-0.1.1 | spec/unit/axiom/function/binary/type_spec.rb |