veritas-optimizer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.rvmrc +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +20 -10
- data/Guardfile +22 -0
- data/README.rdoc +2 -0
- data/Rakefile +4 -2
- data/TODO +43 -2
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/roodi.yml +4 -4
- data/lib/veritas/optimizer/aggregate/count.rb +17 -0
- data/lib/veritas/optimizer/aggregate/maximum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/mean.rb +17 -0
- data/lib/veritas/optimizer/aggregate/minimum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/standard_deviation.rb +17 -0
- data/lib/veritas/optimizer/aggregate/sum.rb +17 -0
- data/lib/veritas/optimizer/aggregate/variance.rb +17 -0
- data/lib/veritas/optimizer/aggregate.rb +16 -0
- data/lib/veritas/optimizer/algebra/difference.rb +3 -1
- data/lib/veritas/optimizer/algebra/extension.rb +58 -3
- data/lib/veritas/optimizer/algebra/intersection.rb +3 -1
- data/lib/veritas/optimizer/algebra/join.rb +6 -4
- data/lib/veritas/optimizer/algebra/product.rb +3 -1
- data/lib/veritas/optimizer/algebra/projection.rb +23 -54
- data/lib/veritas/optimizer/algebra/rename.rb +55 -80
- data/lib/veritas/optimizer/algebra/restriction.rb +33 -66
- data/lib/veritas/optimizer/algebra/summarization.rb +161 -3
- data/lib/veritas/optimizer/algebra/union.rb +3 -1
- data/lib/veritas/optimizer/function/binary.rb +124 -0
- data/lib/veritas/optimizer/{logic → function}/connective/binary.rb +48 -102
- data/lib/veritas/optimizer/{logic → function}/connective/conjunction.rb +12 -11
- data/lib/veritas/optimizer/{logic → function}/connective/disjunction.rb +15 -14
- data/lib/veritas/optimizer/function/connective/negation.rb +65 -0
- data/lib/veritas/optimizer/function/numeric/absolute.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/addition.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/division.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/exponentiation.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/modulo.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/multiplication.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/square_root.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/subtraction.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/unary_minus.rb +20 -0
- data/lib/veritas/optimizer/function/numeric/unary_plus.rb +20 -0
- data/lib/veritas/optimizer/function/numeric.rb +34 -0
- data/lib/veritas/optimizer/{logic → function}/predicate/comparable.rb +6 -4
- data/lib/veritas/optimizer/{logic → function}/predicate/enumerable.rb +24 -26
- data/lib/veritas/optimizer/{logic → function}/predicate/equality.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/exclusion.rb +6 -16
- data/lib/veritas/optimizer/{logic → function}/predicate/greater_than.rb +6 -5
- data/lib/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/inclusion.rb +6 -16
- data/lib/veritas/optimizer/{logic → function}/predicate/inequality.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/less_than.rb +6 -5
- data/lib/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to.rb +6 -6
- data/lib/veritas/optimizer/{logic → function}/predicate/match.rb +5 -4
- data/lib/veritas/optimizer/{logic → function}/predicate/no_match.rb +5 -4
- data/lib/veritas/optimizer/function/predicate.rb +61 -0
- data/lib/veritas/optimizer/function/string/length.rb +31 -0
- data/lib/veritas/optimizer/function/unary.rb +86 -0
- data/lib/veritas/optimizer/function.rb +87 -0
- data/lib/veritas/optimizer/optimizable.rb +6 -3
- data/lib/veritas/optimizer/relation/operation/binary.rb +36 -70
- data/lib/veritas/optimizer/relation/operation/limit.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/offset.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/order.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/reverse.rb +1 -9
- data/lib/veritas/optimizer/relation/operation/unary.rb +50 -13
- data/lib/veritas/optimizer/version.rb +1 -1
- data/lib/veritas/optimizer.rb +43 -16
- data/spec/integration/veritas/algebra/difference/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/intersection/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/join/optimize_spec.rb +4 -2
- data/spec/integration/veritas/algebra/product/optimize_spec.rb +2 -0
- data/spec/integration/veritas/algebra/projection/optimize_spec.rb +6 -4
- data/spec/integration/veritas/algebra/rename/optimize_spec.rb +2 -0
- data/spec/integration/veritas/algebra/restriction/optimize_spec.rb +9 -7
- data/spec/integration/veritas/algebra/summarization/optimize_spec.rb +49 -0
- data/spec/integration/veritas/algebra/union/optimize_spec.rb +6 -4
- data/spec/integration/veritas/{logic → function}/connective/conjunction/optimize_spec.rb +33 -31
- data/spec/integration/veritas/{logic → function}/connective/disjunction/optimize_spec.rb +30 -28
- data/spec/integration/veritas/{logic → function}/connective/negation/optimize_spec.rb +7 -5
- data/spec/integration/veritas/{logic/expression → function}/optimize_spec.rb +5 -3
- data/spec/integration/veritas/{logic → function}/predicate/equality/optimize_spec.rb +9 -7
- data/spec/integration/veritas/{logic → function}/predicate/exclusion/optimize_spec.rb +13 -11
- data/spec/integration/veritas/{logic → function}/predicate/greater_than/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/greater_than_or_equal_to/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/inclusion/optimize_spec.rb +13 -11
- data/spec/integration/veritas/{logic → function}/predicate/inequality/optimize_spec.rb +9 -7
- data/spec/integration/veritas/{logic → function}/predicate/less_than/optimize_spec.rb +17 -15
- data/spec/integration/veritas/{logic → function}/predicate/less_than_or_equal_to/optimize_spec.rb +17 -15
- data/spec/integration/veritas/relation/empty/optimize_spec.rb +2 -0
- data/spec/integration/veritas/relation/materialized/optimize_spec.rb +2 -0
- data/spec/integration/veritas/relation/operation/limit/optimize_spec.rb +3 -1
- data/spec/integration/veritas/relation/operation/offset/optimize_spec.rb +3 -1
- data/spec/integration/veritas/relation/operation/order/optimize_spec.rb +4 -2
- data/spec/integration/veritas/relation/operation/reverse/optimize_spec.rb +4 -2
- data/spec/integration/veritas/relation/optimize_spec.rb +2 -0
- data/spec/shared/{logic_connective_binary_optimize_behavior.rb → function_connective_binary_optimize_behavior.rb} +14 -12
- data/spec/shared/idempotent_method_behavior.rb +2 -0
- data/spec/shared/optimize_method_behavior.rb +2 -0
- data/spec/support/add_method_missing.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/difference/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/extension/extensions_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/extension/order_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimizable_spec.rb +18 -8
- data/spec/unit/veritas/optimizer/algebra/extension/unoptimized_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/intersection/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/join/equal_headers/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/product/table_dee_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/projection_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/projection/{set_operand → union_operand}/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/projection/unoptimized_operand/optimize_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/algebra/rename/aliases_spec.rb +5 -13
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/offset_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/order_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimizable_spec.rb +17 -7
- data/spec/unit/veritas/optimizer/algebra/rename/projection_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/rename_operand_and_empty_aliases/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/rename/restriction_operand/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/reverse_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/set_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimizable_spec.rb +7 -20
- data/spec/unit/veritas/optimizer/algebra/rename/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimizable_spec.rb +23 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/contradiction/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/order_operand/optimize_spec.rb +7 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/predicate_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimizable_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/restriction_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/algebra/restriction/set_operand/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimizable_spec.rb +11 -3
- data/spec/unit/veritas/optimizer/algebra/restriction/tautology/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimizable_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/algebra/restriction/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/class_methods/extension_default_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimizable_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_operand/optimize_spec.rb +47 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimizable_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/empty_summarize_per/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/order_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/summarize_per_spec.rb +29 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/summarizers_spec.rb +31 -0
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimizable_spec.rb +30 -8
- data/spec/unit/veritas/optimizer/algebra/summarization/unoptimized_operand/optimize_spec.rb +12 -9
- data/spec/unit/veritas/optimizer/algebra/union/empty_left/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/union/empty_right/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/algebra/union/equal_operands/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/class_methods/chain_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimizable_spec.rb +36 -0
- data/spec/unit/veritas/optimizer/function/binary/constant_operands/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/binary/left_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/binary/right_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimizable_spec.rb +37 -0
- data/spec/unit/veritas/optimizer/function/binary/unoptimized_operands/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/function/class_methods/optimize_functions_spec.rb +26 -0
- data/spec/unit/veritas/optimizer/function/class_methods/optimize_operand_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/function/connective/binary/constant_operands/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/equal_operands/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/left_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_left_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/redundant_right_operand/optimize_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/binary/right_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimizable_spec.rb +64 -0
- data/spec/unit/veritas/optimizer/function/connective/conjunction/contradiction/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/{logic/connective/disjunction/contradiction_left_operand → function/connective/conjunction/left_operand_tautology}/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/left_operand_tautology/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/optimizable_to_exclusion/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/{logic → function}/connective/conjunction/right_operand_tautology/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/function/connective/conjunction/right_operand_tautology/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/{logic/connective/conjunction/left_operand_tautology → function/connective/disjunction/contradiction_left_operand}/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_left_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/contradiction_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/connective/disjunction/optimizable_to_inclusion/optimize_spec.rb +5 -3
- data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimizable_spec.rb +64 -0
- data/spec/unit/veritas/optimizer/function/connective/disjunction/tautology/optimize_spec.rb +19 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/constant_operand/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimize_spec.rb +22 -0
- data/spec/unit/veritas/optimizer/{logic → function}/connective/negation/operand_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_comparable/optimizable_spec.rb +23 -7
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/never_equivalent/optimizable_spec.rb +23 -7
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimizable_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/comparable/normalizable_operands/optimize_spec.rb +7 -5
- data/spec/unit/veritas/optimizer/function/predicate/constant_operands/optimize_spec.rb +16 -0
- data/spec/unit/veritas/optimizer/function/predicate/contradiction/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/predicate/enumerable/class_methods/sort_by_value_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/empty_right_operand/optimizable_spec.rb +6 -4
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/enumerable/one_right_operand/optimizable_spec.rb +9 -7
- data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic/predicate/enumerable/unoptimized_operand → function/predicate/enumerable/unoptimized_operands}/optimize_spec.rb +18 -5
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/equality/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/empty_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/exclusion/one_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/greater_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/empty_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inclusion/one_right_operand/optimize_spec.rb +8 -6
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/inequality/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/contradiction/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic → function}/predicate/less_than_or_equal_to/tautology/optimizable_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/function/predicate/tautology/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/constant_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/function/unary/operand_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimizable_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/unary/unoptimized_operand/optimize_spec.rb +18 -0
- data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/attribute_spec.rb +4 -2
- data/spec/unit/veritas/optimizer/{logic/predicate → function}/util/class_methods/constant_spec.rb +13 -5
- data/spec/unit/veritas/optimizer/function/util/class_methods/max_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/function/util/class_methods/min_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/operation_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimizable/class_methods/optimizer_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimizable/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/materialized/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_left/optimizable_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/empty_right/optimizable_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/equal_operands/optimizable_spec.rb +2 -5
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_order_operand/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/left_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/materialized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimizable_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_order_operand/optimize_spec.rb +23 -0
- data/spec/unit/veritas/optimizer/relation/operation/binary/right_spec.rb +2 -4
- data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimizable_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/binary/{unoptimized_operand → unoptimized_operands}/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/combination/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/equal_limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/limit/zero_limit/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/offset_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/offset/zero_offset/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/one_limit_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/order_operand/optimize_spec.rb +3 -1
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/order/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/order_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/reverse_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimizable_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/reverse/unoptimized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimizable_spec.rb +5 -2
- data/spec/unit/veritas/optimizer/relation/operation/unary/empty_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/header_spec.rb +15 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimizable_spec.rb +5 -2
- data/spec/unit/veritas/optimizer/relation/operation/unary/materialized_operand/optimize_spec.rb +2 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/operand_spec.rb +8 -5
- data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimizable_spec.rb +28 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/order_operand/optimize_spec.rb +27 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimizable_spec.rb +24 -0
- data/spec/unit/veritas/optimizer/relation/operation/unary/unchanged_header/optimize_spec.rb +14 -0
- data/tasks/metrics/ci.rake +7 -0
- data/tasks/{quality → metrics}/flay.rake +0 -0
- data/tasks/{quality → metrics}/flog.rake +0 -0
- data/tasks/{quality → metrics}/heckle.rake +1 -0
- data/tasks/{quality → metrics}/metric_fu.rake +3 -0
- data/tasks/{quality → metrics}/reek.rake +0 -0
- data/tasks/{quality → metrics}/roodi.rake +0 -0
- data/tasks/{quality → metrics}/yardstick.rake +0 -0
- data/tasks/spec.rake +1 -0
- data/veritas-optimizer.gemspec +183 -352
- metadata +232 -357
- data/lib/veritas/optimizer/logic/connective/negation.rb +0 -71
- data/lib/veritas/optimizer/logic/predicate.rb +0 -177
- data/spec/unit/veritas/optimizer/algebra/projection/header_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/projection/unchanged_header/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/rename/class_methods/union_aliases_spec.rb +0 -27
- data/spec/unit/veritas/optimizer/algebra/rename/header_spec.rb +0 -19
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/rename/unchanged_header/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/algebra/restriction/class_methods/optimize_predicate_spec.rb +0 -31
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/algebra/restriction/reverse_operand/optimize_spec.rb +0 -18
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimizable_spec.rb +0 -34
- data/spec/unit/veritas/optimizer/logic/connective/binary/unoptimized_operand/optimize_spec.rb +0 -21
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimizable_spec.rb +0 -41
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/contradiction/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/conjunction/right_operand_tautology/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimizable_spec.rb +0 -41
- data/spec/unit/veritas/optimizer/logic/connective/disjunction/tautology/optimize_spec.rb +0 -17
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimizable_spec.rb +0 -26
- data/spec/unit/veritas/optimizer/logic/connective/negation/invertible_operand/optimize_spec.rb +0 -20
- data/spec/unit/veritas/optimizer/logic/predicate/class_methods/optimize_operand_spec.rb +0 -20
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimizable_spec.rb +0 -29
- data/spec/unit/veritas/optimizer/logic/predicate/constant_operands/optimize_spec.rb +0 -14
- data/spec/unit/veritas/optimizer/logic/predicate/contradiction/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/logic/predicate/left_spec.rb +0 -25
- data/spec/unit/veritas/optimizer/logic/predicate/right_spec.rb +0 -25
- data/spec/unit/veritas/optimizer/logic/predicate/tautology/optimize_spec.rb +0 -16
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/max_spec.rb +0 -19
- data/spec/unit/veritas/optimizer/logic/predicate/util/class_methods/min_spec.rb +0 -19
- data/tasks/quality/ci.rake +0 -2
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Connective::Disjunction::Tautology, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:left) { Function::Proposition::Tautology.instance }
|
10
|
+
let(:right) { Function::Proposition::Tautology.instance }
|
11
|
+
let(:connective) { Function::Connective::Disjunction.new(left, right) }
|
12
|
+
let(:object) { described_class.new(connective) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
object.should be_optimizable
|
16
|
+
end
|
17
|
+
|
18
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
19
|
+
end
|
data/spec/unit/veritas/optimizer/function/connective/negation/constant_operand/optimize_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Connective::Negation::ConstantOperand, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:negation) { Function::Connective::Negation.new(false) }
|
9
|
+
let(:object) { described_class.new(negation) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
object.should be_optimizable
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
16
|
+
end
|
data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimizable_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Connective::Negation::InvertibleOperand, '#optimizable?' do
|
6
|
+
subject { object.optimizable? }
|
7
|
+
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:negation) { Function::Connective::Negation.new(operand) }
|
10
|
+
let(:object) { described_class.new(negation) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
object.operation.should be_kind_of(Function::Connective::Negation)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when operand is invertible' do
|
17
|
+
let(:operand) { attribute.eq(1) }
|
18
|
+
|
19
|
+
it { should be(true) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when operand is not invertible' do
|
23
|
+
let(:operand) { proc { true } }
|
24
|
+
|
25
|
+
it { should be(false) }
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/unit/veritas/optimizer/function/connective/negation/invertible_operand/optimize_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Connective::Negation::InvertibleOperand, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:operand) { attribute.eq(1) }
|
10
|
+
let(:negation) { Function::Connective::Negation.new(operand) }
|
11
|
+
let(:object) { described_class.new(negation) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
object.should be_optimizable
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
18
|
+
|
19
|
+
its(:left) { should equal(attribute) }
|
20
|
+
|
21
|
+
its(:right) { should == 1 }
|
22
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Connective::Negation, '#operand' do
|
4
6
|
subject { object.operand }
|
5
7
|
|
6
8
|
let(:optimized_operand) { mock('Optimized Operand') }
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Comparable::NeverComparable, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:described_class) { Class.new(Optimizer::
|
7
|
-
let(:attribute) { Attribute::Integer.new(:id)
|
8
|
-
let(:predicate) {
|
9
|
-
let(:object) { described_class.new(predicate)
|
8
|
+
let(:described_class) { Class.new(Optimizer::Function::Predicate) }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:predicate) { Function::Predicate::Equality.new(left, right) }
|
11
|
+
let(:object) { described_class.new(predicate) }
|
10
12
|
|
11
13
|
before do
|
12
|
-
described_class.class_eval { include Optimizer::
|
14
|
+
described_class.class_eval { include Optimizer::Function::Predicate::Comparable::NeverComparable }
|
13
15
|
|
14
|
-
predicate.should be_kind_of(
|
16
|
+
predicate.should be_kind_of(Function::Predicate::Comparable)
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'when left is a constant and is valid' do
|
@@ -55,4 +57,18 @@ describe Optimizer::Logic::Predicate::Comparable::NeverComparable, '#optimizable
|
|
55
57
|
|
56
58
|
it { should be(true) }
|
57
59
|
end
|
60
|
+
|
61
|
+
context 'when left is nil' do
|
62
|
+
let(:left) { nil }
|
63
|
+
let(:right) { attribute }
|
64
|
+
|
65
|
+
it { should be(true) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when right is nil' do
|
69
|
+
let(:left) { attribute }
|
70
|
+
let(:right) { nil }
|
71
|
+
|
72
|
+
it { should be(true) }
|
73
|
+
end
|
58
74
|
end
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Comparable::NeverEquivalent, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:described_class) { Class.new(Optimizer::
|
7
|
-
let(:attribute) { Attribute::Integer.new(:id, :size => 1..10)
|
8
|
-
let(:predicate) {
|
9
|
-
let(:object) { described_class.new(predicate)
|
8
|
+
let(:described_class) { Class.new(Optimizer::Function::Predicate) }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id, :size => 1..10) }
|
10
|
+
let(:predicate) { Function::Predicate::Equality.new(left, right) }
|
11
|
+
let(:object) { described_class.new(predicate) }
|
10
12
|
|
11
13
|
before do
|
12
|
-
described_class.class_eval { include Optimizer::
|
14
|
+
described_class.class_eval { include Optimizer::Function::Predicate::Comparable::NeverEquivalent }
|
13
15
|
|
14
|
-
predicate.should be_kind_of(
|
16
|
+
predicate.should be_kind_of(Function::Predicate::Comparable)
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'when left is a constant and is valid' do
|
@@ -55,4 +57,18 @@ describe Optimizer::Logic::Predicate::Comparable::NeverEquivalent, '#optimizable
|
|
55
57
|
|
56
58
|
it { should be(true) }
|
57
59
|
end
|
60
|
+
|
61
|
+
context 'when left is nil' do
|
62
|
+
let(:left) { nil }
|
63
|
+
let(:right) { attribute }
|
64
|
+
|
65
|
+
it { should be(true) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when right is nil' do
|
69
|
+
let(:left) { attribute }
|
70
|
+
let(:right) { nil }
|
71
|
+
|
72
|
+
it { should be(true) }
|
73
|
+
end
|
58
74
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Comparable::NormalizableOperands, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:attribute) { Attribute::Integer.new(:id)
|
7
|
-
let(:predicate) {
|
8
|
-
let(:object) { described_class.new(predicate)
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:predicate) { Function::Predicate::Equality.new(left, right) }
|
10
|
+
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::Comparable)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when left and right is a constant' do
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Comparable::NormalizableOperands, '#optimize' do
|
4
6
|
subject { object.optimize }
|
5
7
|
|
6
|
-
let(:attribute) { Attribute::Integer.new(:id)
|
7
|
-
let(:predicate) {
|
8
|
-
let(:object) { described_class.new(predicate)
|
8
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
9
|
+
let(:predicate) { Function::Predicate::Equality.new(1, attribute) }
|
10
|
+
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
13
|
object.should be_optimizable
|
12
14
|
end
|
13
15
|
|
14
|
-
it { should be_kind_of(
|
16
|
+
it { should be_kind_of(Function::Predicate::Equality) }
|
15
17
|
|
16
18
|
its(:left) { should equal(attribute) }
|
17
19
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Predicate::ConstantOperands, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:predicate) { Function::Predicate::Equality.new(1, 1) }
|
9
|
+
let(:object) { described_class.new(predicate) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
object.should be_optimizable
|
13
|
+
end
|
14
|
+
|
15
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Predicate::Contradiction, '#optimize' do
|
6
|
+
subject { object.optimize }
|
7
|
+
|
8
|
+
let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary } }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:predicate) { Function::Predicate::Inequality.new(attribute, attribute) }
|
11
|
+
let(:object) { described_class.new(predicate) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
described_class.class_eval { include Optimizer::Function::Predicate::Contradiction }
|
15
|
+
end
|
16
|
+
|
17
|
+
it { should equal(Function::Proposition::Contradiction.instance) }
|
18
|
+
end
|
data/spec/unit/veritas/optimizer/function/predicate/enumerable/class_methods/sort_by_value_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Optimizer::Function::Predicate::Enumerable, '.sort_by_value' do
|
6
|
+
subject { object.sort_by_value(value) }
|
7
|
+
|
8
|
+
let(:object) { self.class.described_type }
|
9
|
+
|
10
|
+
context 'when the value is true' do
|
11
|
+
let(:value) { true }
|
12
|
+
|
13
|
+
it { should eql(1) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when the value is false' do
|
17
|
+
let(:value) { false }
|
18
|
+
|
19
|
+
it { should eql(0) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when the value is an object' do
|
23
|
+
let(:value) { Object.new }
|
24
|
+
|
25
|
+
it { should equal(value) }
|
26
|
+
end
|
27
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Enumerable::EmptyRightOperand, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:described_class) { Class.new(Optimizer::
|
8
|
+
let(:described_class) { Class.new(Optimizer::Function::Predicate) }
|
7
9
|
let(:attribute) { Attribute::Integer.new(:id, :size => 1..9) }
|
8
10
|
let(:predicate) { attribute.include(operand) }
|
9
11
|
let(:object) { described_class.new(predicate) }
|
10
12
|
|
11
13
|
before do
|
12
|
-
described_class.class_eval { include Optimizer::
|
14
|
+
described_class.class_eval { include Optimizer::Function::Predicate::Enumerable::EmptyRightOperand }
|
13
15
|
|
14
|
-
predicate.should be_kind_of(
|
16
|
+
predicate.should be_kind_of(Function::Predicate::Enumerable)
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'when the operand contains a nil' do
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Enumerable::OneRightOperand, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
|
-
let(:described_class) { Class.new(Optimizer::
|
7
|
-
let(:attribute) { Attribute::Integer.new(:id)
|
8
|
-
let(:predicate) { attribute.include(operand)
|
9
|
-
let(:object) { described_class.new(predicate)
|
8
|
+
let(:described_class) { Class.new(Optimizer::Function::Predicate) }
|
9
|
+
let(:attribute) { Attribute::Integer.new(:id) }
|
10
|
+
let(:predicate) { attribute.include(operand) }
|
11
|
+
let(:object) { described_class.new(predicate) }
|
10
12
|
|
11
13
|
before do
|
12
|
-
described_class.class_eval { include Optimizer::
|
14
|
+
described_class.class_eval { include Optimizer::Function::Predicate::Enumerable::OneRightOperand }
|
13
15
|
|
14
|
-
predicate.should be_kind_of(
|
16
|
+
predicate.should be_kind_of(Function::Predicate::Enumerable)
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'when the operand contains a one entry Enumerable' do
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Enumerable::UnoptimizedOperands, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -8,7 +10,7 @@ describe Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand, '#optimiza
|
|
8
10
|
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::Enumerable)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when the operand contains an unsorted Enumerable' do
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Enumerable::UnoptimizedOperands, '#optimize' do
|
4
6
|
subject { object.optimize }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -14,17 +16,28 @@ describe Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand, '#optimize
|
|
14
16
|
context 'when the operand contains an unsorted Enumerable' do
|
15
17
|
let(:operand) { [ 2, 1 ] }
|
16
18
|
|
17
|
-
it { should be_kind_of(
|
19
|
+
it { should be_kind_of(Function::Predicate::Inclusion) }
|
18
20
|
|
19
21
|
its(:left) { should equal(attribute) }
|
20
22
|
|
21
23
|
its(:right) { should == [ 1, 2 ] }
|
22
24
|
end
|
23
25
|
|
26
|
+
context 'when the operand contains an Enumerable with boolean values' do
|
27
|
+
let(:attribute) { Attribute::Boolean.new(:status) }
|
28
|
+
let(:operand) { [ true, false ] }
|
29
|
+
|
30
|
+
it { should be_kind_of(Function::Predicate::Inclusion) }
|
31
|
+
|
32
|
+
its(:left) { should equal(attribute) }
|
33
|
+
|
34
|
+
its(:right) { should == [ false, true ] }
|
35
|
+
end
|
36
|
+
|
24
37
|
context 'when the operand contains an exclusive Range' do
|
25
38
|
let(:operand) { 1...3 }
|
26
39
|
|
27
|
-
it { should be_kind_of(
|
40
|
+
it { should be_kind_of(Function::Predicate::Inclusion) }
|
28
41
|
|
29
42
|
its(:left) { should equal(attribute) }
|
30
43
|
|
@@ -34,7 +47,7 @@ describe Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand, '#optimize
|
|
34
47
|
context 'when the operand contains an Enumerable after filtering invalid entries' do
|
35
48
|
let(:operand) { [ 'a', 1, 2 ] }
|
36
49
|
|
37
|
-
it { should be_kind_of(
|
50
|
+
it { should be_kind_of(Function::Predicate::Inclusion) }
|
38
51
|
|
39
52
|
its(:left) { should equal(attribute) }
|
40
53
|
|
@@ -44,7 +57,7 @@ describe Optimizer::Logic::Predicate::Enumerable::UnoptimizedOperand, '#optimize
|
|
44
57
|
context 'when the operand contains an Enumerable after filtering duplicate entries' do
|
45
58
|
let(:operand) { [ 1, 1, 2, 2 ] }
|
46
59
|
|
47
|
-
it { should be_kind_of(
|
60
|
+
it { should be_kind_of(Function::Predicate::Inclusion) }
|
48
61
|
|
49
62
|
its(:left) { should equal(attribute) }
|
50
63
|
|
data/spec/unit/veritas/optimizer/{logic → function}/predicate/equality/tautology/optimizable_spec.rb
RENAMED
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Equality::Tautology, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -8,7 +10,7 @@ describe Optimizer::Logic::Predicate::Equality::Tautology, '#optimizable?' do
|
|
8
10
|
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::Equality)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when left and right are equal' do
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Exclusion::EmptyRightOperand, '#optimize' do
|
4
6
|
subject { object.optimize }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -14,30 +16,30 @@ describe Optimizer::Logic::Predicate::Exclusion::EmptyRightOperand, '#optimize'
|
|
14
16
|
context 'when the operand contains a nil' do
|
15
17
|
let(:operand) { nil }
|
16
18
|
|
17
|
-
it { should equal(
|
19
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
18
20
|
end
|
19
21
|
|
20
22
|
context 'when the operand contains an empty Enumerable' do
|
21
23
|
let(:operand) { [] }
|
22
24
|
|
23
|
-
it { should equal(
|
25
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
24
26
|
end
|
25
27
|
|
26
28
|
context 'when the operand contains an empty inclusive Range' do
|
27
29
|
let(:operand) { 1..0 }
|
28
30
|
|
29
|
-
it { should equal(
|
31
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'when the operand contains an empty exclusive Range' do
|
33
35
|
let(:operand) { 1...1 }
|
34
36
|
|
35
|
-
it { should equal(
|
37
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
36
38
|
end
|
37
39
|
|
38
40
|
context 'when the operand is empty after filtering invalid entries' do
|
39
41
|
let(:operand) { [ 'a' ] }
|
40
42
|
|
41
|
-
it { should equal(
|
43
|
+
it { should equal(Function::Proposition::Tautology.instance) }
|
42
44
|
end
|
43
45
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
4
6
|
subject { object.optimize }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -14,7 +16,7 @@ describe Optimizer::Logic::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
|
14
16
|
context 'when the operand contains a one entry Enumerable' do
|
15
17
|
let(:operand) { [ 1 ] }
|
16
18
|
|
17
|
-
it { should be_kind_of(
|
19
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
18
20
|
|
19
21
|
its(:left) { should equal(attribute) }
|
20
22
|
|
@@ -24,7 +26,7 @@ describe Optimizer::Logic::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
|
24
26
|
context 'when the operand contains a one entry inclusive Range' do
|
25
27
|
let(:operand) { 1..1 }
|
26
28
|
|
27
|
-
it { should be_kind_of(
|
29
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
28
30
|
|
29
31
|
its(:left) { should equal(attribute) }
|
30
32
|
|
@@ -34,7 +36,7 @@ describe Optimizer::Logic::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
|
34
36
|
context 'when the operand contains a one entry exclusive Range' do
|
35
37
|
let(:operand) { 1...2 }
|
36
38
|
|
37
|
-
it { should be_kind_of(
|
39
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
38
40
|
|
39
41
|
its(:left) { should equal(attribute) }
|
40
42
|
|
@@ -44,7 +46,7 @@ describe Optimizer::Logic::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
|
44
46
|
context 'when the operand contains one entry after filtering invalid entries' do
|
45
47
|
let(:operand) { [ 'a', 1 ] }
|
46
48
|
|
47
|
-
it { should be_kind_of(
|
49
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
48
50
|
|
49
51
|
its(:left) { should equal(attribute) }
|
50
52
|
|
@@ -54,7 +56,7 @@ describe Optimizer::Logic::Predicate::Exclusion::OneRightOperand, '#optimize' do
|
|
54
56
|
context 'when the operand contains one entry after filtering duplicate entries' do
|
55
57
|
let(:operand) { [ 1, 1 ] }
|
56
58
|
|
57
|
-
it { should be_kind_of(
|
59
|
+
it { should be_kind_of(Function::Predicate::Inequality) }
|
58
60
|
|
59
61
|
its(:left) { should equal(attribute) }
|
60
62
|
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::GreaterThan::Contradiction, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -8,7 +10,7 @@ describe Optimizer::Logic::Predicate::GreaterThan::Contradiction, '#optimizable?
|
|
8
10
|
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::GreaterThan)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when left and right are equal' do
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::GreaterThan::Tautology, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:predicate) { left.gt(right) }
|
7
9
|
let(:object) { described_class.new(predicate) }
|
8
10
|
|
9
11
|
before do
|
10
|
-
predicate.should be_kind_of(
|
12
|
+
predicate.should be_kind_of(Function::Predicate::GreaterThan)
|
11
13
|
end
|
12
14
|
|
13
15
|
context 'when left is always greater than right' do
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::GreaterThanOrEqualTo::Contradiction, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -8,7 +10,7 @@ describe Optimizer::Logic::Predicate::GreaterThanOrEqualTo::Contradiction, '#opt
|
|
8
10
|
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::GreaterThanOrEqualTo)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when left and right are equal' do
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Optimizer::
|
5
|
+
describe Optimizer::Function::Predicate::GreaterThanOrEqualTo::Tautology, '#optimizable?' do
|
4
6
|
subject { object.optimizable? }
|
5
7
|
|
6
8
|
let(:attribute) { Attribute::Integer.new(:id) }
|
@@ -8,7 +10,7 @@ describe Optimizer::Logic::Predicate::GreaterThanOrEqualTo::Tautology, '#optimiz
|
|
8
10
|
let(:object) { described_class.new(predicate) }
|
9
11
|
|
10
12
|
before do
|
11
|
-
predicate.should be_kind_of(
|
13
|
+
predicate.should be_kind_of(Function::Predicate::GreaterThan)
|
12
14
|
end
|
13
15
|
|
14
16
|
context 'when left and right are equal' do
|