expressir 1.3.3-aarch64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +7 -0
  2. data/.cross_rubies +28 -0
  3. data/.github/workflows/codeql.yml +47 -0
  4. data/.github/workflows/rake.yml +448 -0
  5. data/.github/workflows/release.yml +189 -0
  6. data/.github/workflows/stress.yml +53 -0
  7. data/.gitignore +23 -0
  8. data/.gitmodules +6 -0
  9. data/.hound.yml +3 -0
  10. data/.rspec +2 -0
  11. data/.rubocop.yml +18 -0
  12. data/.yardopts +11 -0
  13. data/Gemfile +4 -0
  14. data/README.adoc +155 -0
  15. data/Rakefile +17 -0
  16. data/bin/console +11 -0
  17. data/bin/rspec +29 -0
  18. data/bin/setup +8 -0
  19. data/docs/development.md +90 -0
  20. data/exe/expressir +22 -0
  21. data/exe/format +18 -0
  22. data/exe/format-test +81 -0
  23. data/exe/generate-parser +51 -0
  24. data/expressir.gemspec +48 -0
  25. data/lib/expressir/cli/ui.rb +36 -0
  26. data/lib/expressir/cli.rb +21 -0
  27. data/lib/expressir/config.rb +23 -0
  28. data/lib/expressir/express/2.7/express_parser.so +0 -0
  29. data/lib/expressir/express/3.0/express_parser.so +0 -0
  30. data/lib/expressir/express/3.1/express_parser.so +0 -0
  31. data/lib/expressir/express/3.2/express_parser.so +0 -0
  32. data/lib/expressir/express/cache.rb +51 -0
  33. data/lib/expressir/express/formatter.rb +1608 -0
  34. data/lib/expressir/express/hyperlink_formatter.rb +36 -0
  35. data/lib/expressir/express/model_visitor.rb +24 -0
  36. data/lib/expressir/express/parser.rb +83 -0
  37. data/lib/expressir/express/resolve_references_model_visitor.rb +31 -0
  38. data/lib/expressir/express/schema_head_formatter.rb +23 -0
  39. data/lib/expressir/express/visitor.rb +2591 -0
  40. data/lib/expressir/model/cache.rb +17 -0
  41. data/lib/expressir/model/data_type.rb +9 -0
  42. data/lib/expressir/model/data_types/aggregate.rb +31 -0
  43. data/lib/expressir/model/data_types/array.rb +31 -0
  44. data/lib/expressir/model/data_types/bag.rb +25 -0
  45. data/lib/expressir/model/data_types/binary.rb +22 -0
  46. data/lib/expressir/model/data_types/boolean.rb +10 -0
  47. data/lib/expressir/model/data_types/enumeration.rb +25 -0
  48. data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
  49. data/lib/expressir/model/data_types/generic.rb +26 -0
  50. data/lib/expressir/model/data_types/generic_entity.rb +26 -0
  51. data/lib/expressir/model/data_types/integer.rb +10 -0
  52. data/lib/expressir/model/data_types/list.rb +28 -0
  53. data/lib/expressir/model/data_types/logical.rb +10 -0
  54. data/lib/expressir/model/data_types/number.rb +10 -0
  55. data/lib/expressir/model/data_types/real.rb +19 -0
  56. data/lib/expressir/model/data_types/select.rb +28 -0
  57. data/lib/expressir/model/data_types/set.rb +25 -0
  58. data/lib/expressir/model/data_types/string.rb +22 -0
  59. data/lib/expressir/model/declaration.rb +9 -0
  60. data/lib/expressir/model/declarations/attribute.rb +47 -0
  61. data/lib/expressir/model/declarations/constant.rb +34 -0
  62. data/lib/expressir/model/declarations/entity.rb +53 -0
  63. data/lib/expressir/model/declarations/function.rb +67 -0
  64. data/lib/expressir/model/declarations/interface.rb +28 -0
  65. data/lib/expressir/model/declarations/interface_item.rb +23 -0
  66. data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
  67. data/lib/expressir/model/declarations/parameter.rb +34 -0
  68. data/lib/expressir/model/declarations/procedure.rb +64 -0
  69. data/lib/expressir/model/declarations/remark_item.rb +21 -0
  70. data/lib/expressir/model/declarations/rule.rb +71 -0
  71. data/lib/expressir/model/declarations/schema.rb +117 -0
  72. data/lib/expressir/model/declarations/schema_version.rb +22 -0
  73. data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
  74. data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
  75. data/lib/expressir/model/declarations/type.rb +45 -0
  76. data/lib/expressir/model/declarations/unique_rule.rb +31 -0
  77. data/lib/expressir/model/declarations/variable.rb +34 -0
  78. data/lib/expressir/model/declarations/where_rule.rb +31 -0
  79. data/lib/expressir/model/expression.rb +9 -0
  80. data/lib/expressir/model/expressions/aggregate_initializer.rb +19 -0
  81. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
  82. data/lib/expressir/model/expressions/binary_expression.rb +53 -0
  83. data/lib/expressir/model/expressions/entity_constructor.rb +22 -0
  84. data/lib/expressir/model/expressions/function_call.rb +22 -0
  85. data/lib/expressir/model/expressions/interval.rb +34 -0
  86. data/lib/expressir/model/expressions/query_expression.rb +35 -0
  87. data/lib/expressir/model/expressions/unary_expression.rb +27 -0
  88. data/lib/expressir/model/identifier.rb +34 -0
  89. data/lib/expressir/model/literal.rb +9 -0
  90. data/lib/expressir/model/literals/binary.rb +19 -0
  91. data/lib/expressir/model/literals/integer.rb +19 -0
  92. data/lib/expressir/model/literals/logical.rb +23 -0
  93. data/lib/expressir/model/literals/real.rb +19 -0
  94. data/lib/expressir/model/literals/string.rb +22 -0
  95. data/lib/expressir/model/model_element.rb +208 -0
  96. data/lib/expressir/model/reference.rb +9 -0
  97. data/lib/expressir/model/references/attribute_reference.rb +22 -0
  98. data/lib/expressir/model/references/group_reference.rb +22 -0
  99. data/lib/expressir/model/references/index_reference.rb +27 -0
  100. data/lib/expressir/model/references/simple_reference.rb +24 -0
  101. data/lib/expressir/model/repository.rb +23 -0
  102. data/lib/expressir/model/statement.rb +9 -0
  103. data/lib/expressir/model/statements/alias.rb +35 -0
  104. data/lib/expressir/model/statements/assignment.rb +22 -0
  105. data/lib/expressir/model/statements/case.rb +25 -0
  106. data/lib/expressir/model/statements/case_action.rb +22 -0
  107. data/lib/expressir/model/statements/compound.rb +19 -0
  108. data/lib/expressir/model/statements/escape.rb +10 -0
  109. data/lib/expressir/model/statements/if.rb +25 -0
  110. data/lib/expressir/model/statements/null.rb +10 -0
  111. data/lib/expressir/model/statements/procedure_call.rb +22 -0
  112. data/lib/expressir/model/statements/repeat.rb +47 -0
  113. data/lib/expressir/model/statements/return.rb +19 -0
  114. data/lib/expressir/model/statements/skip.rb +10 -0
  115. data/lib/expressir/model/supertype_expression.rb +9 -0
  116. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
  117. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
  118. data/lib/expressir/model.rb +79 -0
  119. data/lib/expressir/version.rb +3 -0
  120. data/lib/expressir.rb +44 -0
  121. data/rakelib/antlr4-native.rake +173 -0
  122. data/rakelib/cross-ruby.rake +403 -0
  123. data/spec/acceptance/version_spec.rb +30 -0
  124. data/spec/expressir/express/cache_spec.rb +89 -0
  125. data/spec/expressir/express/formatter_spec.rb +171 -0
  126. data/spec/expressir/express/parser_spec.rb +141 -0
  127. data/spec/expressir/model/model_element_spec.rb +318 -0
  128. data/spec/spec_helper.rb +24 -0
  129. data/spec/support/console_helper.rb +29 -0
  130. data/spec/syntax/multiple.exp +23 -0
  131. data/spec/syntax/multiple.yaml +198 -0
  132. data/spec/syntax/multiple_formatted.exp +71 -0
  133. data/spec/syntax/multiple_hyperlink_formatted.exp +71 -0
  134. data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  135. data/spec/syntax/remark.exp +193 -0
  136. data/spec/syntax/remark.yaml +471 -0
  137. data/spec/syntax/remark_formatted.exp +228 -0
  138. data/spec/syntax/single.exp +4 -0
  139. data/spec/syntax/single.yaml +18 -0
  140. data/spec/syntax/single_formatted.exp +10 -0
  141. data/spec/syntax/single_formatted.yaml +36 -0
  142. data/spec/syntax/syntax.exp +333 -0
  143. data/spec/syntax/syntax.yaml +3509 -0
  144. data/spec/syntax/syntax_formatted.exp +902 -0
  145. data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
  146. data/spec/syntax/syntax_schema_head_formatted.exp +18 -0
  147. metadata +392 -0
