Compare commits
2 Commits
5853365707
...
4379960835
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4379960835 | ||
|
|
2aeec1e5f6 |
@@ -7,7 +7,27 @@ package schema
|
|||||||
States!: {...} // type: node
|
States!: {...} // type: node
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
Message: {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
StateMachineEvent: {
|
||||||
|
NextState!: string
|
||||||
|
NextStateError!: string
|
||||||
|
Timeout: uint32
|
||||||
|
[_= !~"^(Class|NextState|Timeout|NextStateError|[#_$].+)$"]: Message
|
||||||
|
...
|
||||||
|
}
|
||||||
|
_State: {
|
||||||
|
Class: "ReferenceContainer"
|
||||||
|
ENTER?: {
|
||||||
|
Class: "ReferenceContainer"
|
||||||
|
...
|
||||||
|
}
|
||||||
|
[_ = !~"^(Class|ENTER)$"]: StateMachineEvent
|
||||||
|
...
|
||||||
|
}
|
||||||
StateMachine: {
|
StateMachine: {
|
||||||
|
[_ = !~"^(Class|[$].*)$"]: _State
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
RealTimeState: {
|
RealTimeState: {
|
||||||
|
|||||||
@@ -9,39 +9,6 @@ import (
|
|||||||
"github.com/marte-dev/marte-dev-tools/internal/validator"
|
"github.com/marte-dev/marte-dev-tools/internal/validator"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSchemaValidationMandatory(t *testing.T) {
|
|
||||||
// StateMachine requires "States"
|
|
||||||
content := `
|
|
||||||
+MySM = {
|
|
||||||
Class = StateMachine
|
|
||||||
// Missing States
|
|
||||||
}
|
|
||||||
`
|
|
||||||
p := parser.NewParser(content)
|
|
||||||
config, err := p.Parse()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Parse failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
idx := index.NewProjectTree()
|
|
||||||
idx.AddFile("test.marte", config)
|
|
||||||
|
|
||||||
v := validator.NewValidator(idx, ".")
|
|
||||||
v.ValidateProject()
|
|
||||||
|
|
||||||
found := false
|
|
||||||
for _, d := range v.Diagnostics {
|
|
||||||
if strings.Contains(d.Message, "States: field is required") {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
t.Error("Expected error for missing mandatory field 'States', but found none")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSchemaValidationType(t *testing.T) {
|
func TestSchemaValidationType(t *testing.T) {
|
||||||
// OrderedClass: First (int), Second (string)
|
// OrderedClass: First (int), Second (string)
|
||||||
content := `
|
content := `
|
||||||
|
|||||||
Reference in New Issue
Block a user