Sha256: 02f10c47beacb64f6f6c12cb72a3612d637ced8361743b3610842a0d6fb39555
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
require 'spec_helper' module Alf module Operator::Relational describe Rank do let(:operator_class){ Rank } it_should_behave_like("An operator class") let(:input) {Alf::Relation[ {:pid => 'P1', :weight => 12.0}, {:pid => 'P2', :weight => 17.0}, {:pid => 'P3', :weight => 17.0}, {:pid => 'P4', :weight => 14.0}, {:pid => 'P5', :weight => 12.0}, {:pid => 'P6', :weight => 19.0} ]} subject{ operator.to_rel } describe "when a partial ordering is used" do let(:expected) {Alf::Relation[ {:pid => 'P1', :weight => 12.0, :rank => 0}, {:pid => 'P5', :weight => 12.0, :rank => 0}, {:pid => 'P4', :weight => 14.0, :rank => 2}, {:pid => 'P2', :weight => 17.0, :rank => 3}, {:pid => 'P3', :weight => 17.0, :rank => 3}, {:pid => 'P6', :weight => 19.0, :rank => 5} ]} let(:operator){ Rank.new([:weight]) } before{ operator.pipe(input) } it{ should eq(expected) } end describe "when a total ordering is used" do let(:expected) {Alf::Relation[ {:pid => 'P1', :weight => 12.0, :rank => 0}, {:pid => 'P5', :weight => 12.0, :rank => 1}, {:pid => 'P4', :weight => 14.0, :rank => 2}, {:pid => 'P2', :weight => 17.0, :rank => 3}, {:pid => 'P3', :weight => 17.0, :rank => 4}, {:pid => 'P6', :weight => 19.0, :rank => 5} ]} let(:operator){ Rank.new([:weight, :pid]) } before{ operator.pipe(input) } it{ should eq(expected) } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alf-0.10.1 | spec/unit/operator/relational/test_rank.rb |
alf-0.10.0 | spec/unit/operator/relational/test_rank.rb |
alf-0.9.3 | spec/unit/operator/relational/test_rank.rb |