Skip to content

Commit 9789e0f

Browse files
authored
Merge pull request #16 from Anshukumar123975/main
Add New Semantic Validation Rules and Conformance Tests
2 parents 8303cea + a8397d0 commit 9789e0f

File tree

82 files changed

+215
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+215
-85
lines changed

runner.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Parser } from '@accordproject/concerto-cto';
2+
import { ModelFile, ModelManager } from '@accordproject/concerto-core';
3+
4+
export default {
5+
parser: Parser,
6+
modelFile: ModelFile,
7+
modelManager: new ModelManager({ enableMapType: true }),
8+
};

semantic/features/concepts.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ Feature: Semantic Validation for CTO Class Declarations
114114
When I validate the models
115115
Then no error should be thrown
116116

117+
Scenario: Unique property names across inheritance
118+
Given I load the following models:
119+
| model_file | alias |
120+
| concepts/models/CLASS_DECLARATION_009/class_declaration_009_circular_inheritance.cto | main |
121+
When I validate the models
122+
Then an error should be thrown with message "Maximum call stack size exceeded"
123+
124+
Scenario: Unique property names across inheritance
125+
Given I load the following models:
126+
| model_file | alias |
127+
| concepts/models/CLASS_DECLARATION_009/class_declaration_009_valid_inheritance.cto | main |
128+
When I validate the models
129+
Then no error should be thrown
130+
131+
Scenario: Unique property names across inheritance
132+
Given I load the following models:
133+
| model_file | alias |
134+
| concepts/models/CLASS_DECLARATION_010/class_declaration_010_duplicate_property_from_super.cto | main |
135+
When I validate the models
136+
Then an error should be thrown with message "has more than one field"
137+
138+
Scenario: Unique property names across inheritance
139+
Given I load the following models:
140+
| model_file | alias |
141+
| concepts/models/CLASS_DECLARATION_010/class_declaration_010_unique_property_from_super.cto | main |
142+
When I validate the models
143+
Then no error should be thrown
144+
117145
Scenario: Duplicate declarations should throw
118146
Given I load the following models:
119147
| model_file | alias |

semantic/features/namespaces.feature

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,30 @@ Feature: Semantic Validation of CTO Namespace Imports
33
@skip
44
Scenario: Invalid duplicate namespace imports should throw an error
55
Given I load the following models:
6-
| model_file | alias |
7-
| namespaces/models/MODEL_FILE_002/importedTypes.cto | imported |
8-
| namespaces/models/MODEL_FILE_002/model_file_002_duplicate_namespace_imports.cto | main |
6+
| model_file | alias |
7+
| namespaces/models/MODEL_FILE_002/importedTypes.cto | imported |
8+
| namespaces/models/MODEL_FILE_002/model_file_002_duplicate_namespace_imports.cto | main |
99
When I validate the models
1010
Then an error should be thrown with message "Namespace org.external.types is already defined"
1111

1212
Scenario: Valid unique namespace imports should pass
1313
Given I load the following models:
14-
| model_file | alias |
15-
| namespaces/models/MODEL_FILE_002/importedTypes.cto | imported |
16-
| namespaces/models/MODEL_FILE_002/model_file_002_unique_namespace_imports.cto | main |
14+
| model_file | alias |
15+
| namespaces/models/MODEL_FILE_002/importedTypes.cto | imported |
16+
| namespaces/models/MODEL_FILE_002/model_file_002_unique_namespace_imports.cto | main |
1717
When I validate the models
18-
Then no error should be thrown
18+
Then no error should be thrown
19+
20+
Scenario: Invalid self-import should throw MODEL_FILE_004 error
21+
Given I load the following models:
22+
| model_file | alias |
23+
| namespaces/models/MODEL_FILE_003/model_file_003_self_import.cto | main |
24+
When I validate the models
25+
Then an error should be thrown with message "Namespace is not defined for type"
26+
27+
Scenario: Valid model without self-import should pass
28+
Given I load the following models:
29+
| model_file | alias |
30+
| namespaces/models/MODEL_FILE_003/model_file_003_valid_import.cto | main |
31+
When I validate the models
32+
Then no error should be thrown

semantic/features/scalars.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ Feature: Semantic Validation of CTO Scalars specification
2424
| scalars/models/NUMBER_VALIDATOR_002/number_validator_002_lower_greater_than_upper.cto |main|
2525
Then an error should be thrown with message "/Lower bound must be less than or equal to upper bound/"
2626

27+
28+
Scenario: Invalid floating point range on Integer property should throw an error
29+
Given I load the following models:
30+
| model_file | alias |
31+
| scalars/models/NUMBER_VALIDATOR_003/number_validator_003_invalid_range_type.cto | main |
32+
Then an error should be thrown with message 'Expected ","'
33+
34+
Scenario: Valid integer range on Integer property should pass validation
35+
Given I load the following models:
36+
| model_file | alias |
37+
| scalars/models/NUMBER_VALIDATOR_003/number_validator_003_valid_range_type.cto | main |
38+
Then no error should be thrown
39+
2740
Scenario: should pass for valid string length bounds
2841
Given I load the following models:
2942
| model_file |alias|

semantic/features/support/C#/Semantic.Support.CSharp/obj/Debug/net6.0/Semantic.Support.CSharp.AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[assembly: System.Reflection.AssemblyCompanyAttribute("Semantic.Support.CSharp")]
1414
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
1515
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
16-
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ab1c0b591c54f581969d654d8f4aed6e3c76c4c5")]
16+
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+63a012d9040a0114719eb56b8d735e07fff7bb4a")]
1717
[assembly: System.Reflection.AssemblyProductAttribute("Semantic.Support.CSharp")]
1818
[assembly: System.Reflection.AssemblyTitleAttribute("Semantic.Support.CSharp")]
1919
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e78ef0e113f61fa9a797fd34e6fd0045449697fdb637ea1b17d1870a1d3f0d10
1+
ac751e616cdb4178e8e1b0c3c1233dc4b2b6a691fe113800adc728d7d8146b29

semantic/features/support/Javascript/steps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Given('I load the following models:', function (dataTable) {
1919
}
2020
});
2121

22+
2223
When('I validate the models', function () {
2324
try {
2425
this.modelManager.validateModelFiles();

semantic/specifications/concepts/models/CLASS_DECLARATION_001/class_declaration_001_system_property_name.cto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace org.example.invalid
1+
namespace org.concerto.concepts.cd001.invalid@1.0.0
22

33
concept SampleConcept {
44
o String name

semantic/specifications/concepts/models/CLASS_DECLARATION_001/class_declaration_001_valid_property_name.cto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace org.example.valid
1+
namespace org.concerto.concepts.cd001.valid@1.0.0
22

33
concept SampleConcept {
44
o String name

semantic/specifications/concepts/models/CLASS_DECLARATION_002/class_declaration_002_invalid_$class_type.cto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace org.example.invalid
1+
namespace org.concerto.concepts.cd002.invalid@1.0.0
22

33
concept SampleConcept {
44
o Integer $class

0 commit comments

Comments
 (0)