-
Notifications
You must be signed in to change notification settings - Fork 1
/
gherkin_pkg.sv
429 lines (301 loc) · 10.5 KB
/
gherkin_pkg.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
// ===================================================================
package gherkin_pkg;
// ===================================================================
import uvm_pkg::*;
import meta_pkg::*;
typedef class background;
typedef class comment;
typedef class data_table;
typedef class doc_string;
typedef class examples;
typedef class feature;
typedef class gherkin_document;
typedef class scenario;
typedef class scenario_definition;
typedef class scenario_outline;
typedef class step;
typedef class step_argument;
typedef class table_cell;
typedef class table_row;
typedef class tag;
(* visitor_pattern *)
interface class visitor;
pure virtual task visit_background(gherkin_pkg::background background);
pure virtual task visit_comment(gherkin_pkg::comment comment);
pure virtual task visit_data_table(gherkin_pkg::data_table data_table);
pure virtual task visit_doc_string(gherkin_pkg::doc_string doc_string);
pure virtual task visit_examples(gherkin_pkg::examples examples);
pure virtual task visit_feature(gherkin_pkg::feature feature);
pure virtual task visit_gherkin_document(gherkin_pkg::gherkin_document gherkin_document);
pure virtual task visit_scenario(gherkin_pkg::scenario scenario);
pure virtual task visit_scenario_definition(gherkin_pkg::scenario_definition scenario_definition);
pure virtual task visit_scenario_outline(gherkin_pkg::scenario_outline scenario_outline);
pure virtual task visit_step(gherkin_pkg::step step);
pure virtual task visit_step_argument(gherkin_pkg::step_argument step_argument);
pure virtual task visit_table_cell(gherkin_pkg::table_cell table_cell);
pure virtual task visit_table_row(gherkin_pkg::table_row table_row);
pure virtual task visit_tag(gherkin_pkg::tag tag);
endclass : visitor
(* visitor_pattern *)
interface class element;
pure virtual task accept(gherkin_pkg::visitor visitor);
endclass : element
class comment extends uvm_object implements element;
string text;
`uvm_object_utils(comment)
function new(string name = "comment");
super.new(name);
endfunction : new
function comment configure(string text);
this.text = text;
return this;
endfunction : configure
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_comment(this);
endtask : accept
endclass : comment
virtual class step_argument extends uvm_object implements element;
function new(string name = "step_argument");
super.new(name);
endfunction : new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_step_argument(this);
endtask : accept
endclass : step_argument
class table_cell extends uvm_object implements element;
string value;
`uvm_object_utils(table_cell)
function new(string name="table_cell");
super.new(name);
this.value = "";
endfunction : new
static function table_cell create_new(string name="table_cell", string value="");
table_cell new_obj;
new_obj = new(name);
new_obj.value = value;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_table_cell(this);
endtask : accept
endclass : table_cell
class table_row extends uvm_object implements element;
table_cell cells[$];
`uvm_object_utils(table_row)
function new(string name="table_row");
super.new(name);
cells.delete();
endfunction : new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_table_row(this);
endtask : accept
endclass : table_row
class data_table extends step_argument implements element;
table_row rows[$];
`uvm_object_utils(data_table)
function new(string name = "data_table");
super.new(name);
rows.delete();
endfunction : new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_data_table(this);
endtask : accept
endclass : data_table
class doc_string extends step_argument implements element;
string content;
string content_type;
`uvm_object_utils(doc_string)
function new(string name = "doc_string");
super.new(name);
this.content = "";
this.content_type = "";
endfunction : new
function doc_string configure(string content="", string content_type="");
this.content = content;
this.content_type = content_type;
return this;
endfunction : configure
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_doc_string(this);
endtask : accept
endclass : doc_string
class step extends uvm_object implements element;
string keyword;
string text;
step_argument argument;
`uvm_object_utils(step)
function new(string name = "step");
super.new(name);
this.keyword = "";
this.text = "";
this.argument = null;
endfunction : new
static function step create_new(string name = "step", string keyword, string text);
step new_obj;
new_obj = new(name);
new_obj.keyword = keyword;
new_obj.text = text;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_step(this);
endtask : accept
endclass : step
virtual class scenario_definition extends uvm_object implements element;
string keyword;
string scenario_definition_name;
string description;
step steps[$];
function new(string name = "scenario_definition");
super.new(name);
this.keyword = "";
this.scenario_definition_name = "";
this.description = "";
this.steps.delete();
endfunction : new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_scenario_definition(this);
endtask : accept
endclass : scenario_definition
class background extends scenario_definition implements element;
step steps[$];
`uvm_object_utils(background)
function new(string name = "background", string scenario_definition_name="", string description="", string keyword="Background");
super.new(name);
this.scenario_definition_name = scenario_definition_name;
this.description = description;
this.keyword = keyword;
this.steps.delete();
endfunction : new
static function background create_new(string name = "background", string scenario_definition_name="", string description="", string keyword="Background");
background new_obj;
new_obj = new(name);
new_obj.scenario_definition_name = scenario_definition_name;
new_obj.description = description;
new_obj.keyword = keyword;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_background(this);
endtask : accept
endclass : background
class tag extends uvm_object implements element;
string tag_name;
`uvm_object_utils(tag)
function new(string name="tag");
super.new(name);
tag_name = "";
endfunction : new
function tag configure(string tag_name="");
this.tag_name = tag_name;
return this;
endfunction : configure
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_tag(this);
endtask : accept
endclass : tag
class examples extends uvm_object implements element;
string keyword;
string examples_name;
string description;
table_row header;
table_row rows[$];
function new(string name="examples");
super.new(name);
this.keyword = "Examples";
this.examples_name = "";
this.description = "";
this.header = new("header");
this.rows.delete();
endfunction : new
static function examples create_new(string name="examples", string examples_name="", string description="", string keyword="Examples");
examples new_obj;
new_obj = new(name);
new_obj.examples_name = examples_name;
new_obj.description = description;
new_obj.keyword = keyword;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_examples(this);
endtask : accept
endclass : examples
class scenario_outline extends scenario_definition implements element;
tag tags[$];
gherkin_pkg::examples examples[$];
`uvm_object_utils(scenario_outline)
function new(string name = "scenario_outline");
super.new(name);
tags.delete();
examples.delete();
endfunction : new
static function scenario_outline create_new(string name = "scenario_outline", string scenario_definition_name="", string description="", string keyword="Scenario Outline");
scenario_outline new_obj;
new_obj = new(name);
new_obj.scenario_definition_name = scenario_definition_name;
new_obj.description = description;
new_obj.keyword = keyword;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_scenario_outline(this);
endtask : accept
endclass : scenario_outline
class scenario extends scenario_definition implements element;
tag tags[$];
`uvm_object_utils(scenario)
function new(string name = "scenario");
super.new(name);
tags.delete();
endfunction : new
static function scenario create_new(string name = "scenario", string scenario_definition_name="", string description="", string keyword="Scenario");
scenario new_obj;
new_obj = new(name);
new_obj.scenario_definition_name = scenario_definition_name;
new_obj.description = description;
new_obj.keyword = keyword;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_scenario(this);
endtask : accept
endclass : scenario
class feature extends uvm_object implements element;
string language;
string keyword;
string feature_name;
string description;
tag tags[$];
scenario_definition scenario_definitions[$];
`uvm_object_utils(feature)
function new(string name = "feature");
super.new(name);
scenario_definitions.delete();
endfunction : new
static function feature create_new(string name = "feature", string feature_name="", string description="", string keyword="Feature", string language="en");
feature new_obj;
new_obj = new(name);
new_obj.keyword = keyword;
new_obj.feature_name = feature_name;
new_obj.description = description;
new_obj.language = language;
return new_obj;
endfunction : create_new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_feature(this);
endtask : accept
endclass : feature
class gherkin_document extends uvm_object implements element;
gherkin_pkg::feature feature;
comment comments[$];
`uvm_object_utils(gherkin_document)
function new(string name = "gherkin_document");
super.new(name);
this.feature = null;
this.comments.delete();
endfunction : new
virtual task accept(gherkin_pkg::visitor visitor);
visitor.visit_gherkin_document(this);
endtask : accept
endclass : gherkin_document
endpackage : gherkin_pkg