diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-01-06 14:22:11 -0200 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-01-06 14:22:11 -0200 |
commit | b0338475babfb8388691c8f6b0af674707a6a70e (patch) | |
tree | de75f21653caf477e4059db9ea50a1c12ec391a7 /test/nodes | |
parent | ffc4b8e93af4356110c7a2573cc3340145baa02b (diff) | |
parent | c22abda79b7f0fbee5f0ef0e9648d52d7d483902 (diff) | |
download | rails-b0338475babfb8388691c8f6b0af674707a6a70e.tar.gz rails-b0338475babfb8388691c8f6b0af674707a6a70e.tar.bz2 rails-b0338475babfb8388691c8f6b0af674707a6a70e.zip |
Merge pull request #408 from sjaveed/bitwise_operations
Support for Bitwise Operations as InfixOperations
Diffstat (limited to 'test/nodes')
-rw-r--r-- | test/nodes/test_unary_operation.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/nodes/test_unary_operation.rb b/test/nodes/test_unary_operation.rb new file mode 100644 index 0000000000..d89c10b431 --- /dev/null +++ b/test/nodes/test_unary_operation.rb @@ -0,0 +1,39 @@ +require 'helper' + +module Arel + module Nodes + class TestUnaryOperation < Minitest::Test + def test_construct + operation = UnaryOperation.new :-, 1 + assert_equal :-, operation.operator + assert_equal 1, operation.expr + end + + def test_operation_alias + operation = UnaryOperation.new :-, 1 + aliaz = operation.as('zomg') + assert_kind_of As, aliaz + assert_equal operation, aliaz.left + assert_equal 'zomg', aliaz.right + end + + def test_operation_ordering + operation = UnaryOperation.new :-, 1 + ordering = operation.desc + assert_kind_of Descending, ordering + assert_equal operation, ordering.expr + assert ordering.descending? + end + + def test_equality_with_same_ivars + array = [UnaryOperation.new(:-, 1), UnaryOperation.new(:-, 1)] + assert_equal 1, array.uniq.size + end + + def test_inequality_with_different_ivars + array = [UnaryOperation.new(:-, 1), UnaryOperation.new(:-, 2)] + assert_equal 2, array.uniq.size + end + end + end +end |