Sha256: a5ed6339fba57572806f0065063c79dce2bc87e274e7d4b68c52b7c2b9d1c9cd

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

#
# ActiveFacts tests: Test the CQL parser by looking at its parse trees.
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
#

require 'activefacts/cql'
require 'activefacts/support'
require 'activefacts/api/support'
require 'spec_helper'
require 'helpers/test_parser'

describe "Fact Types" do
  FactTypes = [
    [ "Foo has at most one Bar, Bar is of one Foo restricted to {1..10};",
      ["FactType: [{Foo} \"has\" {[..1] Bar}, {Bar} \"is of\" {[1..1] Foo ValueConstraint to ([1..10])}]"]
    ],
    [ "Bar(1) is related to Bar(2), primary-Bar(1) has secondary-Bar(2);",
      ["FactType: [{Bar(1)} \"is related to\" {Bar(2)}, {primary- Bar(1)} \"has\" {secondary- Bar(2)}]"]
    ],
    # REVISIT: Test all quantifiers
    # REVISIT: Test all post-qualifiers
#    [ "AnnualIncome is where Person has total- Income in Year: Person has total- Income.sum(), Income was earned in current- Time.Year() (as Year);",
#      [%q{FactType: AnnualIncome [{Person} "has" {total- Income} "in" {Year}] where {Person} "has" {total- Income}.sum() , {Income} "was earned in" {current- Time (as Year)}.Year()}]
#    ],
    [ "A is interesting : b- C has F -g;",
      [%q{FactType: Query: where {b- C} "has" {F -g} [{A} "is interesting"]}]
    ],
    [ "A has one pre-- bound B;",
      [%q{FactType: [{A} "has" {[1..1] pre-bound- B}]}]
    ]
    # REVISIT: Test all quantifiers
  ]

  before :each do
    @parser = TestParser.new
  end

  FactTypes.each do |c|
    source, ast, definition = *c
    it "should parse #{source.inspect}" do
      source.should parse_to_ast *ast
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activefacts-1.6.0 spec/cql/parser/fact_types_spec.rb
activefacts-1.5.3 spec/cql/parser/fact_types_spec.rb
activefacts-1.5.2 spec/cql/parser/fact_types_spec.rb
activefacts-1.5.1 spec/cql/parser/fact_types_spec.rb
activefacts-1.5.0 spec/cql/parser/fact_types_spec.rb
activefacts-1.3.0 spec/cql/parser/fact_types_spec.rb
activefacts-1.2.1 spec/cql/parser/fact_types_spec.rb
activefacts-1.2.0 spec/cql/parser/fact_types_spec.rb