expressir 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ffc6b0439702c043c6a606ba6c45e6316027be0bc838b647f53b14e849e482e
4
- data.tar.gz: 8d10711fbe684dcc368481a2cbb909d055461e66e5ee1ad9ed8b66d447e29781
3
+ metadata.gz: be523698bc4b0f210e3beb5e8eaa2b05b5ab33b8c5c32762a269759d6d3f6fd7
4
+ data.tar.gz: f49b97df3c0fce460a9d5374cff70d6f29b0ada6e972619230398d653e489385
5
5
  SHA512:
6
- metadata.gz: 5b3831d6d8286cfe7d5c017f5be55f736d4ac1400e06c2dd95076e9929733b8ca397026d76d213bbaee715b1684331026377fdeee916ece5c70509d64c109d83
7
- data.tar.gz: b70488df7783479437049194aae50b8ef8f676f2d218589075fe177558fe619cbaa60c6223ad6a326c2d593dfc16034ce4506321e2e094586682fd997ed0a9f1
6
+ metadata.gz: b816ba44ca7dba9ea6f1186c0ed714255947d52b1412e97109e6b094c8d51234e8fb87b5a24971f68915e5d0180b8dfd8e560910e5994428cd7a18ba8c8c3090
7
+ data.tar.gz: 3509a1d1edd20451ccb18a7d3bf3fb0e74ea9fad1285fe7c83de32684e9bb117f7509e1f7e8a382215f00ab37f94d4e1c9688171edece8270a37eedb4a77bafb
@@ -29,23 +29,11 @@ jobs:
29
29
  rake:
30
30
  name: test on ruby-${{ matrix.ruby }} ${{ matrix.os }}
31
31
  runs-on: ${{ matrix.os }}
32
- continue-on-error: ${{ matrix.experimental }}
33
32
  strategy:
34
33
  fail-fast: false
35
34
  matrix:
36
35
  ruby: [ '3.1', '3.0', '2.7' ]
37
36
  os: [ ubuntu-latest, windows-latest, macos-latest ]
38
- experimental: [ false ]
39
- include:
40
- - ruby: 'head'
41
- os: 'ubuntu-latest'
42
- experimental: true
43
- - ruby: 'head'
44
- os: 'windows-latest'
45
- experimental: true
46
- - ruby: 'head'
47
- os: 'macos-latest'
48
- experimental: true
49
37
 
50
38
  steps:
51
39
  - name: Checkout
data/README.adoc CHANGED
@@ -75,6 +75,14 @@ Run the test suite
75
75
  bin/rspec
76
76
  ----
77
77
 
78
+ === Grammar updates
79
+ EXPRESS grammar is lined as git submodule to ext/express-grammar
80
+ Shoudl you update it, run ```rake generate```. This command will generate source code for updated native extension using antlr4-native gem.
81
+ Please note that we create several classes on top of antlr4-native output so using embedded rake task is a real requirement.
82
+
83
+ When new extension is gnerated and tested plase check in updated C++ files to git (```rake generate``` is NOT a CI step,
84
+ extension source files are pulled from the repo).
85
+
78
86
  == Installation
79
87
 
80
88
  Add this line to your application's `Gemfile`:
@@ -228,6 +228,8 @@ Class rb_cParser;
228
228
  Class rb_cParseTree;
229
229
  Class rb_cTerminalNode;
230
230
  Class rb_cContextProxy;
231
+ Class rb_cParserExt;
232
+ Class rb_cTokenExt;
231
233
 
232
234
  namespace Rice::detail {
233
235
  template <>
@@ -258,6 +260,28 @@ namespace Rice::detail {
258
260
  };
259
261
  }
260
262
 
