Sha256: b80cdf7b9e69651968e679c0de0891913a9687ce4a37f34d604c9ab1bfd64b26

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

input = rel(
  {:id => 1, :weight => 10.0},
  {:id => 2, :weight => 12.0},
  {:id => 3, :weight => 12.0}
)

(specify "rank should respect < by default",
  (rel_equal \
    (rel (tuple :id => 1, :weight => 10.0, :rank => 0),
         (tuple :id => 2, :weight => 12.0, :rank => 1),
         (tuple :id => 3, :weight => 12.0, :rank => 1)),
    (rank input, [:weight])))

(specify "rank should support a strict order",
  (rel_equal \
    (rel (tuple :id => 1, :weight => 10.0, :rank => 0),
         (tuple :id => 2, :weight => 12.0, :rank => 1),
         (tuple :id => 3, :weight => 12.0, :rank => 2)),
    (rank input, [:weight, :id])))
      
(specify "rank should support a reverse order",
  (rel_equal \
    (rel (tuple :id => 1, :weight => 10.0, :rank => 2),
         (tuple :id => 2, :weight => 12.0, :rank => 0),
         (tuple :id => 3, :weight => 12.0, :rank => 0)),
    (rank input, [[:weight, :desc]])))

(specify "rank should allow specifying a name",
  (rel_equal \
    (rel (tuple :id => 1, :weight => 10.0, :pos => 0),
         (tuple :id => 2, :weight => 12.0, :pos => 1),
         (tuple :id => 3, :weight => 12.0, :pos => 1)),
    (rank input, [:weight], :pos)))
      

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.9.3 spec/integration/semantics/test_rank.alf