@@ -0,0 +1,141 @@
1
+ require "yaml"
2
+ require "spec_helper"
3
+ require "expressir/express/parser"
4
+
5
+ RSpec.describe Expressir::Express::Parser do
6
+ describe ".from_file" do
7
+ it "throws an exception if the file to parse does not exist" do |example|
8
+ print "\n[#{example.description}] "
9
+ expect do
10
+ Expressir::Express::Parser.from_file("non-existing-file")
11
+ end.to raise_error(Errno::ENOENT)
12
+ end
13
+
14
+ it "parses a file (single.exp)" do |example|
15
+ print "\n[#{example.description}] "
16
+ exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
17
+ yaml_file = Expressir.root_path.join("spec", "syntax", "single.yaml")
18
+
19
+ repo = Expressir::Express::Parser.from_file(exp_file)
20
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
21
+ # File.write(yaml_file, result)
22
+ expected_result = File.read(yaml_file)
23
+
24
+ expect(result).to eq(expected_result)
25
+
26
+ # Validate Object Space
27
+ GC.start
28
+ GC.verify_compaction_references
29
+ GC.verify_internal_consistency
30
+ end
31
+
32
+ it "parses a file (multiple.exp)" do |example|
33
+ print "\n[#{example.description}] "
34
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
35
+ yaml_file = Expressir.root_path.join("spec", "syntax", "multiple.yaml")
36
+
37
+ repo = Expressir::Express::Parser.from_file(exp_file)
38
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
39
+ # File.write(yaml_file, result)
40
+ expected_result = File.read(yaml_file)
41
+
42
+ expect(result).to eq(expected_result)
43
+
44
+ # Validate Object Space
45
+ GC.start
46
+ GC.verify_compaction_references
47
+ GC.verify_internal_consistency
48
+ end
49
+
50
+ it "parses a file (syntax.exp)" do |example|
51
+ print "\n[#{example.description}] "
52
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
53
+ yaml_file = Expressir.root_path.join("spec", "syntax", "syntax.yaml")
54
+
55
+ repo = Expressir::Express::Parser.from_file(exp_file)
56
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
57
+ # File.write(yaml_file, result)
58
+ expected_result = File.read(yaml_file)
59
+
60
+ expect(result).to eq(expected_result)
61
+
62
+ # Validate Object Space
63
+ GC.start
64
+ GC.verify_compaction_references
65
+ GC.verify_internal_consistency
66
+ end
67
+
68
+ it "parses a file (remark.exp)" do |example|
69
+ print "\n[#{example.description}] "
70
+ exp_file = Expressir.root_path.join("spec", "syntax", "remark.exp")
71
+ yaml_file = Expressir.root_path.join("spec", "syntax", "remark.yaml")
72
+
73
+ repo = Expressir::Express::Parser.from_file(exp_file)
74
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
75
+ # File.write(yaml_file, result)
76
+ expected_result = File.read(yaml_file)
77
+
78
+ expect(result).to eq(expected_result)
79
+
80
+ # Validate Object Space
81
+ GC.start
82
+ GC.verify_compaction_references
83
+ GC.verify_internal_consistency
84
+ end
85
+
86
+ it "parses a file including original source (multiple.exp)" do |example|
87
+ print "\n[#{example.description}] "
88
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
89
+
90
+ input = File.read(exp_file)
91
+ repo = Expressir::Express::Parser.from_file(exp_file, include_source: true)
92
+
93
+ schema = repo.schemas.first
94
+ start_index = input.index("SCHEMA")
95
+ stop_index = input.index("END_SCHEMA;") + "END_SCHEMA;".length - 1
96
+ expected_result = input[start_index..stop_index]
97
+ expect(schema.source).to eq(expected_result)
98
+
99
+ entity = schema.entities.first
100
+ start_index = input.index("ENTITY")
101
+ stop_index = input.index("END_ENTITY;") + "END_ENTITY;".length - 1
102
+ expected_result = input[start_index..stop_index]
103
+ expect(entity.source).to eq(expected_result)
104
+
105
+ # Validate Object Space
106
+ GC.start
107
+ GC.verify_compaction_references
108
+ GC.verify_internal_consistency
109
+ end
110
+ end
111
+
112
+ describe ".from_files" do
113
+ it "parses multiple files (single.exp, multiple.exp)" do |example|
114
+ print "\n[#{example.description}] "
115
+ exp_files = [
116
+ Expressir.root_path.join("spec", "syntax", "single.exp"),
117
+ Expressir.root_path.join("spec", "syntax", "multiple.exp"),
118
+ ]
119
+
120
+ repo = Expressir::Express::Parser.from_files(exp_files)
121
+
122
+ schemas = repo.schemas
123
+ expect(schemas.count).to eq(5)
124
+ expect(schemas[0].file).to eq(exp_files[0].to_s)
125
+ expect(schemas[0].id).to eq("single_schema")
126
+ expect(schemas[1].file).to eq(exp_files[1].to_s)
127
+ expect(schemas[1].id).to eq("multiple_schema")
128
+ expect(schemas[2].file).to eq(exp_files[1].to_s)
129
+ expect(schemas[2].id).to eq("multiple_schema2")
130
+ expect(schemas[3].file).to eq(exp_files[1].to_s)
131
+ expect(schemas[3].id).to eq("multiple_schema3")
132
+ expect(schemas[4].file).to eq(exp_files[1].to_s)
133
+ expect(schemas[4].id).to eq("multiple_schema4")
134
+
135
+ # Validate Object Space
136
+ GC.start
137
+ GC.verify_compaction_references
138
+ GC.verify_internal_consistency
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,318 @@
1
+ require "yaml"
2
+ require "spec_helper"
3
+ require "expressir/express/parser"
4
+ require "expressir/express/formatter"
5
+
6
+ RSpec.describe Expressir::Model::ModelElement do
7
+ describe ".to_hash" do
8
+ it "exports an object with a formatter (single.exp)" do |example|
9
+ print "\n[#{example.description}] "
10
+ exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
11
+ yaml_file = Expressir.root_path.join("spec", "syntax", "single_formatted.yaml")
12
+
13
+ repo = Expressir::Express::Parser.from_file(exp_file)
14
+
15
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, formatter: Expressir::Express::Formatter))
16
+ # File.write(yaml_file, result)
17
+ expected_result = File.read(yaml_file)
18
+
19
+ expect(result).to eq(expected_result)
20
+
21
+ # Validate Object Space
22
+ GC.start
23
+ GC.verify_compaction_references
24
+ GC.verify_internal_consistency
25
+ end
26
+ end
27
+
28
+ describe ".from_hash" do
29
+ it "parses an object (single.yaml)" do |example|
30
+ print "\n[#{example.description}] "
31
+ yaml_file = Expressir.root_path.join("spec", "syntax", "single.yaml")
32
+
33
+ input = YAML.safe_load(File.read(yaml_file))
34
+ repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
35
+
36
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
37
+ expected_result = File.read(yaml_file)
38
+
39
+ expect(result).to eq(expected_result)
40
+
41
+ # Validate Object Space
42
+ GC.start
43
+ GC.verify_compaction_references
44
+ GC.verify_internal_consistency
45
+ end
46
+
47
+ it "parses an object (multiple.yaml)" do |example|
48
+ print "\n[#{example.description}] "
49
+ yaml_file = Expressir.root_path.join("spec", "syntax", "multiple.yaml")
50
+
51
+ input = YAML.safe_load(File.read(yaml_file), permitted_classes: [Symbol]) # For UTF8 symbols
52
+ repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
53
+
54
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
55
+ expected_result = File.read(yaml_file)
56
+
57
+ expect(result).to eq(expected_result)
58
+
59
+ # Validate Object Space
60
+ GC.start
61
+ GC.verify_compaction_references
62
+ GC.verify_internal_consistency
63
+ end
64
+
65
+ it "parses an object (syntax.yaml)" do |example|
66
+ print "\n[#{example.description}] "
67
+ yaml_file = Expressir.root_path.join("spec", "syntax", "syntax.yaml")
68
+
69
+ input = YAML.safe_load(File.read(yaml_file), permitted_classes: [Symbol]) # For UTF8 symbols
70
+ repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
71
+
72
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
73
+ expected_result = File.read(yaml_file)
74
+
75
+ expect(result).to eq(expected_result)
76
+
77
+ GC.start
78
+ GC.verify_compaction_references
79
+ GC.verify_internal_consistency
80
+ end
81
+
82
+ it "parses an object (remark.yaml)" do |example|
83
+ print "\n[#{example.description}] "
84
+ yaml_file = Expressir.root_path.join("spec", "syntax", "remark.yaml")
85
+
86
+ input = YAML.safe_load(File.read(yaml_file), permitted_classes: [Symbol]) # For UTF8 symbols
87
+ repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
88
+
89
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
90
+ expected_result = File.read(yaml_file)
91
+
92
+ expect(result).to eq(expected_result)
93
+
94
+ # Validate Object Space
95
+ GC.start
96
+ GC.verify_compaction_references
97
+ GC.verify_internal_consistency
98
+ end
99
+ end
100
+
101
+ describe ".find" do
102
+ it "finds an object (single.exp)" do |example|
103
+ print "\n[#{example.description}] "
104
+ exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
105
+
106
+ repo = Expressir::Express::Parser.from_file(exp_file)
107
+
108
+ # universal scope
109
+ expect(repo.find("single_schema")).to be_instance_of(Expressir::Model::Declarations::Schema)
110
+ expect(repo.find("single_schema.empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
111
+
112
+ # schema scope
113
+ schema = repo.schemas.first
114
+ expect(schema.find("empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
115
+
116
+ # Validate Object Space
117
+ GC.start
118
+ GC.verify_compaction_references
119
+ GC.verify_internal_consistency
120
+ end
121
+
122
+ it "finds an object (multiple.exp)" do |example|
123
+ print "\n[#{example.description}] "
124
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
125
+
126
+ repo = Expressir::Express::Parser.from_file(exp_file)
127
+
128
+ # universal scope
129
+ expect(repo.find("multiple_schema")).to be_instance_of(Expressir::Model::Declarations::Schema)
130
+ expect(repo.find("multiple_schema.empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
131
+ expect(repo.find("multiple_schema.attribute_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
132
+ expect(repo.find("multiple_schema.attribute_entity2")).to be_instance_of(Expressir::Model::Declarations::Entity)
133
+ expect(repo.find("multiple_schema.attribute_entity3")).to be_instance_of(Expressir::Model::Declarations::Entity)
134
+ expect(repo.find("multiple_schema.attribute_entity4")).to be_instance_of(Expressir::Model::Declarations::Entity)
135
+
136
+ # schema scope
137
+ schema = repo.schemas.first
138
+ expect(schema.find("empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
139
+ expect(schema.find("attribute_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
140
+ expect(schema.find("attribute_entity2")).to be_instance_of(Expressir::Model::Declarations::Entity)
141
+ expect(schema.find("attribute_entity3")).to be_instance_of(Expressir::Model::Declarations::Entity)
142
+ expect(schema.find("attribute_entity4")).to be_instance_of(Expressir::Model::Declarations::Entity)
143
+
144
+ # Validate Object Space
145
+ GC.start
146
+ GC.verify_compaction_references
147
+ GC.verify_internal_consistency
148
+ end
149
+
150
+ it "finds an object (syntax.exp)" do |example|
151
+ print "\n[#{example.description}] "
152
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
153
+
154
+ repo = Expressir::Express::Parser.from_file(exp_file)
155
+
156
+ # universal scope
157
+ expect(repo.find("syntax_schema")).to be_instance_of(Expressir::Model::Declarations::Schema)
158
+ expect(repo.find("syntax_schema.empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
159
+
160
+ # schema scope
161
+ schema = repo.schemas.first
162
+ expect(schema.find("empty_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
163
+
164
+ # Validate Object Space
165
+ GC.start
166
+ GC.verify_compaction_references
167
+ GC.verify_internal_consistency
168
+ end
169
+
170
+ it "finds an object (remark.exp)" do |example|
171
+ print "\n[#{example.description}] "
172
+ exp_file = Expressir.root_path.join("spec", "syntax", "remark.exp")
173
+
174
+ repo = Expressir::Express::Parser.from_file(exp_file)
175
+
176
+ # universal scope
177
+ expect(repo.find("remark_schema")).to be_instance_of(Expressir::Model::Declarations::Schema)
178
+ expect(repo.find("remark_schema.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
179
+ expect(repo.find("remark_schema.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
180
+ expect(repo.find("remark_schema.remark_type.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
181
+ expect(repo.find("remark_schema.remark_type.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
182
+ expect(repo.find("remark_schema.remark_type.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
183
+ expect(repo.find("remark_schema.remark_type.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
184
+ expect(repo.find("remark_schema.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
185
+ expect(repo.find("remark_schema.remark_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
186
+ expect(repo.find("remark_schema.remark_entity.remark_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
187
+ expect(repo.find("remark_schema.remark_entity.remark_derived_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
188
+ expect(repo.find("remark_schema.remark_entity.remark_inverse_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
189
+ expect(repo.find("remark_schema.remark_entity.UR1")).to be_instance_of(Expressir::Model::Declarations::UniqueRule)
190
+ expect(repo.find("remark_schema.remark_entity.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
191
+ expect(repo.find("remark_schema.remark_entity.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
192
+ expect(repo.find("remark_schema.remark_entity.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
193
+ expect(repo.find("remark_schema.remark_entity.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
194
+ expect(repo.find("remark_schema.remark_subtype_constraint")).to be_instance_of(Expressir::Model::Declarations::SubtypeConstraint)
195
+ expect(repo.find("remark_schema.remark_function")).to be_instance_of(Expressir::Model::Declarations::Function)
196
+ expect(repo.find("remark_schema.remark_function.remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
197
+ expect(repo.find("remark_schema.remark_function.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
198
+ expect(repo.find("remark_schema.remark_function.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
199
+ expect(repo.find("remark_schema.remark_function.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
200
+ expect(repo.find("remark_schema.remark_function.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
201
+ expect(repo.find("remark_schema.remark_procedure")).to be_instance_of(Expressir::Model::Declarations::Procedure)
202
+ expect(repo.find("remark_schema.remark_procedure.remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
203
+ expect(repo.find("remark_schema.remark_procedure.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
204
+ expect(repo.find("remark_schema.remark_procedure.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
205
+ expect(repo.find("remark_schema.remark_procedure.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
206
+ expect(repo.find("remark_schema.remark_procedure.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
207
+ expect(repo.find("remark_schema.remark_rule")).to be_instance_of(Expressir::Model::Declarations::Rule)
208
+ expect(repo.find("remark_schema.remark_rule.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
209
+ expect(repo.find("remark_schema.remark_rule.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
210
+ expect(repo.find("remark_schema.remark_rule.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
211
+ expect(repo.find("remark_schema.remark_rule.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
212
+ expect(repo.find("remark_schema.remark_rule.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
213
+ expect(repo.find("remark_schema.remark_rule.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
214
+ expect(repo.find("remark_schema.remark_rule.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
215
+ expect(repo.find("remark_schema.remark_rule.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
216
+ expect(repo.find("remark_schema.remark_item")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
217
+
218
+ # schema scope
219
+ schema = repo.schemas.first
220
+ expect(schema.find("remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
221
+ expect(schema.find("remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
222
+ expect(schema.find("remark_type.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
223
+ expect(schema.find("remark_type.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
224
+ expect(schema.find("remark_type.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
225
+ expect(schema.find("remark_type.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
226
+ expect(schema.find("remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
227
+ expect(schema.find("remark_entity")).to be_instance_of(Expressir::Model::Declarations::Entity)
228
+ expect(schema.find("remark_entity.remark_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
229
+ expect(schema.find("remark_entity.remark_derived_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
230
+ expect(schema.find("remark_entity.remark_inverse_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
231
+ expect(schema.find("remark_entity.UR1")).to be_instance_of(Expressir::Model::Declarations::UniqueRule)
232
+ expect(schema.find("remark_entity.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
233
+ expect(schema.find("remark_entity.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
234
+ expect(schema.find("remark_entity.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
235
+ expect(schema.find("remark_entity.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
236
+ expect(schema.find("remark_subtype_constraint")).to be_instance_of(Expressir::Model::Declarations::SubtypeConstraint)
237
+ expect(schema.find("remark_function")).to be_instance_of(Expressir::Model::Declarations::Function)
238
+ expect(schema.find("remark_function.remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
239
+ expect(schema.find("remark_function.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
240
+ expect(schema.find("remark_function.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
241
+ expect(schema.find("remark_function.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
242
+ expect(schema.find("remark_function.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
243
+ expect(schema.find("remark_procedure")).to be_instance_of(Expressir::Model::Declarations::Procedure)
244
+ expect(schema.find("remark_procedure.remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
245
+ expect(schema.find("remark_procedure.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
246
+ expect(schema.find("remark_procedure.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
247
+ expect(schema.find("remark_procedure.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
248
+ expect(schema.find("remark_procedure.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
249
+ expect(schema.find("remark_rule")).to be_instance_of(Expressir::Model::Declarations::Rule)
250
+ expect(schema.find("remark_rule.remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
251
+ expect(schema.find("remark_rule.remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
252
+ expect(schema.find("remark_rule.remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
253
+ expect(schema.find("remark_rule.remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
254
+ expect(schema.find("remark_rule.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
255
+ expect(schema.find("remark_rule.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
256
+ expect(schema.find("remark_rule.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
257
+ expect(schema.find("remark_rule.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
258
+ expect(schema.find("remark_item")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
259
+
260
+ # type scope
261
+ type = schema.types.first
262
+ expect(type.find("WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
263
+ expect(type.find("wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
264
+ expect(type.find("IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
265
+ expect(type.find("ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
266
+
267
+ # entity scope
268
+ entity = schema.entities.first
269
+ expect(entity.find("remark_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
270
+ expect(entity.find("remark_derived_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
271
+ expect(entity.find("remark_inverse_attribute")).to be_instance_of(Expressir::Model::Declarations::Attribute)
272
+ expect(entity.find("UR1")).to be_instance_of(Expressir::Model::Declarations::UniqueRule)
273
+ expect(entity.find("WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
274
+ expect(entity.find("wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
275
+ expect(entity.find("IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
276
+ expect(entity.find("ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
277
+
278
+ # function scope
279
+ function = schema.functions.first
280
+ expect(function.find("remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
281
+ expect(function.find("remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
282
+ expect(function.find("remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
283
+ expect(function.find("remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
284
+ expect(function.find("remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
285
+
286
+ # procedure scope
287
+ procedure = schema.procedures.first
288
+ expect(procedure.find("remark_parameter")).to be_instance_of(Expressir::Model::Declarations::Parameter)
289
+ expect(procedure.find("remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
290
+ expect(procedure.find("remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
291
+ expect(procedure.find("remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
292
+ expect(procedure.find("remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
293
+
294
+ # rule scope
295
+ rule = schema.rules.first
296
+ expect(rule.find("remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
297
+ expect(rule.find("remark_enumeration_item")).to be_instance_of(Expressir::Model::DataTypes::EnumerationItem)
298
+ expect(rule.find("remark_constant")).to be_instance_of(Expressir::Model::Declarations::Constant)
299
+ expect(rule.find("remark_variable")).to be_instance_of(Expressir::Model::Declarations::Variable)
300
+ expect(rule.find("WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
301
+ expect(rule.find("wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
302
+ expect(rule.find("IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
303
+ expect(rule.find("ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
304
+
305
+ # retry search in parent scope
306
+ expect(entity.find("remark_type")).to be_instance_of(Expressir::Model::Declarations::Type)
307
+ expect(entity.find("remark_type.WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
308
+ expect(entity.find("remark_type.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
309
+ expect(entity.find("remark_type.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
310
+ expect(entity.find("remark_type.ip:IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
311
+
312
+ # Validate Object Space
313
+ GC.start
314
+ GC.verify_compaction_references
315
+ GC.verify_internal_consistency
316
+ end
317
+ end
318
+ end
@@ -0,0 +1,24 @@
1
+ require "bundler/setup"
2
+ require "expressir"
3
+
4
+ Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
5
+
6
+ RSpec.configure do |config|
7
+ # Enable flags like --only-failures and --next-failure
8
+ config.example_status_persistence_file_path = ".rspec_status"
9
+ config.include Expressir::ConsoleHelper
10
+
11
+ # Disable RSpec exposing methods globally on `Module` and `main`
12
+ config.disable_monkey_patching!
13
+
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+
18
+ config.around(:example) do |ex|
19
+ ex.run
20
+ rescue SystemExit => e
21
+ puts "Got SystemExit: #{e.inspect}."
22
+ raise
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ module Expressir
2
+ module ConsoleHelper
3
+ def capture_stdout(&_block)
4
+ original_stdout = $stdout
5
+ $stdout = fake = StringIO.new
6
+
7
+ begin
8
+ yield
9
+ ensure
10
+ $stdout = original_stdout
11
+ end
12
+
13
+ fake.string
14
+ end
15
+
16
+ def capture_stderr(&_block)
17
+ original_stderr = $stderr
18
+ $stderr = fake = StringIO.new
19
+
20
+ begin
21
+ yield
22
+ ensure
23
+ $stderr = original_stderr
24
+ end
25
+
26
+ fake.string
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ SCHEMA multiple_schema;
2
+ REFERENCE FROM multiple_schema2;
3
+ REFERENCE FROM multiple_schema3 (attribute_entity3);
4
+ REFERENCE FROM multiple_schema4 (attribute_entity AS attribute_entity4);
5
+ ENTITY test; END_ENTITY;
6
+ ENTITY empty_entity; END_ENTITY;
7
+ ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
8
+ ENTITY subtype_empty_entity SUBTYPE OF (empty_entity); END_ENTITY;
9
+ ENTITY subtype_attribute_entity SUBTYPE OF (attribute_entity); SELF\attribute_entity.test : BOOLEAN; END_ENTITY;
10
+ ENTITY subtype_attribute_entity2 SUBTYPE OF (attribute_entity2); SELF\attribute_entity2.test : BOOLEAN; END_ENTITY;
11
+ ENTITY subtype_attribute_entity3 SUBTYPE OF (attribute_entity3); SELF\attribute_entity3.test : BOOLEAN; END_ENTITY;
12
+ ENTITY subtype_attribute_entity4 SUBTYPE OF (attribute_entity4); SELF\attribute_entity4.test : BOOLEAN; END_ENTITY;
13
+ ENTITY subtype_missing_entity SUBTYPE OF (missing_entity); END_ENTITY;
14
+ END_SCHEMA;
15
+ SCHEMA multiple_schema2;
16
+ ENTITY attribute_entity2; test : BOOLEAN; END_ENTITY;
17
+ END_SCHEMA;
18
+ SCHEMA multiple_schema3;
19
+ ENTITY attribute_entity3; test : BOOLEAN; END_ENTITY;
20
+ END_SCHEMA;
21
+ SCHEMA multiple_schema4;
22
+ ENTITY attribute_entity; test : BOOLEAN; END_ENTITY;
23
+ END_SCHEMA;