activefacts 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +3 -80
- data/activefacts.gemspec +36 -0
- data/bin/afgen +4 -2
- data/bin/cql +5 -1
- data/lib/activefacts.rb +3 -12
- data/lib/activefacts/{vocabulary/query_evaluator.rb → query/evaluator.rb} +0 -0
- data/lib/activefacts/version.rb +2 -2
- metadata +48 -296
- data/History.txt +0 -4
- data/LICENSE +0 -19
- data/Manifest.txt +0 -165
- data/README.rdoc +0 -81
- data/css/offline.css +0 -3
- data/css/orm2.css +0 -124
- data/css/print.css +0 -8
- data/css/style-print.css +0 -357
- data/css/style.css +0 -387
- data/download.html +0 -110
- data/examples/CQL/Address.cql +0 -44
- data/examples/CQL/Blog.cql +0 -54
- data/examples/CQL/CompanyDirectorEmployee.cql +0 -56
- data/examples/CQL/Death.cql +0 -17
- data/examples/CQL/Diplomacy.cql +0 -48
- data/examples/CQL/Genealogy.cql +0 -98
- data/examples/CQL/Insurance.cql +0 -320
- data/examples/CQL/Marriage.cql +0 -18
- data/examples/CQL/Metamodel.cql +0 -493
- data/examples/CQL/Monogamy.cql +0 -24
- data/examples/CQL/MultiInheritance.cql +0 -22
- data/examples/CQL/NonRoleId.cql +0 -14
- data/examples/CQL/OddIdentifier.cql +0 -18
- data/examples/CQL/OilSupply.cql +0 -53
- data/examples/CQL/OneToOnes.cql +0 -17
- data/examples/CQL/Orienteering.cql +0 -111
- data/examples/CQL/PersonPlaysGame.cql +0 -18
- data/examples/CQL/RedundantDependency.cql +0 -34
- data/examples/CQL/SchoolActivities.cql +0 -33
- data/examples/CQL/SeparateSubtype.cql +0 -30
- data/examples/CQL/ServiceDirector.cql +0 -276
- data/examples/CQL/SimplestUnary.cql +0 -12
- data/examples/CQL/Supervision.cql +0 -34
- data/examples/CQL/WaiterTips.cql +0 -33
- data/examples/CQL/Warehousing.cql +0 -101
- data/examples/CQL/WindowInRoomInBldg.cql +0 -28
- data/examples/CQL/unit.cql +0 -474
- data/examples/index.html +0 -420
- data/examples/intro.html +0 -327
- data/examples/local.css +0 -24
- data/index.html +0 -111
- data/lib/activefacts/cql.rb +0 -35
- data/lib/activefacts/cql/CQLParser.treetop +0 -158
- data/lib/activefacts/cql/Context.treetop +0 -48
- data/lib/activefacts/cql/Expressions.treetop +0 -67
- data/lib/activefacts/cql/FactTypes.treetop +0 -358
- data/lib/activefacts/cql/Language/English.treetop +0 -315
- data/lib/activefacts/cql/LexicalRules.treetop +0 -253
- data/lib/activefacts/cql/ObjectTypes.treetop +0 -210
- data/lib/activefacts/cql/Rakefile +0 -14
- data/lib/activefacts/cql/Terms.treetop +0 -183
- data/lib/activefacts/cql/ValueTypes.treetop +0 -202
- data/lib/activefacts/cql/compiler.rb +0 -156
- data/lib/activefacts/cql/compiler/clause.rb +0 -1137
- data/lib/activefacts/cql/compiler/constraint.rb +0 -581
- data/lib/activefacts/cql/compiler/entity_type.rb +0 -457
- data/lib/activefacts/cql/compiler/expression.rb +0 -443
- data/lib/activefacts/cql/compiler/fact.rb +0 -390
- data/lib/activefacts/cql/compiler/fact_type.rb +0 -421
- data/lib/activefacts/cql/compiler/query.rb +0 -106
- data/lib/activefacts/cql/compiler/shared.rb +0 -161
- data/lib/activefacts/cql/compiler/value_type.rb +0 -174
- data/lib/activefacts/cql/nodes.rb +0 -49
- data/lib/activefacts/cql/parser.rb +0 -241
- data/lib/activefacts/dependency_analyser.rb +0 -182
- data/lib/activefacts/generate/absorption.rb +0 -70
- data/lib/activefacts/generate/composition.rb +0 -118
- data/lib/activefacts/generate/cql.rb +0 -714
- data/lib/activefacts/generate/dm.rb +0 -279
- data/lib/activefacts/generate/help.rb +0 -64
- data/lib/activefacts/generate/helpers/inject.rb +0 -16
- data/lib/activefacts/generate/helpers/oo.rb +0 -162
- data/lib/activefacts/generate/helpers/ordered.rb +0 -605
- data/lib/activefacts/generate/helpers/rails.rb +0 -57
- data/lib/activefacts/generate/html/glossary.rb +0 -461
- data/lib/activefacts/generate/json.rb +0 -337
- data/lib/activefacts/generate/null.rb +0 -32
- data/lib/activefacts/generate/rails/models.rb +0 -246
- data/lib/activefacts/generate/rails/schema.rb +0 -216
- data/lib/activefacts/generate/records.rb +0 -46
- data/lib/activefacts/generate/ruby.rb +0 -133
- data/lib/activefacts/generate/sql/mysql.rb +0 -280
- data/lib/activefacts/generate/sql/server.rb +0 -273
- data/lib/activefacts/generate/stats.rb +0 -69
- data/lib/activefacts/generate/text.rb +0 -27
- data/lib/activefacts/generate/topics.rb +0 -265
- data/lib/activefacts/generate/traits/datavault.rb +0 -241
- data/lib/activefacts/generate/traits/oo.rb +0 -73
- data/lib/activefacts/generate/traits/ordered.rb +0 -33
- data/lib/activefacts/generate/traits/ruby.rb +0 -210
- data/lib/activefacts/generate/transform/datavault.rb +0 -266
- data/lib/activefacts/generate/transform/surrogate.rb +0 -214
- data/lib/activefacts/generate/version.rb +0 -26
- data/lib/activefacts/input/cql.rb +0 -43
- data/lib/activefacts/input/orm.rb +0 -1636
- data/lib/activefacts/mapping/rails.rb +0 -132
- data/lib/activefacts/persistence.rb +0 -15
- data/lib/activefacts/persistence/columns.rb +0 -446
- data/lib/activefacts/persistence/foreignkey.rb +0 -187
- data/lib/activefacts/persistence/index.rb +0 -240
- data/lib/activefacts/persistence/object_type.rb +0 -198
- data/lib/activefacts/persistence/reference.rb +0 -434
- data/lib/activefacts/persistence/tables.rb +0 -380
- data/lib/activefacts/registry.rb +0 -11
- data/lib/activefacts/support.rb +0 -132
- data/lib/activefacts/vocabulary.rb +0 -9
- data/lib/activefacts/vocabulary/extensions.rb +0 -1348
- data/lib/activefacts/vocabulary/metamodel.rb +0 -570
- data/lib/activefacts/vocabulary/verbaliser.rb +0 -804
- data/script/txt2html +0 -71
- data/spec/absorption_spec.rb +0 -95
- data/spec/cql/comparison_spec.rb +0 -89
- data/spec/cql/context_spec.rb +0 -94
- data/spec/cql/contractions_spec.rb +0 -224
- data/spec/cql/deontic_spec.rb +0 -88
- data/spec/cql/entity_type_spec.rb +0 -320
- data/spec/cql/expressions_spec.rb +0 -66
- data/spec/cql/fact_type_matching_spec.rb +0 -338
- data/spec/cql/french_spec.rb +0 -21
- data/spec/cql/parser/bad_literals_spec.rb +0 -86
- data/spec/cql/parser/constraints_spec.rb +0 -19
- data/spec/cql/parser/entity_types_spec.rb +0 -106
- data/spec/cql/parser/expressions_spec.rb +0 -199
- data/spec/cql/parser/fact_types_spec.rb +0 -44
- data/spec/cql/parser/literals_spec.rb +0 -312
- data/spec/cql/parser/pragmas_spec.rb +0 -89
- data/spec/cql/parser/value_types_spec.rb +0 -42
- data/spec/cql/role_matching_spec.rb +0 -148
- data/spec/cql/samples_spec.rb +0 -244
- data/spec/cql_cql_spec.rb +0 -73
- data/spec/cql_dm_spec.rb +0 -136
- data/spec/cql_mysql_spec.rb +0 -69
- data/spec/cql_parse_spec.rb +0 -34
- data/spec/cql_ruby_spec.rb +0 -73
- data/spec/cql_sql_spec.rb +0 -72
- data/spec/cql_symbol_tables_spec.rb +0 -261
- data/spec/cqldump_spec.rb +0 -170
- data/spec/helpers/array_matcher.rb +0 -23
- data/spec/helpers/ctrl_c_support.rb +0 -52
- data/spec/helpers/diff_matcher.rb +0 -39
- data/spec/helpers/file_matcher.rb +0 -34
- data/spec/helpers/parse_to_ast_matcher.rb +0 -80
- data/spec/helpers/string_matcher.rb +0 -30
- data/spec/helpers/test_parser.rb +0 -15
- data/spec/norma_cql_spec.rb +0 -66
- data/spec/norma_ruby_spec.rb +0 -62
- data/spec/norma_ruby_sql_spec.rb +0 -107
- data/spec/norma_sql_spec.rb +0 -57
- data/spec/norma_tables_spec.rb +0 -95
- data/spec/ruby_api_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -35
- data/spec/transform_surrogate_spec.rb +0 -59
- data/status.html +0 -138
- data/why.html +0 -60
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# ActiveFacts tests: Test the CQL parser by looking at its parse trees.
|
|
3
|
-
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
=begin
|
|
7
|
-
|
|
8
|
-
require 'activefacts/support'
|
|
9
|
-
require 'activefacts/api/support'
|
|
10
|
-
require 'activefacts/input/cql'
|
|
11
|
-
|
|
12
|
-
describe "CQL Symbol table" do
|
|
13
|
-
|
|
14
|
-
# A Form here is a form of reference to a object_type, being a name and optional adjectives, possibly designated by a role name:
|
|
15
|
-
# Struct.new("Form", :object_type, :name, :leading_adjective, :trailing_adjective, :role_name)
|
|
16
|
-
# def initialize(constellation, vocabulary)
|
|
17
|
-
# def bind(words, leading_adjective = nil, trailing_adjective = nil, role_name = nil, allowed_forward = false, leading_speculative = false, trailing_speculative = false)
|
|
18
|
-
|
|
19
|
-
before :each do
|
|
20
|
-
include ActiveFacts::Input::CQL
|
|
21
|
-
@constellation = ActiveFacts::API::Constellation.new(ActiveFacts::Metamodel)
|
|
22
|
-
@vocabulary = @constellation.Vocabulary("Test")
|
|
23
|
-
@symbols = ActiveFacts::CQL::Compiler::SymbolTable.new(@constellation, @vocabulary)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
Definitions = [
|
|
27
|
-
[ "predefined value type",
|
|
28
|
-
["Date"],
|
|
29
|
-
["Date", nil, nil, nil]],
|
|
30
|
-
[ "predefined value type as word array",
|
|
31
|
-
[["Date"]],
|
|
32
|
-
["Date", nil, nil, nil]],
|
|
33
|
-
[ "predefined value type with inline leading adjective",
|
|
34
|
-
[["Birth", "Date"]],
|
|
35
|
-
["Date", "Birth", nil, nil]],
|
|
36
|
-
[ "predefined value types with inline trailing adjective",
|
|
37
|
-
[["Date", "OfBirth"]],
|
|
38
|
-
["Date", nil, "OfBirth", nil]],
|
|
39
|
-
[ "predefined value type with two inline adjectives",
|
|
40
|
-
[["Second", "Birth", "Date"]],
|
|
41
|
-
nil], # Illegal
|
|
42
|
-
[ "predefined value type with defined leading adjective",
|
|
43
|
-
["Date", "Birth"],
|
|
44
|
-
["Date", "Birth", nil, nil]],
|
|
45
|
-
[ "predefined value types with defined trailing adjective",
|
|
46
|
-
["Date", nil, "OfBirth"],
|
|
47
|
-
["Date", nil, "OfBirth", nil]],
|
|
48
|
-
[ "predefined value type with inline and defined leading adjective",
|
|
49
|
-
[["Second", "Date"], "Birth"],
|
|
50
|
-
nil], # Illegal
|
|
51
|
-
[ "predefined value types with inline and defined trailing adjective",
|
|
52
|
-
[["Second", "Date"], nil, "OfBirth"],
|
|
53
|
-
nil], # Illegal
|
|
54
|
-
|
|
55
|
-
[ "predefined type with role name",
|
|
56
|
-
["Date", nil, nil, "BirthDate"],
|
|
57
|
-
["Date", nil, nil, "BirthDate"]],
|
|
58
|
-
|
|
59
|
-
[ "forward-referenced type",
|
|
60
|
-
["Unknown", nil, nil, nil, true],
|
|
61
|
-
["Unknown", nil, nil, nil]],
|
|
62
|
-
[ "forward-referenced type with inline adjective",
|
|
63
|
-
[["Haha", "Unknown"], nil, nil, nil, true],
|
|
64
|
-
nil], # Illegal
|
|
65
|
-
|
|
66
|
-
[ "entity type",
|
|
67
|
-
["Person"],
|
|
68
|
-
["Person", nil, nil, nil]],
|
|
69
|
-
[ "entity type as word array",
|
|
70
|
-
[["Person"]],
|
|
71
|
-
["Person", nil, nil, nil]],
|
|
72
|
-
[ "entity type with inline leading adjective",
|
|
73
|
-
[["Birth", "Person"]],
|
|
74
|
-
["Person", "Birth", nil, nil]],
|
|
75
|
-
[ "entity types with inline trailing adjective",
|
|
76
|
-
[["Person", "OfBirth"]],
|
|
77
|
-
["Person", nil, "OfBirth", nil]],
|
|
78
|
-
[ "entity type with two inline adjectives",
|
|
79
|
-
[["Second", "Birth", "Person"]],
|
|
80
|
-
nil], # Illegal
|
|
81
|
-
[ "entity type with defined leading adjective",
|
|
82
|
-
["Person", "Birth"],
|
|
83
|
-
["Person", "Birth", nil, nil]],
|
|
84
|
-
[ "entity types with defined trailing adjective",
|
|
85
|
-
["Person", nil, "OfBirth"],
|
|
86
|
-
["Person", nil, "OfBirth", nil]],
|
|
87
|
-
[ "entity type with inline and defined leading adjective",
|
|
88
|
-
[["Second", "Person"], "Birth"],
|
|
89
|
-
nil], # Illegal
|
|
90
|
-
[ "entity types with inline and defined trailing adjective",
|
|
91
|
-
[["Second", "Person"], nil, "OfBirth"],
|
|
92
|
-
nil], # Illegal
|
|
93
|
-
|
|
94
|
-
[ "entity type with role name",
|
|
95
|
-
["Person", nil, nil, "Father"],
|
|
96
|
-
["Person", nil, nil, "Father"]],
|
|
97
|
-
]
|
|
98
|
-
|
|
99
|
-
Definitions.each do |c|
|
|
100
|
-
description, args, result = *c
|
|
101
|
-
|
|
102
|
-
it "should define #{description}" do
|
|
103
|
-
if result
|
|
104
|
-
# Predefine an entity type, some cases use it:
|
|
105
|
-
@constellation.EntityType(@vocabulary.identifying_role_values, "Person", :guid => :new)
|
|
106
|
-
|
|
107
|
-
player, bound = @symbols.bind(*args)
|
|
108
|
-
player.should_not be_nil
|
|
109
|
-
player.should == bound.object_type
|
|
110
|
-
[bound.name, bound.leading_adjective, bound.trailing_adjective, bound.role_name].should == result
|
|
111
|
-
else
|
|
112
|
-
lambda {player, bound = @symbols.bind(*args)}.should raise_error
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "should disallow binding to a role name where a leading adjective is provided" do
|
|
118
|
-
object_type, = @symbols.bind("Name", nil, nil, "GivenName", true)
|
|
119
|
-
lambda{player, bound = @symbols.bind("GivenName", "SomeAdj")}.should raise_error
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "should disallow binding to a role name where a trailing adjective is provided" do
|
|
123
|
-
object_type, = @symbols.bind("Name", nil, nil, "GivenName", true)
|
|
124
|
-
lambda{player, bound = @symbols.bind("GivenName", nil, "SomeAdj")}.should raise_error
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should disallow binding to a role name and defining a new role name" do
|
|
128
|
-
object_type, = @symbols.bind("Name", nil, nil, "GivenName", true)
|
|
129
|
-
lambda{player, bound = @symbols.bind("GivenName", nil, nil, "SomeName")}.should raise_error
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
Predefined = [
|
|
133
|
-
[ "Name", "Given", nil, nil, true ],
|
|
134
|
-
[ "Nom", nil, "Donné", nil, true ],
|
|
135
|
-
[ "Name", nil, nil, "GivenName", true ],
|
|
136
|
-
[ "Simple", nil, nil, ],
|
|
137
|
-
]
|
|
138
|
-
|
|
139
|
-
it "should allow adding a role name to an adjectival form without one" do
|
|
140
|
-
object_type, = @symbols.bind("Name", "Given", nil, nil, true)
|
|
141
|
-
player, bound = @symbols.bind("Name", nil, nil, "GivenName")
|
|
142
|
-
player.should == object_type
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "should create new binding with a role name rather than binding to existing simple player without adjectives" do
|
|
146
|
-
object_type, bare = @symbols.bind("Name", nil, nil, nil, true)
|
|
147
|
-
player, bound = @symbols.bind("Name", nil, nil, "SomeAdj")
|
|
148
|
-
bare.should_not == bound
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should disallow adding a role name which is the name of an existing object_type" do
|
|
152
|
-
object_type, = @symbols.bind("Name", "Given", nil, nil, true)
|
|
153
|
-
lambda{player, bound = @symbols.bind("Name", "Given", nil, "Date")}.should raise_error
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "should disallow adding a role name to a role player that already has one" do
|
|
157
|
-
object_type, first = @symbols.bind("Name", "Given", nil, "GivenName", true)
|
|
158
|
-
player, bound = @symbols.bind("Name", "Given", nil, "FirstName")
|
|
159
|
-
first.should_not == bound
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "should bind to an existing player without adjectives" do
|
|
163
|
-
object_type, = @symbols.bind("Name", nil, nil, nil, true)
|
|
164
|
-
player, bound = @symbols.bind("Name")
|
|
165
|
-
player.should == object_type
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "should bind to an existing player using a leading adjective" do
|
|
169
|
-
object_type, = @symbols.bind("Name", nil, nil, nil, true)
|
|
170
|
-
player, bound = @symbols.bind("Name", "Given")
|
|
171
|
-
player.should == object_type
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "should bind to an existing player using a trailing adjective" do
|
|
175
|
-
object_type, = @symbols.bind("Name", nil, nil, nil, true)
|
|
176
|
-
player, bound = @symbols.bind("Name", nil, "Donné")
|
|
177
|
-
player.should == object_type
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it "should bind to an existing player only using the defined leading adjective" do
|
|
181
|
-
object_type, = @symbols.bind("Name", "Given", nil, nil, true)
|
|
182
|
-
player, bound = @symbols.bind("Name", "Given")
|
|
183
|
-
player.should == object_type
|
|
184
|
-
forms = [bound]
|
|
185
|
-
|
|
186
|
-
player, alt = @symbols.bind("Name")
|
|
187
|
-
forms.should_not be_include(alt)
|
|
188
|
-
forms << alt
|
|
189
|
-
|
|
190
|
-
player, alt = @symbols.bind("Name", nil, "Donné")
|
|
191
|
-
forms.should_not be_include(alt)
|
|
192
|
-
forms << alt
|
|
193
|
-
|
|
194
|
-
player, alt = @symbols.bind("Name", "Given", "Donné")
|
|
195
|
-
forms.should_not be_include(alt)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it "should bind to an existing player only using a defined trailing adjective" do
|
|
199
|
-
object_type, = @symbols.bind("Name", nil, "Donné", nil, true)
|
|
200
|
-
player, bound = @symbols.bind("Name", nil, "Donné")
|
|
201
|
-
player.should == object_type
|
|
202
|
-
forms = [bound]
|
|
203
|
-
|
|
204
|
-
player, alt = @symbols.bind("Name")
|
|
205
|
-
forms.should_not be_include(alt)
|
|
206
|
-
forms << alt
|
|
207
|
-
|
|
208
|
-
player, alt = @symbols.bind("Name", "Given")
|
|
209
|
-
forms.should_not be_include(alt)
|
|
210
|
-
forms << alt
|
|
211
|
-
|
|
212
|
-
player, alt = @symbols.bind("Name", "Given", "Donné")
|
|
213
|
-
forms.should_not be_include(alt)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it "should bind to an existing player only using defined leading and trailing adjective" do
|
|
217
|
-
object_type, = @symbols.bind("Name", "Given", "Donné", nil, true)
|
|
218
|
-
player, bound = @symbols.bind("Name", "Given", "Donné")
|
|
219
|
-
player.should == object_type
|
|
220
|
-
forms = [bound]
|
|
221
|
-
|
|
222
|
-
player, alt = @symbols.bind("Name")
|
|
223
|
-
forms.should_not be_include(alt)
|
|
224
|
-
forms << alt
|
|
225
|
-
|
|
226
|
-
player, alt = @symbols.bind("Name", "Given")
|
|
227
|
-
forms.should_not be_include(alt)
|
|
228
|
-
forms << alt
|
|
229
|
-
|
|
230
|
-
player, alt = @symbols.bind("Name", nil, "Donné")
|
|
231
|
-
forms.should_not be_include(alt)
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
it "should bind to an existing player using a speculative leading adjective" do
|
|
235
|
-
object_type, = @symbols.bind("Name", "Given", nil, nil, true)
|
|
236
|
-
player, bound = @symbols.bind("Name", l = "Given", t = "Donné", nil, nil, true, true)
|
|
237
|
-
player.should == object_type
|
|
238
|
-
bound.leading_adjective.should == "Given"
|
|
239
|
-
bound.trailing_adjective.should be_nil
|
|
240
|
-
l.should be_empty
|
|
241
|
-
t.should == "Donné"
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
it "should bind to an existing player using a speculative trailing adjective" do
|
|
245
|
-
object_type, = @symbols.bind("Name", nil, "Donné", nil, true)
|
|
246
|
-
player, bound = @symbols.bind("Name", l = "Given", t = "Donné", nil, nil, true, true)
|
|
247
|
-
player.should == object_type
|
|
248
|
-
l.should == "Given"
|
|
249
|
-
t.should be_empty
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
it "should bind to an existing player using a speculative leading and trailing adjective" do
|
|
253
|
-
object_type, = @symbols.bind("Name", "Given", "Donné", nil, true)
|
|
254
|
-
player, bound = @symbols.bind("Name", l = "Given", t = "Donné", nil, nil, true, true)
|
|
255
|
-
player.should == object_type
|
|
256
|
-
l.should be_empty
|
|
257
|
-
t.should be_empty
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
end
|
|
261
|
-
=end
|
data/spec/cqldump_spec.rb
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# ActiveFacts tests: Test the generated CQL for some simple cases.
|
|
3
|
-
# Copyright (c) 2008 Clifford Heath. Read the LICENSE file.
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
require 'stringio'
|
|
7
|
-
require 'activefacts'
|
|
8
|
-
require 'activefacts/support'
|
|
9
|
-
require 'activefacts/vocabulary'
|
|
10
|
-
require 'activefacts/generate/cql'
|
|
11
|
-
|
|
12
|
-
describe "CQL Dumper" do
|
|
13
|
-
def self.hide(*a,&b)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
before :each do
|
|
17
|
-
@constellation = ActiveFacts::API::Constellation.new(ActiveFacts::Metamodel)
|
|
18
|
-
@vocabulary = @constellation.Vocabulary("TestVocab")
|
|
19
|
-
@string_type = @constellation.ValueType(@vocabulary, "String", :concept => :new)
|
|
20
|
-
@integer_type = @constellation.ValueType(@vocabulary, "Integer", :concept => :new)
|
|
21
|
-
@dumper = ActiveFacts::Generate::CQL.new(@constellation)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def cql
|
|
25
|
-
output = StringIO.new
|
|
26
|
-
@dumper.generate(output)
|
|
27
|
-
output.rewind
|
|
28
|
-
output.read
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should dump a String ValueType" do
|
|
32
|
-
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20, :concept => :new)
|
|
33
|
-
vt.supertype = @string_type
|
|
34
|
-
vt.length = 20
|
|
35
|
-
#p vt.class.roles.keys.sort_by{|s| s.to_s}
|
|
36
|
-
#p vt.supertype
|
|
37
|
-
cql.should == <<END
|
|
38
|
-
vocabulary TestVocab;
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
* Value Types
|
|
42
|
-
*/
|
|
43
|
-
Name is written as String(20);
|
|
44
|
-
|
|
45
|
-
END
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "should dump an Integer ValueType" do
|
|
49
|
-
vt = @constellation.ValueType(@vocabulary, "Count", :supertype => @integer_type, :length => 32, :concept => :new)
|
|
50
|
-
cql.should == <<END
|
|
51
|
-
vocabulary TestVocab;
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
* Value Types
|
|
55
|
-
*/
|
|
56
|
-
Count is written as Integer(32);
|
|
57
|
-
|
|
58
|
-
END
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def value_type(name, datatype = "String", length = 0, scale = 0)
|
|
62
|
-
dt = @constellation.ValueType[[@vocabulary.identifying_role_values, datatype]] ||
|
|
63
|
-
@constellation.ValueType(@vocabulary, datatype, :concept => :new)
|
|
64
|
-
vt = @constellation.ValueType[[@vocabulary.identifying_role_values, name]] ||
|
|
65
|
-
@constellation.ValueType(@vocabulary, name, :supertype => dt, :concept => :new)
|
|
66
|
-
vt.length = length if length != 0
|
|
67
|
-
vt.scale = scale if scale != 0
|
|
68
|
-
vt
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def one_to_many(one, many, reading)
|
|
72
|
-
# Combine them with a fact type:
|
|
73
|
-
ft = @constellation.FactType(:new)
|
|
74
|
-
role0 = @constellation.Role(ft, 0, :object_type => one, :concept => :new)
|
|
75
|
-
role1 = @constellation.Role(ft, 1, :object_type => many, :concept => :new)
|
|
76
|
-
|
|
77
|
-
# Make a role sequence:
|
|
78
|
-
rs = @constellation.RoleSequence(:new)
|
|
79
|
-
rr0 = @constellation.RoleRef(rs, 0, :role => role0)
|
|
80
|
-
rr1 = @constellation.RoleRef(rs, 1, :role => role1)
|
|
81
|
-
|
|
82
|
-
# Make a uniqueness constraint:
|
|
83
|
-
pcrs = @constellation.RoleSequence(:new)
|
|
84
|
-
@constellation.RoleRef(pcrs, 0, :role => role0)
|
|
85
|
-
pc = @constellation.PresenceConstraint(:new, :is_mandatory => false, :is_preferred_identifier => false, :max_frequency => 1, :min_frequency => 0, :role_sequence => pcrs)
|
|
86
|
-
|
|
87
|
-
# Make a new reading:
|
|
88
|
-
reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :text => reading)
|
|
89
|
-
|
|
90
|
-
ft
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def one_to_one(first, second, reading)
|
|
94
|
-
# Combine them with a fact type:
|
|
95
|
-
ft = @constellation.FactType(:new)
|
|
96
|
-
role0 = @constellation.Role(ft, 0, :object_type => first, :concept => :new)
|
|
97
|
-
role1 = @constellation.Role(ft, 1, :object_type => second, :concept => :new)
|
|
98
|
-
|
|
99
|
-
# Make a role sequence for the reading
|
|
100
|
-
rs = @constellation.RoleSequence(:new)
|
|
101
|
-
rr0 = @constellation.RoleRef(rs, 0, :role => role0)
|
|
102
|
-
rr1 = @constellation.RoleRef(rs, 1, :role => role1)
|
|
103
|
-
|
|
104
|
-
# Make a new reading:
|
|
105
|
-
reading = @constellation.Reading(ft, ft.all_reading.size, :role_sequence => rs, :text => reading)
|
|
106
|
-
|
|
107
|
-
# Make a uniqueness constraint for the first role
|
|
108
|
-
first_rs = @constellation.RoleSequence(:new)
|
|
109
|
-
@constellation.RoleRef(first_rs, 0, :role => role0)
|
|
110
|
-
first_pc = @constellation.PresenceConstraint(:new, :is_mandatory => true, :is_preferred_identifier => false, :max_frequency => 1, :min_frequency => 1, :role_sequence => first_rs)
|
|
111
|
-
|
|
112
|
-
# Make a uniqueness constraint for the second role
|
|
113
|
-
second_rs = @constellation.RoleSequence(:new)
|
|
114
|
-
@constellation.RoleRef(second_rs, 0, :role => role1)
|
|
115
|
-
second_pc = @constellation.PresenceConstraint(:new, :is_mandatory => true, :is_preferred_identifier => true, :max_frequency => 1, :min_frequency => 1, :role_sequence => second_rs)
|
|
116
|
-
|
|
117
|
-
ft
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "should dump a VT-VT FactType" do
|
|
121
|
-
# Make two valuetypes:
|
|
122
|
-
st = value_type("Name", "String", 20)
|
|
123
|
-
vt = value_type("Count", "Integer", 32)
|
|
124
|
-
|
|
125
|
-
ft = one_to_many(st, vt, "{0} occurs {1} times")
|
|
126
|
-
|
|
127
|
-
#puts @constellation.verbalise #; exit
|
|
128
|
-
|
|
129
|
-
cql.should == <<END
|
|
130
|
-
vocabulary TestVocab;
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
* Value Types
|
|
134
|
-
*/
|
|
135
|
-
Count is written as Integer(32);
|
|
136
|
-
Name is written as String(20);
|
|
137
|
-
|
|
138
|
-
/*
|
|
139
|
-
* Fact Types
|
|
140
|
-
*/
|
|
141
|
-
Name occurs Count times;
|
|
142
|
-
|
|
143
|
-
END
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "should dump an named EntityType" do
|
|
147
|
-
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20, :concept => :new)
|
|
148
|
-
et = @constellation.EntityType(@vocabulary, "Company", :concept => :new)
|
|
149
|
-
|
|
150
|
-
ft = one_to_one(et, vt, "{0} is called {1}")
|
|
151
|
-
|
|
152
|
-
cql.should == <<END
|
|
153
|
-
vocabulary TestVocab;
|
|
154
|
-
|
|
155
|
-
/*
|
|
156
|
-
* Value Types
|
|
157
|
-
*/
|
|
158
|
-
Name is written as String(20);
|
|
159
|
-
|
|
160
|
-
/*
|
|
161
|
-
* Entity Types
|
|
162
|
-
*/
|
|
163
|
-
Company is identified by Name where
|
|
164
|
-
Company is called Name;
|
|
165
|
-
|
|
166
|
-
END
|
|
167
|
-
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
RSpec::Matchers.define :be_different_array_from do |x|
|
|
2
|
-
match do |actual|
|
|
3
|
-
perform_match(actual, expected_as_array)
|
|
4
|
-
@extra + @missing != []
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def perform_match(actual, expected)
|
|
8
|
-
@extra = actual - expected
|
|
9
|
-
@missing = expected - actual
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
failure_message_for_should do |actual|
|
|
13
|
-
"expected a difference in the two lists, but got none"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
failure_message_for_should_not do |actual|
|
|
17
|
-
"expected no difference, but result #{
|
|
18
|
-
[ (@missing.empty? ? nil : 'lacks '+@missing.sort.inspect),
|
|
19
|
-
(@extra.empty? ? nil : 'has extra '+@extra.sort.inspect)
|
|
20
|
-
].compact * ' and '
|
|
21
|
-
}"
|
|
22
|
-
end
|
|
23
|
-
end
|