File: eql.rb

package info (click to toggle)
ruby-morpher 0.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: ruby: 2,366; makefile: 4
file content (50 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
module Morpher
  class Evaluator
    class Predicate
      # Binary equal evaluator
      class EQL < self
        include Binary

        register :eql

        # Call evaluator
        #
        # @param [Object] input
        #
        # @return [true]
        #   if input is semantically equivalent to expectation
        #
        # @return [false]
        #   otherwise
        #
        # @api private
        #
        def call(input)
          left.call(input).eql?(right.call(input))
        end

        # Return evaluation
        #
        # @param [Object] input
        #
        # @return [Evaluation]
        #
        # @api private
        #
        def evaluation(input)
          left_evaluation  = left.evaluation(input)
          right_evaluation = right.evaluation(input)

          Evaluation::Binary.success(
            evaluator: self,
            input: input,
            output: left_evaluation.output.eql?(right_evaluation.output),
            left_evaluation: left_evaluation,
            right_evaluation: right_evaluation
          )
        end

      end # EQL
    end # Predicate
  end # Evaluator
end # Morpher