Sha256: 4eb098b0211edf048144f9bf99841525c0717aebbc02b1f52af3d055f1b7ce3e

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'helper'

module Arel
  module Nodes
    class TestInfixOperation < Minitest::Test
      def test_construct
        operation = InfixOperation.new :+, 1, 2
        assert_equal :+, operation.operator
        assert_equal 1, operation.left
        assert_equal 2, operation.right
      end

      def test_operation_alias
        operation = InfixOperation.new :+, 1, 2
        aliaz = operation.as('zomg')
        assert_kind_of As, aliaz
        assert_equal operation, aliaz.left
        assert_equal 'zomg', aliaz.right
      end

      def test_opertaion_ordering
        operation = InfixOperation.new :+, 1, 2
        ordering = operation.desc
        assert_kind_of Descending, ordering
        assert_equal operation, ordering.expr
        assert ordering.descending?
      end

      def test_equality_with_same_ivars
        array = [InfixOperation.new(:+, 1, 2), InfixOperation.new(:+, 1, 2)]
        assert_equal 1, array.uniq.size
      end

      def test_inequality_with_different_ivars
        array = [InfixOperation.new(:+, 1, 2), InfixOperation.new(:+, 1, 3)]
        assert_equal 2, array.uniq.size
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_infix_operation.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_infix_operation.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_infix_operation.rb
arel-5.0.1.20140414130214 test/nodes/test_infix_operation.rb