alf-core 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +9 -17
- data/examples/operators/frame.alf +2 -0
- data/lib/alf-core.rb +24 -22
- data/lib/{alf-adapter/alf → alf}/adapter.rb +0 -0
- data/lib/{alf-adapter/alf → alf}/adapter/connection.rb +4 -10
- data/lib/{alf-adapter/alf → alf}/adapter/connection/schema_cached.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder/connection.rb +3 -2
- data/lib/{alf-adapter-fs/alf → alf}/adapter/fs.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator.rb +12 -9
- data/lib/{alf-aggregator/alf → alf}/aggregator/avg.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/collect.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/concat.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/count.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/max.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/min.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/stddev.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/sum.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/variance.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra.rb +1 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand.rb +13 -6
- data/lib/{alf-algebra/alf → alf}/algebra/operand/fake.rb +18 -4
- data/lib/alf/algebra/operand/named.rb +65 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand/proxy.rb +7 -3
- data/lib/{alf-algebra/alf → alf}/algebra/operator.rb +40 -12
- data/lib/{alf-algebra/alf → alf}/algebra/operator/autonum.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/clip.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/coerce.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/compact.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/defaults.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/extend.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/frame.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/generator.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/group.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/hierarchize.rb +8 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operator/intersect.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/join.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/matching.rb +10 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/minus.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/not_matching.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/page.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/project.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/quota.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rank.rb +11 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rename.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/restrict.rb +12 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/sort.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/summarize.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/ungroup.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/union.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/unwrap.rb +13 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/wrap.rb +10 -1
- data/lib/alf/algebra/shortcut.rb +40 -0
- data/lib/alf/algebra/shortcut/allbut.rb +25 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/binary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/classification.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/compiler.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/experimental.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/non_relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/nullary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/rewriter.rb +4 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/signature.rb +7 -8
- data/lib/alf/algebra/support/type_check.rb +51 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/unary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/visitor.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/with_ordering.rb +0 -0
- data/lib/alf/compiler.rb +57 -0
- data/lib/alf/compiler/cog.rb +39 -0
- data/lib/alf/compiler/default.rb +168 -0
- data/lib/alf/compiler/plan.rb +77 -0
- data/lib/{alf-core → alf/core}/loader.rb +0 -0
- data/lib/{alf-core → alf/core}/version.rb +1 -1
- data/lib/{alf-database/alf → alf}/database.rb +0 -0
- data/lib/{alf-database/alf → alf}/database/connection.rb +10 -52
- data/lib/{alf-database/alf → alf}/database/options.rb +2 -5
- data/lib/{alf-core → alf}/dsl.rb +4 -4
- data/lib/{alf-engine/alf → alf}/engine.rb +0 -2
- data/lib/{alf-engine/alf → alf}/engine/aggregate.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/autonum.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/clip.rb +10 -2
- data/lib/{alf-engine/alf → alf}/engine/coerce.rb +6 -2
- data/lib/alf/engine/cog.rb +58 -0
- data/lib/{alf-engine/alf → alf}/engine/compact.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/set.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/uniq.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/concat.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/defaults.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/filter.rb +8 -4
- data/lib/{alf-engine/alf → alf}/engine/generator.rb +6 -2
- data/lib/alf/engine/group.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/group/hash.rb +11 -2
- data/lib/{alf-engine/alf → alf}/engine/hierarchize.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/infer_heading.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/join.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/join/hash.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/leaf.rb +7 -3
- data/lib/{alf-engine/alf → alf}/engine/materialize.rb +5 -1
- data/lib/{alf-engine/alf → alf}/engine/materialize/array.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/materialize/hash.rb +3 -2
- data/lib/alf/engine/quota.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/quota/cesure.rb +8 -3
- data/lib/alf/engine/rank.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/rank/cesure.rb +8 -3
- data/lib/{alf-engine/alf → alf}/engine/rename.rb +6 -2
- data/lib/alf/engine/semi.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/semi/hash.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/set_attr.rb +8 -4
- data/lib/alf/engine/sort.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/sort/in_memory.rb +12 -2
- data/lib/alf/engine/summarize.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/summarize/cesure.rb +5 -4
- data/lib/{alf-engine/alf → alf}/engine/summarize/hash.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/support/cesure.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/take.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/to_array.rb +13 -5
- data/lib/{alf-engine/alf → alf}/engine/type_safe.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/ungroup.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/unwrap.rb +11 -5
- data/lib/{alf-engine/alf → alf}/engine/wrap.rb +6 -2
- data/lib/{alf-core → alf}/errors.rb +2 -3
- data/lib/{alf-core → alf}/ext.rb +0 -0
- data/lib/{alf-core → alf}/ext/domain/heading_based.rb +5 -0
- data/lib/alf/facade.rb +53 -0
- data/lib/{alf-lang/alf → alf}/lang.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/functional.rb +0 -4
- data/lib/{alf-lang/alf → alf}/lang/object_oriented.rb +0 -0
- data/lib/{alf-lang/alf → alf}/lang/oo/aggregation_methods.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/oo/algebra_methods.rb +0 -12
- data/lib/{alf-lang/alf → alf}/lang/oo/rendering_methods.rb +1 -1
- data/lib/alf/lang/parser.rb +9 -0
- data/lib/alf/lang/parser/lispy.rb +63 -0
- data/lib/alf/lang/parser/safer.rb +69 -0
- data/lib/{alf-lang/alf → alf}/lang/predicates.rb +1 -1
- data/lib/{alf-optimizer/alf → alf}/optimizer.rb +15 -7
- data/lib/alf/optimizer/project.rb +182 -0
- data/lib/{alf-optimizer/alf → alf}/optimizer/restrict.rb +48 -50
- data/lib/{alf-predicate/alf → alf}/predicate.rb +16 -12
- data/lib/{alf-predicate/alf → alf}/predicate/factory.rb +13 -8
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.rb +2 -5
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.sexp.yml +11 -7
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/and.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/contradiction.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/dyadic_comp.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/eq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/expr.rb +10 -5
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gte.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/var_ref.rb → alf/predicate/nodes/identifier.rb} +3 -3
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/in.rb +2 -2
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/literal.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lte.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/nadic_bool.rb +0 -0
- data/lib/alf/predicate/nodes/native.rb +32 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/neq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/not.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/or.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/native.rb → alf/predicate/nodes/qualified_identifier.rb} +8 -4
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/tautology.rb +0 -0
- data/lib/alf/predicate/processors.rb +3 -0
- data/lib/alf/predicate/processors/qualifier.rb +25 -0
- data/lib/alf/predicate/processors/renamer.rb +27 -0
- data/lib/{alf-predicate/alf → alf}/predicate/processors/to_ruby_code.rb +6 -11
- data/lib/{alf-io/alf → alf}/reader.rb +11 -2
- data/lib/{alf-io/alf → alf}/reader/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/ruby.rb +0 -0
- data/lib/alf/reader/yaml.rb +25 -0
- data/lib/{alf-relation/alf → alf}/relation.rb +12 -2
- data/lib/{alf-relvar/alf → alf}/relvar.rb +14 -21
- data/lib/alf/relvar/base.rb +35 -0
- data/lib/{alf-relvar/alf → alf}/relvar/fake.rb +3 -2
- data/lib/{alf-relvar/alf → alf}/relvar/read_only.rb +6 -30
- data/lib/{alf-relvar/alf → alf}/relvar/virtual.rb +0 -31
- data/lib/{alf-io/alf → alf}/renderer.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/text.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/yaml.rb +2 -2
- data/lib/{alf-support/alf → alf}/support.rb +2 -1
- data/lib/{alf-support/alf → alf}/support/coerce.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/config.rb +0 -0
- data/lib/{alf-io/alf → alf}/support/csv_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/dot_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/miscellaneous.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/ordered_set.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/registry.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/scope.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/to_lispy.rb +6 -1
- data/lib/{alf-support/alf → alf}/support/to_ruby_literal.rb +0 -0
- data/lib/alf/support/tree.rb +51 -0
- data/lib/{alf-support/alf → alf}/support/tuple_scope.rb +9 -1
- data/lib/{alf-relation/alf → alf}/tuple.rb +1 -1
- data/lib/{alf-types/alf → alf}/types.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/attr_list.rb +2 -2
- data/lib/{alf-types/alf → alf}/types/attr_name.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/boolean.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/heading.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/keys.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/ordering.rb +7 -1
- data/lib/{alf-types/alf → alf}/types/renaming.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selection.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selector.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/size.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/summarization.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/tuple_computation.rb +13 -4
- data/lib/{alf-types/alf → alf}/types/tuple_expression.rb +6 -19
- data/lib/{alf-types/alf → alf}/types/type_check.rb +1 -0
- data/lib/{alf-update/alf → alf}/update.rb +0 -0
- data/lib/{alf-update/alf → alf}/update/deleter.rb +0 -3
- data/lib/{alf-update/alf → alf}/update/inserter.rb +1 -7
- data/lib/{alf-update/alf → alf}/update/updater.rb +0 -2
- data/lib/{alf-viewpoint/alf → alf}/viewpoint.rb +9 -7
- data/lib/{alf-viewpoint/alf → alf}/viewpoint/metadata.rb +5 -2
- data/spec/compiler_helper.rb +20 -0
- data/spec/integration/relation/test_to_array.rb +6 -6
- data/spec/integration/test_examples.rb +14 -6
- data/spec/shared/a_cog.rb +8 -4
- data/spec/shared/a_valid_type_implementation.rb +4 -7
- data/spec/spec_helper.rb +9 -5
- data/spec/type_check_helper.rb +1 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_with_readable_cogs.rb +1 -1
- data/spec/unit/alf-aggregator/test_concat.rb +8 -0
- data/spec/unit/alf-algebra/operand/named/test_hash_and_equal.rb +53 -0
- data/spec/unit/alf-algebra/operand/named/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_to_ascii_tree.rb +18 -0
- data/spec/unit/alf-algebra/operand/named/test_to_cog.rb +24 -0
- data/spec/unit/alf-algebra/operand/named/test_to_relvar.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_type_check.rb +38 -0
- data/spec/unit/alf-algebra/operand/proxy/test_to_cog.rb +42 -0
- data/spec/unit/alf-algebra/operand/test_coerce.rb +0 -6
- data/spec/unit/alf-algebra/operand/test_proxy.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_key_preserving.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/autonum/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/clip/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/coerce/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/commons/test_resulting_type.rb +20 -0
- data/spec/unit/alf-algebra/operator/commons/test_to_ascii_tree.rb +40 -0
- data/spec/unit/alf-algebra/operator/extend/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/frame/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/group/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/hierarchize/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/intersect/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/join/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/matching/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/minus/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/page/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/project/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/quota/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/rank/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/rename/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/restrict/test_type_check.rb +46 -0
- data/spec/unit/alf-algebra/operator/shared/test_to_cog.rb +34 -0
- data/spec/unit/alf-algebra/operator/sort/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/summarize/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/test_hash_and_equal.rb +59 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/union/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/wrap/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/support/signature/test_to_lispy.rb +24 -9
- data/spec/unit/alf-algebra/support/test_non_relational.rb +1 -2
- data/spec/unit/alf-algebra/support/test_relational.rb +1 -1
- data/spec/unit/alf-compiler/default/test_allbut.rb +65 -0
- data/spec/unit/alf-compiler/default/test_autonum.rb +30 -0
- data/spec/unit/alf-compiler/default/test_clip.rb +30 -0
- data/spec/unit/alf-compiler/default/test_coerce.rb +30 -0
- data/spec/unit/alf-compiler/default/test_compact.rb +26 -0
- data/spec/unit/alf-compiler/default/test_completude.rb +16 -0
- data/spec/unit/alf-compiler/default/test_defaults.rb +50 -0
- data/spec/unit/alf-compiler/default/test_extend.rb +34 -0
- data/spec/unit/alf-compiler/default/test_frame.rb +77 -0
- data/spec/unit/alf-compiler/default/test_generator.rb +30 -0
- data/spec/unit/alf-compiler/default/test_group.rb +38 -0
- data/spec/unit/alf-compiler/default/test_hierarchize.rb +40 -0
- data/spec/unit/alf-compiler/default/test_intersect.rb +34 -0
- data/spec/unit/alf-compiler/default/test_join.rb +34 -0
- data/spec/unit/alf-compiler/default/test_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_minus.rb +38 -0
- data/spec/unit/alf-compiler/default/test_not_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_page.rb +91 -0
- data/spec/unit/alf-compiler/default/test_project.rb +76 -0
- data/spec/unit/alf-compiler/default/test_quota.rb +88 -0
- data/spec/unit/alf-compiler/default/test_rank.rb +71 -0
- data/spec/unit/alf-compiler/default/test_rename.rb +30 -0
- data/spec/unit/alf-compiler/default/test_restrict.rb +34 -0
- data/spec/unit/alf-compiler/default/test_sort.rb +81 -0
- data/spec/unit/alf-compiler/default/test_summarize.rb +85 -0
- data/spec/unit/alf-compiler/default/test_ungroup.rb +30 -0
- data/spec/unit/alf-compiler/default/test_union.rb +36 -0
- data/spec/unit/alf-compiler/default/test_unwrap.rb +30 -0
- data/spec/unit/alf-compiler/default/test_wrap.rb +38 -0
- data/spec/unit/alf-compiler/shared/compiled_examples.rb +111 -0
- data/spec/unit/alf-compiler/test_principle.rb +332 -0
- data/spec/unit/alf-core/test_aggregator.rb +0 -24
- data/spec/unit/alf-database/connection/test_parse.rb +0 -49
- data/spec/unit/alf-database/connection/test_relvar.rb +1 -9
- data/spec/unit/alf-database/options/test_parser.rb +23 -0
- data/spec/unit/alf-engine/cog/test_to_ascii_tree.rb +14 -0
- data/spec/unit/alf-engine/test_aggregate.rb +2 -2
- data/spec/unit/alf-engine/test_filter.rb +1 -1
- data/spec/unit/alf-engine/test_to_array.rb +16 -2
- data/spec/unit/alf-io/reader/test_yaml.rb +30 -0
- data/spec/unit/alf-io/renderer/test_yaml.rb +11 -0
- data/spec/unit/alf-lang/functional/test_aggregation.rb +18 -4
- data/spec/unit/alf-lang/parser/lispy/test_connection_bang.rb +28 -0
- data/spec/unit/alf-lang/parser/lispy/test_parse.rb +38 -0
- data/spec/unit/alf-lang/parser/lispy/test_to_s.rb +16 -0
- data/spec/unit/alf-lang/parser/safer/safe.txt +5 -0
- data/spec/unit/alf-lang/parser/safer/test_parse.rb +82 -0
- data/spec/unit/alf-lang/parser/safer/unsafe.txt +14 -0
- data/spec/unit/alf-optimizer/restrict/test_on_autonum.rb +1 -1
- data/spec/unit/alf-optimizer/test_quota.rb +1 -1
- data/spec/unit/alf-optimizer/test_rename.rb +7 -0
- data/spec/unit/alf-optimizer/test_summarize.rb +1 -1
- data/spec/unit/alf-predicate/expr/test_to_proc.rb +4 -6
- data/spec/unit/alf-predicate/expr/test_to_ruby_code.rb +23 -23
- data/spec/unit/alf-predicate/factory/shared/a_comparison_factory_method.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_between.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_comp.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_factor_predicate.rb +3 -3
- data/spec/unit/alf-predicate/factory/{test_var_ref.rb → test_identifier.rb} +4 -4
- data/spec/unit/alf-predicate/factory/test_in.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_native.rb +9 -4
- data/spec/unit/alf-predicate/factory/test_qualified_identifier.rb +17 -0
- data/spec/unit/alf-predicate/grammar/test_match.rb +9 -9
- data/spec/unit/alf-predicate/grammar/test_sexpr.rb +11 -11
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_and_split.rb +2 -2
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_free_variables.rb +2 -2
- data/spec/unit/alf-predicate/nodes/identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_and_split.rb +25 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_free_variables.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_qualifier.rb +14 -0
- data/spec/unit/alf-predicate/predicate/test_and_split.rb +4 -4
- data/spec/unit/alf-predicate/predicate/test_bool_and.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_not.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_or.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_coerce.rb +9 -8
- data/spec/unit/alf-predicate/predicate/test_contradiction.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_factory_methods.rb +12 -12
- data/spec/unit/alf-predicate/predicate/test_qualify.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_rename.rb +58 -15
- data/spec/unit/alf-predicate/predicate/test_tautology.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_code.rb +8 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_literal.rb +1 -1
- data/spec/unit/alf-predicate/test_predicate.rb +7 -8
- data/spec/unit/alf-relation/relation/class/test_dum.rb +19 -0
- data/spec/unit/alf-relation/relation/test_heading.rb +1 -1
- data/spec/unit/alf-relation/relation/test_keys.rb +17 -0
- data/spec/unit/alf-relation/relation/test_relation.rb +1 -1
- data/spec/unit/alf-relation/relation/test_to_a.rb +10 -10
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +26 -10
- data/spec/unit/alf-relvar/base/test_to_cog.rb +2 -2
- data/spec/unit/alf-relvar/read_only/test_to_relation.rb +17 -0
- data/spec/unit/alf-relvar/read_only/test_type.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +4 -4
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +1 -1
- data/spec/unit/alf-support/test_to_lispy.rb +13 -31
- data/spec/unit/alf-support/test_tuple_scope.rb +11 -0
- data/spec/unit/alf-types/ordering/test_coerce.rb +13 -0
- data/spec/unit/alf-types/ordering/test_lte.rb +43 -0
- data/spec/unit/alf-types/summarization/test_coerce.rb +2 -2
- data/spec/unit/alf-types/summarization/test_least.rb +1 -1
- data/spec/unit/alf-types/summarization/test_summarize.rb +1 -1
- data/spec/unit/alf-types/test_summarization.rb +2 -2
- data/spec/unit/alf-types/test_tuple_expression.rb +2 -2
- data/spec/unit/alf-types/tuple_computation/test_coerce.rb +4 -13
- data/spec/unit/alf-types/tuple_computation/test_empty.rb +24 -0
- data/spec/unit/alf-types/tuple_computation/test_project.rb +46 -0
- data/spec/unit/alf-types/tuple_expression/test_coerce.rb +1 -10
- data/spec/unit/alf-types/tuple_expression/test_evaluate.rb +0 -8
- data/spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb +0 -5
- data/spec/unit/alf-update/deleter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/inserter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/updater/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-viewpoint/test_native_const.rb +1 -1
- data/spec/update_helper.rb +18 -2
- metadata +417 -313
- data/lib/alf-algebra/alf/algebra/operand/named.rb +0 -36
- data/lib/alf-algebra/alf/algebra/operator/infer_heading.rb +0 -19
- data/lib/alf-algebra/alf/algebra/operator/type_safe.rb +0 -21
- data/lib/alf-algebra/alf/algebra/support/to_dot.rb +0 -196
- data/lib/alf-core/facade.rb +0 -39
- data/lib/alf-engine/alf/engine/cog.rb +0 -50
- data/lib/alf-engine/alf/engine/compiler.rb +0 -171
- data/lib/alf-engine/alf/engine/group.rb +0 -3
- data/lib/alf-engine/alf/engine/quota.rb +0 -3
- data/lib/alf-engine/alf/engine/rank.rb +0 -3
- data/lib/alf-engine/alf/engine/semi.rb +0 -3
- data/lib/alf-engine/alf/engine/sort.rb +0 -30
- data/lib/alf-engine/alf/engine/summarize.rb +0 -4
- data/lib/alf-engine/alf/engine/to_dot.rb +0 -60
- data/lib/alf-io/alf/io.rb +0 -6
- data/lib/alf-lang/alf/lang/lispy.rb +0 -65
- data/lib/alf-predicate/alf/predicate/parser.rb +0 -12
- data/lib/alf-predicate/alf/predicate/processors.rb +0 -3
- data/lib/alf-predicate/alf/predicate/processors/renamer.rb +0 -19
- data/lib/alf-predicate/alf/predicate/processors/to_proc.rb +0 -35
- data/lib/alf-relvar/alf/relvar/base.rb +0 -69
- data/lib/alf-support/alf/support/bindable.rb +0 -26
- data/spec/integration/algebra/test_to_dot.rb +0 -14
- data/spec/integration/relvar/test_type_safe.rb +0 -22
- data/spec/unit/alf-algebra/operator/infer_heading/test_keys.rb +0 -23
- data/spec/unit/alf-algebra/operator/test_infer_heading.rb +0 -16
- data/spec/unit/alf-algebra/operator/type_safe/test_heading.rb +0 -26
- data/spec/unit/alf-algebra/operator/type_safe/test_keys.rb +0 -26
- data/spec/unit/alf-engine/compiler/test_on_frame.rb +0 -70
- data/spec/unit/alf-engine/compiler/test_on_hierarchize.rb +0 -33
- data/spec/unit/alf-engine/compiler/test_on_page.rb +0 -128
- data/spec/unit/alf-engine/compiler/test_unsupported.rb +0 -48
- data/spec/unit/alf-lang/lispy/test_connection_bang.rb +0 -26
- data/spec/unit/alf-lang/lispy/test_parse.rb +0 -38
- data/spec/unit/alf-lang/lispy/test_to_s.rb +0 -14
- data/spec/unit/alf-optimizer/optimizer/test_optimizer.rb +0 -37
- data/spec/unit/alf-optimizer/test_infer_heading.rb +0 -9
- data/spec/unit/alf-predicate/grammar/test_parse.rb +0 -23
- data/spec/unit/alf-predicate/nodes/var_ref/test_var_name.rb +0 -14
- data/spec/unit/alf-relvar/base/test_name.rb +0 -15
- data/spec/unit/alf-relvar/virtual/test_connection.rb +0 -15
- data/spec/unit/alf-support/bindable/test_bind.rb +0 -60
- data/spec/unit/alf-support/bindable/test_bound.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection_bang.rb +0 -35
- data/spec/unit/alf-update/inserter/test_type_safe.rb +0 -72
@@ -6,13 +6,13 @@ module Alf
|
|
6
6
|
let(:expr){ Algebra::Operand::Named.new(:aname, self) }
|
7
7
|
let(:rv) { Virtual.new(expr) }
|
8
8
|
|
9
|
-
subject{ rv.to_cog }
|
9
|
+
subject{ rv.to_cog(12) }
|
10
10
|
|
11
|
-
def cog(
|
12
|
-
|
11
|
+
def cog(*args)
|
12
|
+
@seen = args
|
13
13
|
end
|
14
14
|
|
15
|
-
it{ should eq([
|
15
|
+
it{ should eq([12, expr]) }
|
16
16
|
|
17
17
|
end
|
18
18
|
end
|
@@ -2,20 +2,8 @@ require 'spec_helper'
|
|
2
2
|
module Alf
|
3
3
|
describe Support, ".to_lispy" do
|
4
4
|
|
5
|
-
# it "should have a valid example" do
|
6
|
-
# expr = examples_database.parse{
|
7
|
-
# (project suppliers, [:name])
|
8
|
-
# }
|
9
|
-
# Support.to_lispy(expr).should eq("project(suppliers, [:name])")
|
10
|
-
# end
|
11
|
-
|
12
5
|
subject{ Support.to_lispy(value) }
|
13
6
|
|
14
|
-
# describe "on a Relvar" do
|
15
|
-
# let(:value){ examples_database.relvar(:suppliers) }
|
16
|
-
# it { should eq("suppliers") }
|
17
|
-
# end
|
18
|
-
#
|
19
7
|
describe "on an AttrName" do
|
20
8
|
let(:value){ :city }
|
21
9
|
it { should eq(":city") }
|
@@ -42,21 +30,18 @@ module Alf
|
|
42
30
|
end
|
43
31
|
|
44
32
|
describe "on an Aggregation" do
|
45
|
-
let(:
|
46
|
-
|
33
|
+
let(:expr){ ->(t){ t.qty*t.price } }
|
34
|
+
let(:value){ Aggregator.coerce(Aggregator.sum(expr)) }
|
35
|
+
|
36
|
+
it { should eq("sum{|t| [code unavailable] }") }
|
47
37
|
end
|
48
38
|
|
49
39
|
describe "on a TupleExpression" do
|
50
40
|
let(:value){ TupleExpression.coerce(arg) }
|
51
41
|
|
52
|
-
describe "When built from a string" do
|
53
|
-
let(:arg){ "status.upcase" }
|
54
|
-
it{ should eq("->{ status.upcase }")}
|
55
|
-
end
|
56
|
-
|
57
42
|
describe "When built from a symbol" do
|
58
43
|
let(:arg){ :status }
|
59
|
-
it{ should eq("->{ status }")}
|
44
|
+
it{ should eq("->(t){ t.status }")}
|
60
45
|
end
|
61
46
|
|
62
47
|
end # TupleExpression
|
@@ -66,37 +51,34 @@ module Alf
|
|
66
51
|
|
67
52
|
describe "When built from a boolean" do
|
68
53
|
let(:arg){ true }
|
69
|
-
it{ should eq("->{ true }")}
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "When built from a String" do
|
73
|
-
let(:arg){ "status > 10" }
|
74
|
-
it{ should eq("->{ status > 10 }")}
|
54
|
+
it{ should eq("->(t){ true }")}
|
75
55
|
end
|
76
56
|
|
77
57
|
describe "When built from a Hash" do
|
78
58
|
let(:arg){ {:status => 10} }
|
79
|
-
it{ should eq("->{
|
59
|
+
it{ should eq("->(t){ t.status == 10 }")}
|
80
60
|
end
|
81
61
|
|
82
62
|
end # Predicate
|
83
63
|
|
84
64
|
describe "on a TupleComputation" do
|
85
65
|
let(:value){ TupleComputation.coerce(arg) }
|
66
|
+
let(:expr){ ->(t){ status.upcase } }
|
86
67
|
|
87
68
|
describe "When built from a Hash" do
|
88
|
-
let(:arg){ {"upcased" =>
|
89
|
-
it{ should eq("{upcased: ->{
|
69
|
+
let(:arg){ {"upcased" => expr} }
|
70
|
+
it{ should eq("{upcased: ->(t){ [code unavailable] }}")}
|
90
71
|
end
|
91
72
|
|
92
73
|
end # TupleComputation
|
93
74
|
|
94
75
|
describe "on a Summarization" do
|
95
76
|
let(:value){ Summarization.coerce(arg) }
|
77
|
+
let(:expr){ Aggregator.sum{|t| t.qty*t.price } }
|
96
78
|
|
97
79
|
describe "When built from an Array" do
|
98
|
-
let(:arg){ {"total" =>
|
99
|
-
it{ should eq("{total: sum{
|
80
|
+
let(:arg){ {"total" => expr} }
|
81
|
+
it{ should eq("{total: sum{|t| [code unavailable] }}") }
|
100
82
|
end
|
101
83
|
|
102
84
|
end # Summarization
|
@@ -30,6 +30,17 @@ module Alf
|
|
30
30
|
scope.evaluate{ path < 1 }.should be_false
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should support calling Tuple and Relation" do
|
34
|
+
scope.__set_tuple(:path => 1)
|
35
|
+
scope.evaluate{ Tuple(sid: path) }.should eq(Tuple(sid: 1))
|
36
|
+
scope.evaluate{ Relation(sid: path) }.should eq(Relation(sid: 1))
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should support being converted to Relation" do
|
40
|
+
scope.__set_tuple(:path => 1)
|
41
|
+
Relation(scope).should eq(Relation(path: 1))
|
42
|
+
end
|
43
|
+
|
33
44
|
end
|
34
45
|
end
|
35
46
|
end
|
@@ -60,5 +60,18 @@ module Alf
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
context 'coming from ARGV' do
|
64
|
+
let(:argv){
|
65
|
+
["city", "asc", "status", "desc", "sid", "asc"]
|
66
|
+
}
|
67
|
+
let(:expected){
|
68
|
+
Ordering.new([[:city, :asc], [:status, :desc], [:sid, :asc]])
|
69
|
+
}
|
70
|
+
|
71
|
+
it "should work as expected" do
|
72
|
+
Ordering.coerce(argv).should eq(expected)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
63
76
|
end # Ordering
|
64
77
|
end # Alf
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
describe Ordering, "<=" do
|
4
|
+
|
5
|
+
subject{ o1 <= o2 }
|
6
|
+
|
7
|
+
context 'when empty' do
|
8
|
+
let(:o1){ Ordering::EMPTY }
|
9
|
+
let(:o2){ Ordering.new([]) }
|
10
|
+
|
11
|
+
it{ should be_true }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when equal' do
|
15
|
+
let(:o1){ Ordering.new([[:a, :asc], [:b, :desc]]) }
|
16
|
+
let(:o2){ Ordering.new([[:a, :asc], [:b, :desc]]) }
|
17
|
+
|
18
|
+
it{ should be_true }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when subsumed' do
|
22
|
+
let(:o1){ Ordering.new([[:a, :asc]]) }
|
23
|
+
let(:o2){ Ordering.new([[:a, :asc], [:b, :desc]]) }
|
24
|
+
|
25
|
+
it{ should be_true }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when larger' do
|
29
|
+
let(:o1){ Ordering.new([[:a, :asc], [:b, :desc]]) }
|
30
|
+
let(:o2){ Ordering.new([[:a, :asc]]) }
|
31
|
+
|
32
|
+
it{ should be_false }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when different' do
|
36
|
+
let(:o1){ Ordering.new([[:a, :asc]]) }
|
37
|
+
let(:o2){ Ordering.new([[:a, :desc]]) }
|
38
|
+
|
39
|
+
it{ should be_false }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -10,7 +10,7 @@ module Alf
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "from a Hash" do
|
13
|
-
let(:arg){ { :s =>
|
13
|
+
let(:arg){ { :s => Aggregator.sum{ qty }, :m => Aggregator.max{ size } } }
|
14
14
|
it{ should be_a(Summarization) }
|
15
15
|
specify{
|
16
16
|
subject.to_hash.keys.to_set.should eq([:s, :m].to_set)
|
@@ -19,7 +19,7 @@ module Alf
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "from an Array" do
|
22
|
-
let(:arg){ ["s",
|
22
|
+
let(:arg){ ["s", Aggregator.sum{ qty }, "m", Aggregator.max{ size }] }
|
23
23
|
it{ should be_a(Summarization) }
|
24
24
|
specify{
|
25
25
|
subject.to_hash.keys.to_set.should eq([:s, :m].to_set)
|
@@ -3,7 +3,7 @@ module Alf
|
|
3
3
|
describe Summarization, "least" do
|
4
4
|
|
5
5
|
it 'should invoke least on each aggregator' do
|
6
|
-
sum = Summarization.coerce(["s",
|
6
|
+
sum = Summarization.coerce(["s", Aggregator.avg{ qty }, "m", Aggregator.max{ size }])
|
7
7
|
sum.least.should eq({:s => [0.0, 0.0], :m => nil})
|
8
8
|
end
|
9
9
|
|
@@ -7,7 +7,7 @@ module Alf
|
|
7
7
|
{:qty => 10, :size => 12},
|
8
8
|
{:qty => 5, :size => 5}
|
9
9
|
]
|
10
|
-
sum = Summarization.coerce(["s",
|
10
|
+
sum = Summarization.coerce(["s", Aggregator.avg{ qty }, "m", Aggregator.max{ size }])
|
11
11
|
sum.summarize(rel).should eq({:s => 7.5, :m => 12})
|
12
12
|
end
|
13
13
|
|
@@ -6,7 +6,7 @@ module Alf
|
|
6
6
|
let(:type){ Summarization }
|
7
7
|
def Summarization.exemplars
|
8
8
|
[
|
9
|
-
["total",
|
9
|
+
["total", Aggregator.sum{ qty }]
|
10
10
|
].map{|x| Summarization.coerce(x)}
|
11
11
|
end
|
12
12
|
it_should_behave_like 'A valid type implementation'
|
@@ -14,7 +14,7 @@ module Alf
|
|
14
14
|
|
15
15
|
specify "least -> happens -> finalize" do
|
16
16
|
scope = Support::TupleScope.new
|
17
|
-
summ = Summarization.coerce(["s",
|
17
|
+
summ = Summarization.coerce(["s", Aggregator.sum{ qty }, "m", Aggregator.max{ size }])
|
18
18
|
(x = summ.least).should eql(:s => 0, :m => nil)
|
19
19
|
(x = summ.happens(x, scope.__set_tuple(:qty => 10, :size => 12))).should eq(:s => 10, :m => 12)
|
20
20
|
(x = summ.happens(x, scope.__set_tuple(:qty => 5, :size => 5))).should eq(:s => 15, :m => 12)
|
@@ -16,21 +16,20 @@ module Alf
|
|
16
16
|
describe "from a Hash without coercion" do
|
17
17
|
let(:arg){
|
18
18
|
{:hello => TupleExpression.coerce(:who),
|
19
|
-
:hello2 =>
|
20
|
-
:hello3 => lambda{ who } }
|
19
|
+
:hello2 => ->(t){ t.who } }
|
21
20
|
}
|
22
21
|
let(:expected){
|
23
|
-
{hello: "alf", :hello2 =>
|
22
|
+
{hello: "alf", :hello2 => "alf"}
|
24
23
|
}
|
25
24
|
it{ should eql(expected) }
|
26
25
|
end
|
27
26
|
|
28
27
|
describe "from a Hash with coercion" do
|
29
28
|
let(:arg){
|
30
|
-
{"hello" =>
|
29
|
+
{"hello" => :who}
|
31
30
|
}
|
32
31
|
let(:expected){
|
33
|
-
{hello: "alf"
|
32
|
+
{hello: "alf"}
|
34
33
|
}
|
35
34
|
it{ should eql(expected) }
|
36
35
|
end
|
@@ -42,13 +41,5 @@ module Alf
|
|
42
41
|
it{ should eql(expected) }
|
43
42
|
end
|
44
43
|
|
45
|
-
describe "from an Array with coercions" do
|
46
|
-
let(:arg){ ["hello", "who", "hello2", "2"] }
|
47
|
-
let(:expected){
|
48
|
-
{hello: "alf", hello2: 2}
|
49
|
-
}
|
50
|
-
it{ should eql(expected) }
|
51
|
-
end
|
52
|
-
|
53
44
|
end
|
54
45
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
describe TupleComputation, "empty?" do
|
4
|
+
|
5
|
+
subject{ comp.empty? }
|
6
|
+
|
7
|
+
context 'when not empty' do
|
8
|
+
let(:comp){
|
9
|
+
TupleComputation[big?: ->{}, who: ->{}]
|
10
|
+
}
|
11
|
+
|
12
|
+
it{ should be_false }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when empty' do
|
16
|
+
let(:comp){
|
17
|
+
TupleComputation[{}]
|
18
|
+
}
|
19
|
+
|
20
|
+
it{ should be_true }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Alf
|
3
|
+
describe TupleComputation, "project" do
|
4
|
+
big = TupleExpression.coerce(->(t){ t.status > 10 })
|
5
|
+
who = TupleExpression.coerce(->(t){ t.name })
|
6
|
+
|
7
|
+
let(:comp){
|
8
|
+
TupleComputation[big?: big, who: who]
|
9
|
+
}
|
10
|
+
|
11
|
+
subject{ comp.project(list, allbut) }
|
12
|
+
|
13
|
+
context 'when not allbut' do
|
14
|
+
let(:allbut){ false }
|
15
|
+
|
16
|
+
[
|
17
|
+
[ [:big?, :who], TupleComputation[big?: big, who: who] ],
|
18
|
+
[ [:big?], TupleComputation[big?: big] ],
|
19
|
+
[ [:none], TupleComputation[{}] ],
|
20
|
+
].each do |(attrs,expected)|
|
21
|
+
context "on #{attrs}" do
|
22
|
+
let(:list){ attrs }
|
23
|
+
|
24
|
+
it{ should eq(expected) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when allbut' do
|
30
|
+
let(:allbut){ true }
|
31
|
+
|
32
|
+
[
|
33
|
+
[ [:big?, :who], TupleComputation[{}] ],
|
34
|
+
[ [:big?], TupleComputation[who: who] ],
|
35
|
+
[ [:none], TupleComputation[big?: big, who: who] ],
|
36
|
+
].each do |(attrs,expected)|
|
37
|
+
context "on #{attrs}" do
|
38
|
+
let(:list){ attrs }
|
39
|
+
|
40
|
+
it{ should eq(expected) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -13,21 +13,12 @@ module Alf
|
|
13
13
|
specify{ lambda{ subject }.should raise_error(ArgumentError) }
|
14
14
|
end
|
15
15
|
|
16
|
-
describe "with a String" do
|
17
|
-
let(:arg){ "true" }
|
18
|
-
it { should be_a(TupleExpression) }
|
19
|
-
specify{
|
20
|
-
subject.evaluate(scope).should eql(true)
|
21
|
-
subject.source.should eq("true")
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
16
|
describe "with a Symbol" do
|
26
17
|
let(:arg){ :status }
|
27
18
|
it { should be_a(TupleExpression) }
|
28
19
|
specify{
|
29
20
|
subject.evaluate(scope).should eql(10)
|
30
|
-
subject.source.should eq(
|
21
|
+
subject.source.should eq("t.status")
|
31
22
|
}
|
32
23
|
end
|
33
24
|
|
@@ -26,13 +26,5 @@ module Alf
|
|
26
26
|
it{ should be_a(Relation) }
|
27
27
|
end
|
28
28
|
|
29
|
-
context 'when the proc returns a unbound, yet boundable expression' do
|
30
|
-
let(:exp){ TupleExpression[->(t){ Algebra::Operand::Named.new(:suppliers) }] }
|
31
|
-
|
32
|
-
subject{ exp.evaluate(scope, examples_database) }
|
33
|
-
|
34
|
-
it{ should be_a(Relation) }
|
35
|
-
end
|
36
|
-
|
37
29
|
end # TupleExpression
|
38
30
|
end # Alf
|