263
+ class TokenProxy : public Object {
264
+ public:
265
+ TokenProxy(Token* orig) {
266
+ this -> orig = orig;
267
+ }
268
+
269
+ std::string getText() {
270
+ return orig->getText();
271
+ }
272
+
273
+ size_t getChannel() {
274
+ return orig->getChannel();
275
+ }
276
+
277
+ size_t getTokenIndex() {
278
+ return orig->getTokenIndex();
279
+ }
280
+
281
+ private:
282
+ Token * orig = nullptr;
283
+ };
284
+
261
285
  class ContextProxy {
262
286
  public:
263
287
  ContextProxy(tree::ParseTree* orig) {
@@ -17256,17 +17280,6 @@ public:
17256
17280
  return detail::To_Ruby<SyntaxContextProxy>().convert(proxy);
17257
17281
  }
17258
17282
 
17259
- Array getTokens() {
17260
- Array a;
17261
-
17262
- std::vector<Token*> tokens = this -> tokens -> getTokens();
17263
-
17264
- for (auto &token : tokens) {
17265
- a.push(token);
17266
- }
17267
-
17268
- return a;
17269
- }
17270
17283
  Object visit(VisitorProxy* visitor) {
17271
17284
  auto result = visitor -> visit(this -> parser -> syntax());
17272
17285
 
@@ -18121,6 +18134,59 @@ Object ContextProxy::wrapParseTree(tree::ParseTree* node) {
18121
18134
  }
18122
18135
  }
18123
18136
 
18137
+ class ParserProxyExt : public Object {
18138
+ public:
18139
+ ParserProxyExt(Object self, string file) {
18140
+ ifstream stream;
18141
+ stream.open(file);
18142
+ input = new ANTLRInputStream(stream);
18143
+ lexer = new ExpressLexer(input);
18144
+ tokens = new CommonTokenStream(lexer);
18145
+ parser = new ExpressParser(tokens);
18146
+ stream.close();
18147
+ };
18148
+
18149
+ ~ParserProxyExt() {
18150
+ delete parser;
18151
+ delete tokens;
18152
+ delete lexer;
18153
+ delete input;
18154
+ }
18155
+
18156
+ Object syntax() {
18157
+ auto ctx = parser -> syntax();
18158
+
18159
+ SyntaxContextProxy proxy((ExpressParser::SyntaxContext*) ctx);
18160
+ return detail::To_Ruby<SyntaxContextProxy>().convert(proxy);
18161
+ }
18162
+
18163
+ Array getTokens() {
18164
+ Array a;
18165
+ for (auto token : tokens -> getTokens()) {
18166
+ a.push(new TokenProxy(token));
18167
+ }
18168
+ return a;
18169
+ }
18170
+
18171
+ Object visit(VisitorProxy* visitor) {
18172
+ auto result = visitor -> visit(parser -> syntax());
18173
+
18174
+ lexer -> reset();
18175
+ parser -> reset();
18176
+
18177
+ try {
18178
+ return std::any_cast<Object>(result);
18179
+ } catch(std::bad_cast) {
18180
+ return Qnil;
18181
+ }
18182
+ }
18183
+
18184
+ private:
18185
+ ANTLRInputStream* input;
18186
+ ExpressLexer* lexer;
18187
+ CommonTokenStream* tokens;
18188
+ ExpressParser* parser;
18189
+ };
18124
18190
 
18125
18191
  extern "C"
18126
18192
  void Init_express_parser() {
@@ -18353,9 +18419,19 @@ void Init_express_parser() {
18353
18419
  .define_singleton_function("parse", &ParserProxy::parse)
18354
18420
  .define_singleton_function("parse_file", &ParserProxy::parseFile)
18355
18421
  .define_method("syntax", &ParserProxy::syntax, Return().keepAlive())
18356
- .define_method("tokens", &ParserProxy::getTokens)
18357
18422
  .define_method("visit", &ParserProxy::visit, Return().keepAlive());
18358
18423
 
18424
+ rb_cTokenExt = define_class_under<TokenProxy>(rb_mExpressParser, "TokenExt")
18425
+ .define_method("text", &TokenProxy::getText)
18426
+ .define_method("channel", &TokenProxy::getChannel)
18427
+ .define_method("token_index", &TokenProxy::getTokenIndex);
18428
+
18429
+ rb_cParserExt = define_class_under<ParserProxyExt>(rb_mExpressParser, "ParserExt")
18430
+ .define_constructor(Constructor<ParserProxyExt, Object, string>())
18431
+ .define_method("syntax", &ParserProxyExt::syntax, Return().keepAlive())
18432
+ .define_method("tokens", &ParserProxyExt::getTokens)
18433
+ .define_method("visit", &ParserProxyExt::visit, Return().keepAlive());
18434
+
18359
18435
  rb_cAttributeRefContext = define_class_under<AttributeRefContextProxy, ContextProxy>(rb_mExpressParser, "AttributeRefContext")
18360
18436
  .define_method("attribute_id", &AttributeRefContextProxy::attributeId);
18361
18437
 
@@ -41,7 +41,7 @@ if cross_build
41
41
  # workaround for LoadError: 127: The specified procedure could not be found.
42
42
  $DLDFLAGS << " -static-libgcc -static-libstdc++"
43
43
  when /darwin/
44
- $CXXFLAGS << " -mmacosx-version-min=10.14 -Wno-register -fno-c++-static-destructors"
44
+ $CXXFLAGS << " -mmacosx-version-min=10.14 -fno-c++-static-destructors"
45
45
  $DLDFLAGS << " -mmacosx-version-min=10.14"
46
46
  end
47
47
  else
@@ -31,13 +31,12 @@ module Expressir
31
31
  # @param [Boolean] include_source attach original source code to model elements
32
32
  # @return [Model::Repository]
33
33
  def self.from_file(file, skip_references: nil, include_source: nil)
34
- @input = File.read(file)
35
34
 
36
35
  # An important note re memory management
37
- # parse, syntax, visitor methods return complex tree structures created in netive (C++) extension
36
+ # parse, syntax, visitor methods return complex tree structures created in native (C++) extension
38
37
  # visit method references nodes and leaves of this structures but it is totally untransparent for Ruby GarbageCllector
39
- # so in this class we keep those C++ structure marked for GC so theu are not freed
40
- @parser = ::ExpressParser::Parser.parse(@input)
38
+ # so in this class we keep those C++ structure marked for GC so they are not freed
39
+ @parser = ::ExpressParser::ParserExt.new(file.to_s)
41
40
  @parse_tree = @parser.syntax()
42
41
 
43
42
  @visitor = Visitor.new(@parser.tokens, include_source: include_source)
@@ -1,3 +1,3 @@
1
1
  module Expressir
2
- VERSION = "1.2.5".freeze
2
+ VERSION = "1.2.6".freeze
3
3
  end
@@ -2,34 +2,138 @@ require "fileutils"
2
2
  require "antlr4-native"
3
3
  require "rake"
4
4
 
5
- def create_tokens_api(parser_source_lines)
6
- # - add ParserProxy tokens method, simple compensation for missing exposed BufferedTokenStream
7
- i = parser_source_lines.index { |x| x == " Object syntax() {" }
8
- parser_source_lines[i + 6] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
5
+ def create_class_declarations(parser_source_lines)
6
+ i = parser_source_lines.index { |x| x == "Class rb_cContextProxy;" }
7
+ parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
9
8
 
10
- Array getTokens() {
11
- Array a;
9
+ Class rb_cParserExt;
10
+ Class rb_cTokenExt;
12
11
 
13
- std::vector<Token*> tokens = this -> tokens -> getTokens();
12
+ CPP
13
+ end
14
+
15
+ def create_tp_class_definition(parser_source_lines)
16
+ i = parser_source_lines.index { |x| x == "class ContextProxy {" }
17
+ parser_source_lines[i - 2] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
18
+
19
+
20
+ class TokenProxy : public Object {
21
+ public:
22
+ TokenProxy(Token* orig) {
23
+ this -> orig = orig;
24
+ }
25
+
26
+ std::string getText() {
27
+ return orig->getText();
28
+ }
29
+
30
+ size_t getChannel() {
31
+ return orig->getChannel();
32
+ }
33
+
34
+ size_t getTokenIndex() {
35
+ return orig->getTokenIndex();
36
+ }
37
+
38
+ private:
39
+ Token * orig = nullptr;
40
+ };
41
+
42
+ CPP
43
+ end
44
+
45
+ def create_pp_class_definition(parser_source_lines)
46
+ i = parser_source_lines.index { |x| x == "extern \"C\"" }
47
+ parser_source_lines[i - 2] += <<~CPP.split("\n").map { |x| x == "" ? x : x.to_s }.join("\n")
48
+
49
+ class ParserProxyExt : public Object {
50
+ public:
51
+ ParserProxyExt(Object self, string file) {
52
+ ifstream stream;
53
+ stream.open(file);
54
+ input = new ANTLRInputStream(stream);
55
+ lexer = new ExpressLexer(input);
56
+ tokens = new CommonTokenStream(lexer);
57
+ parser = new ExpressParser(tokens);
58
+ stream.close();
59
+ };
60
+
61
+ ~ParserProxyExt() {
62
+ delete parser;
63
+ delete tokens;
64
+ delete lexer;
65
+ delete input;
66
+ }
67
+
68
+ Object syntax() {
69
+ auto ctx = parser -> syntax();
70
+
71
+ SyntaxContextProxy proxy((ExpressParser::SyntaxContext*) ctx);
72
+ return detail::To_Ruby<SyntaxContextProxy>().convert(proxy);
73
+ }
14
74
 
15
- for (auto &token : tokens) {
16
- a.push(token);
17
- }
75
+ Array getTokens() {
76
+ Array a;
77
+ for (auto token : tokens -> getTokens()) {
78
+ a.push(new TokenProxy(token));
79
+ }
80
+ return a;
81
+ }
82
+
83
+ Object visit(VisitorProxy* visitor) {
84
+ auto result = visitor -> visit(parser -> syntax());
85
+
86
+ lexer -> reset();
87
+ parser -> reset();
88
+
89
+ try {
90
+ return std::any_cast<Object>(result);
91
+ } catch(std::bad_cast) {
92
+ return Qnil;
93
+ }
94
+ }
95
+
96
+ private:
97
+ ANTLRInputStream* input;
98
+ ExpressLexer* lexer;
99
+ CommonTokenStream* tokens;
100
+ ExpressParser* parser;
101
+ };
18
102
 
19
- return a;
20
- }
21
103
 
22
104
  CPP
23
105
  end
24
106
 
25
- def create_tokens_method(parser_source_lines)
26
- i = parser_source_lines.index { |x| x == ' .define_method("syntax", &ParserProxy::syntax, Return().keepAlive())' }
27
- parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
107
+ def create_class_api(parser_source_lines)
108
+ i = parser_source_lines.index { |x| x == " .define_method(\"visit\", &ParserProxy::visit, Return().keepAlive());" }
109
+ parser_source_lines[i] += <<~CPP.split("\n").map { |x| x == "" ? x : " #{x}" }.join("\n")
110
+
111
+
112
+ rb_cTokenExt = define_class_under<TokenProxy>(rb_mExpressParser, "TokenExt")
113
+ .define_method("text", &TokenProxy::getText)
114
+ .define_method("channel", &TokenProxy::getChannel)
115
+ .define_method("token_index", &TokenProxy::getTokenIndex);
116
+
117
+ rb_cParserExt = define_class_under<ParserProxyExt>(rb_mExpressParser, "ParserExt")
118
+ .define_constructor(Constructor<ParserProxyExt, Object, string>())
119
+ .define_method("syntax", &ParserProxyExt::syntax, Return().keepAlive())
120
+ .define_method("tokens", &ParserProxyExt::getTokens)
121
+ .define_method("visit", &ParserProxyExt::visit, Return().keepAlive());
28
122
 
29
- .define_method("tokens", &ParserProxy::getTokens)
30
123
  CPP
31
124
  end
32
125
 
126
+ def generate_extended_parser
127
+ # Generate extended parser that provide Ruby access to token stream
128
+ parser_source_file = File.join("ext", "express-parser", "express_parser.cpp")
129
+ parser_source_lines = File.read(parser_source_file).split("\n")
130
+ create_class_declarations(parser_source_lines)
131
+ create_tp_class_definition(parser_source_lines)
132
+ create_pp_class_definition(parser_source_lines)
133
+ create_class_api(parser_source_lines)
134
+ File.write(parser_source_file, "#{parser_source_lines.join("\n")}\n")
135
+ end
136
+
33
137
  desc "Generate parser (Usage: 'rake generate <grammar_file>')"
34
138
  task "generate" do
35
139
  grammar_file = ARGV[1]
@@ -38,7 +142,6 @@ task "generate" do
38
142
  end
39
143
 
40
144
  puts "Generating parser from '#{grammar_file}'"
41
-
42
145
  # ANTLR does weird things if the grammar file isn't in the current working directory
43
146
  temp_grammar_file = File.join(FileUtils.pwd, File.basename(grammar_file))
44
147
  FileUtils.cp(grammar_file, temp_grammar_file)
@@ -51,13 +154,8 @@ task "generate" do
51
154
  )
52
155
  generator.generate
53
156
 
54
- # fix issues with generated parser
55
- parser_source_file = File.join("ext", "express-parser", "express_parser.cpp")
56
- parser_source_lines = File.read(parser_source_file).split("\n")
57
- create_tokens_api(parser_source_lines)
58
- create_tokens_method(parser_source_lines)
59
- File.write(parser_source_file, "#{parser_source_lines.join("\n")}\n")
60
-
157
+ puts "Generating extended parser"
158
+ generate_extended_parser
61
159
  # cleanup
62
160
  FileUtils.rm(temp_grammar_file)
63
161
  end
@@ -5,6 +5,11 @@ RSpec.describe "Expressir" do
5
5
  it "has a version number" do |example|
6
6
  print "\n[#{example.description}] "
7
7
  expect(Expressir::VERSION).not_to be nil
8
+
9
+ # Validate Object Space
10
+ GC.start
11
+ GC.verify_compaction_references
12
+ GC.verify_internal_consistency
8
13
  end
9
14
 
10
15
  it "displays the current verison" do |example|
@@ -12,6 +17,11 @@ RSpec.describe "Expressir" do
12
17
  command = %w(version)
13
18
  output = capture_stdout { Expressir::Cli.start(command) }
14
19
  expect(output).to include("Version #{Expressir::VERSION}")
20
+
21
+ # Validate Object Space
22
+ GC.start
23
+ GC.verify_compaction_references
24
+ GC.verify_internal_consistency
15
25
  end
16
26
  end
17
27
  end
@@ -24,6 +24,11 @@ RSpec.describe Expressir::Express::Cache do
24
24
  temp_file.close
25
25
  temp_file.unlink
26
26
  end
27
+
28
+ # Validate Object Space
29
+ GC.start
30
+ GC.verify_compaction_references
31
+ GC.verify_internal_consistency
27
32
  end
28
33
  end
29
34
 
@@ -44,6 +49,11 @@ RSpec.describe Expressir::Express::Cache do
44
49
  temp_file.close
45
50
  temp_file.unlink
46
51
  end
52
+
53
+ # Validate Object Space
54
+ GC.start
55
+ GC.verify_compaction_references
56
+ GC.verify_internal_consistency
47
57
  end
48
58
 
49
59
  it "fails parsing a file from a different Expressir version" do |example|
@@ -62,6 +72,11 @@ RSpec.describe Expressir::Express::Cache do
62
72
  temp_file.close
63
73
  temp_file.unlink
64
74
  end
75
+
76
+ # Validate Object Space
77
+ GC.start
78
+ GC.verify_compaction_references
79
+ GC.verify_internal_consistency
65
80
  end
66
81
  end
67
82
  end
@@ -19,6 +19,11 @@ RSpec.describe Expressir::Express::Formatter do
19
19
  expected_result = File.read(formatted_exp_file)
20
20
 
21
21
  expect(result).to eq(expected_result)
22
+
23
+ # Validate Object Space
24
+ GC.start
25
+ GC.verify_compaction_references
26
+ GC.verify_internal_consistency
22
27
  end
23
28
 
24
29
  it "exports an object (multiple.exp)" do |example|
@@ -33,6 +38,9 @@ RSpec.describe Expressir::Express::Formatter do
33
38
  expected_result = File.read(formatted_exp_file)
34
39
 
35
40
  expect(result).to eq(expected_result)
41
+ GC.start
42
+ GC.verify_compaction_references
43
+ GC.verify_internal_consistency
36
44
  end
37
45
 
38
46
  it "exports an object (remark.exp)" do |example|
@@ -47,6 +55,11 @@ RSpec.describe Expressir::Express::Formatter do
47
55
  expected_result = File.read(formatted_exp_file)
48
56
 
49
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
50
63
  end
51
64
 
52
65
  it "exports an object (syntax.exp)" do |example|
@@ -61,6 +74,11 @@ RSpec.describe Expressir::Express::Formatter do
61
74
  expected_result = File.read(formatted_exp_file)
62
75
 
63
76
  expect(result).to eq(expected_result)
77
+
78
+ # Validate Object Space
79
+ GC.start
80
+ GC.verify_compaction_references
81
+ GC.verify_internal_consistency
64
82
  end
65
83
 
66
84
  it "exports an object with schema head formatter (syntax.exp)" do |example|
@@ -78,6 +96,11 @@ RSpec.describe Expressir::Express::Formatter do
78
96
  expected_result = File.read(formatted_exp_file)
79
97
 
80
98
  expect(result).to eq(expected_result)
99
+
100
+ # Validate Object Space
101
+ GC.start
102
+ GC.verify_compaction_references
103
+ GC.verify_internal_consistency
81
104
  end
82
105
 
83
106
  it "exports an object with hyperlink formatter (syntax.exp)" do |example|
@@ -95,6 +118,11 @@ RSpec.describe Expressir::Express::Formatter do
95
118
  expected_result = File.read(formatted_exp_file)
96
119
 
97
120
  expect(result).to eq(expected_result)
121
+
122
+ # Validate Object Space
123
+ GC.start
124
+ GC.verify_compaction_references
125
+ GC.verify_internal_consistency
98
126
  end
99
127
 
100
128
  it "exports an object with hyperlink formatter (multiple.exp)" do |example|
@@ -112,6 +140,11 @@ RSpec.describe Expressir::Express::Formatter do
112
140
  expected_result = File.read(formatted_exp_file)
113
141
 
114
142
  expect(result).to eq(expected_result)
143
+
144
+ # Validate Object Space
145
+ GC.start
146
+ GC.verify_compaction_references
147
+ GC.verify_internal_consistency
115
148
  end
116
149
 
117
150
  it "exports an object with schema head and hyperlink formatter (multiple.exp)" do |example|
@@ -130,6 +163,11 @@ RSpec.describe Expressir::Express::Formatter do
130
163
  expected_result = File.read(formatted_exp_file)
131
164
 
132
165
  expect(result).to eq(expected_result)
166
+
167
+ # Validate Object Space
168
+ GC.start
169
+ GC.verify_compaction_references
170
+ GC.verify_internal_consistency
133
171
  end
134
172
  end
135
173
  end
@@ -15,6 +15,11 @@ RSpec.describe Expressir::Express::Parser do
15
15
  expected_result = File.read(yaml_file)
16
16
 
17
17
  expect(result).to eq(expected_result)
18
+
19
+ # Validate Object Space
20
+ GC.start
21
+ GC.verify_compaction_references
22
+ GC.verify_internal_consistency
18
23
  end
19
24
 
20
25
  it "parses a file (multiple.exp)" do |example|
@@ -28,6 +33,11 @@ RSpec.describe Expressir::Express::Parser do
28
33
  expected_result = File.read(yaml_file)
29
34
 
30
35
  expect(result).to eq(expected_result)
36
+
37
+ # Validate Object Space
38
+ GC.start
39
+ GC.verify_compaction_references
40
+ GC.verify_internal_consistency
31
41
  end
32
42
 
33
43
  it "parses a file (syntax.exp)" do |example|
@@ -41,6 +51,11 @@ RSpec.describe Expressir::Express::Parser do
41
51
  expected_result = File.read(yaml_file)
42
52
 
43
53
  expect(result).to eq(expected_result)
54
+
55
+ # Validate Object Space
56
+ GC.start
57
+ GC.verify_compaction_references
58
+ GC.verify_internal_consistency
44
59
  end
45
60
 
46
61
  it "parses a file (remark.exp)" do |example|
@@ -54,6 +69,11 @@ RSpec.describe Expressir::Express::Parser do
54
69
  expected_result = File.read(yaml_file)
55
70
 
56
71
  expect(result).to eq(expected_result)
72
+
73
+ # Validate Object Space
74
+ GC.start
75
+ GC.verify_compaction_references
76
+ GC.verify_internal_consistency
57
77
  end
58
78
 
59
79
  it "parses a file including original source (multiple.exp)" do |example|
@@ -74,6 +94,11 @@ RSpec.describe Expressir::Express::Parser do
74
94
  stop_index = input.index("END_ENTITY;") + "END_ENTITY;".length - 1
75
95
  expected_result = input[start_index..stop_index]
76
96
  expect(entity.source).to eq(expected_result)
97
+
98
+ # Validate Object Space
99
+ GC.start
100
+ GC.verify_compaction_references
101
+ GC.verify_internal_consistency
77
102
  end
78
103
  end
79
104
 
@@ -99,6 +124,11 @@ RSpec.describe Expressir::Express::Parser do
99
124
  expect(schemas[3].id).to eq("multiple_schema3")
100
125
  expect(schemas[4].file).to eq(exp_files[1].to_s)
101
126
  expect(schemas[4].id).to eq("multiple_schema4")
127
+
128
+ # Validate Object Space
129
+ GC.start
130
+ GC.verify_compaction_references
131
+ GC.verify_internal_consistency
102
132
  end
103
133
  end
104
134
  end
@@ -17,6 +17,11 @@ RSpec.describe Expressir::Model::ModelElement do
17
17
  expected_result = File.read(yaml_file)
18
18
 
19
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
20
25
  end
21
26
  end
22
27
 
@@ -32,6 +37,11 @@ RSpec.describe Expressir::Model::ModelElement do
32
37
  expected_result = File.read(yaml_file)
33
38
 
34
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
35
45
  end
36
46
 
37
47
  it "parses an object (multiple.yaml)" do |example|
@@ -45,6 +55,11 @@ RSpec.describe Expressir::Model::ModelElement do
45
55
  expected_result = File.read(yaml_file)
46
56
 
47
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
48
63
  end
49
64
 
50
65
  it "parses an object (syntax.yaml)" do |example|
@@ -58,6 +73,10 @@ RSpec.describe Expressir::Model::ModelElement do
58
73
  expected_result = File.read(yaml_file)
59
74
 
60
75
  expect(result).to eq(expected_result)
76
+
77
+ GC.start
78
+ GC.verify_compaction_references
79
+ GC.verify_internal_consistency
61
80
  end
62
81
 
63
82
  it "parses an object (remark.yaml)" do |example|
@@ -71,6 +90,11 @@ RSpec.describe Expressir::Model::ModelElement do
71
90
  expected_result = File.read(yaml_file)
72
91
 
73
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
74
98
  end
75
99
  end
76
100
 
@@ -88,6 +112,11 @@ RSpec.describe Expressir::Model::ModelElement do
88
112
  # schema scope
89
113
  schema = repo.schemas.first
90
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
91
120
  end
92
121
 
93
122
  it "finds an object (multiple.exp)" do |example|
@@ -111,6 +140,11 @@ RSpec.describe Expressir::Model::ModelElement do
111
140
  expect(schema.find("attribute_entity2")).to be_instance_of(Expressir::Model::Declarations::Entity)
112
141
  expect(schema.find("attribute_entity3")).to be_instance_of(Expressir::Model::Declarations::Entity)
113
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
114
148
  end
115
149
 
116
150
  it "finds an object (syntax.exp)" do |example|
@@ -126,6 +160,11 @@ RSpec.describe Expressir::Model::ModelElement do
126
160
  # schema scope
127
161
  schema = repo.schemas.first
128
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
129
168
  end
130
169
 
131
170
  it "finds an object (remark.exp)" do |example|
@@ -269,6 +308,11 @@ RSpec.describe Expressir::Model::ModelElement do
269
308
  expect(entity.find("remark_type.wr:WR1")).to be_instance_of(Expressir::Model::Declarations::WhereRule)
270
309
  expect(entity.find("remark_type.IP1")).to be_instance_of(Expressir::Model::Declarations::RemarkItem)
271
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
272
316
  end
273
317
  end
274
318
  end
data/spec/spec_helper.rb CHANGED
@@ -14,4 +14,11 @@ RSpec.configure do |config|
14
14
  config.expect_with :rspec do |c|
15
15
  c.syntax = :expect
16
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
17
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-17 00:00:00.000000000 Z
11
+ date: 2022-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rice