File: comparators.rb

package info (click to toggle)
ruby-insist 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 204 kB
  • sloc: ruby: 378; makefile: 40; sh: 10
file content (41 lines) | stat: -rw-r--r-- 980 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

# Provides the '==' assertion method.
#
# Example:
#
#     insist { "foo" } == "foo"
module Insist::Comparators
  include Insist::Assert
  require "insist/comparators19" if RUBY_VERSION >= "1.9.2"

  # value == expected
  def ==(expected)
    assert(value == expected,
           "Expected #{expected.inspect}, but got #{value.inspect}")
  end # def ==

  # value <= expected
  def <=(expected)
    assert(value <= expected,
           "Expected #{value.inspect} <= #{expected.inspect}")
  end # def <=
 
  # value >= expected
  def >=(expected)
    assert(value >= expected,
           "Expected #{value.inspect} >= #{expected.inspect}")
  end # def >=

  # value > expected
  def >(expected)
    assert(value > expected,
           "Expected #{value.inspect} > #{expected.inspect}")
  end # def >

  # value < expected
  def <(expected)
    assert(value < expected,
           "Expected #{value.inspect} < #{expected.inspect}")
  end # def <
 
end # module Insist::Comparators