Sha256: d1bd8556e1e36498c0423c462989b50f5a99b604fd5d1cd60e4acd629c46ae88
Contents?: true
Size: 1.58 KB
Versions: 4
Compression:
Stored size: 1.58 KB
Contents
require 'spec_helper' module Alf describe Tuple, '<=>' do let(:type) { Tuple[name: String, status: Integer] } let(:supertype){ Tuple[name: String, status: Numeric] } let(:subtype) { Tuple[name: String, status: Fixnum] } subject{ type <=> other } context 'on something else' do let(:other){ Integer } it{ should be_nil } end context 'on itself' do let(:other){ type } it{ should eq(0) } end context 'on same type' do let(:other){ Tuple[name: String, status: Integer] } it{ should eq(0) } end context 'on a sub type' do let(:other){ subtype } it{ should eq(1) } end context 'on a super type' do let(:other){ supertype } it{ should eq(-1) } end context 'the shortcuts' do it 'the > shortcut classifies correctly' do (supertype > supertype).should be_false (supertype > type).should be_true (supertype > subtype).should be_true end it 'the >= shortcut classifies correctly' do (supertype >= supertype).should be_true (supertype >= type).should be_true (supertype >= subtype).should be_true end it 'the < shortcut classifies correctly' do (supertype < supertype).should be_false (supertype < type).should be_false (supertype < subtype).should be_false end it 'the <= shortcut classifies correctly' do (supertype <= supertype).should be_true (supertype <= type).should be_false (supertype <= subtype).should be_false end end end end
Version data entries
4 entries across 4 versions & 1 rubygems