Sha256: c19bc51ccf2ae08adebe4b85ee3956bdca658992629af722e3d21428252c5b34

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 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 'helpers/test_parser'

describe "Value Types" do
  ValueTypes = [
    [ "a is written as b(1, 2) inch restricted to { 3 .. 4 } inch ;",
      ['ValueType: a is written as b(1, 2) in [["inch", 1]] ValueConstraint to ([3..4]) in [["inch", 1]];']
    ],
#    [ "a c  is written as b(1, 2) inch restricted to { 3 .. 4 } inch ;",
#      [["a c", [:value_type, "b", [1, 2], "inch", [[3, 4]]]]]
#    ],
  ]

  before :each do
    @parser = TestParser.new
  end

  ValueTypes.each do |c|
    source, ast = *c
    it "should parse #{source.inspect}" do
      result = @parser.parse_all(source, :definition)

      puts @parser.failure_reason unless result
      result.should_not be_nil

      canonical_form = result.map{|d| d.ast.to_s}
      if ast
        canonical_form.should == ast
      else
        puts "#{source.inspect} should compile to"
        puts "\t#{canonical_form}"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activefacts-1.1.0 spec/cql/parser/value_types_spec.rb
activefacts-1.0.2 spec/cql/parser/value_types_spec.rb
activefacts-1.0.1 spec/cql/parser/value_types_spec.rb
activefacts-1.0.0 spec/cql/parser/value_types_spec.rb
activefacts-0.8.18 spec/cql/parser/value_types_spec.rb
activefacts-0.8.16 spec/cql/parser/value_types_spec.rb
activefacts-0.8.15 spec/cql/parser/value_types_spec.rb
activefacts-0.8.13 spec/cql/parser/value_types_spec.rb
activefacts-0.8.12 spec/cql/parser/value_types_spec.rb
activefacts-0.8.10 spec/cql/parser/value_types_spec.rb