Compare commits

...

2 Commits

Author SHA1 Message Date
Martino Ferrari
4379960835 Removed wrong test 2026-01-23 11:42:34 +01:00
Martino Ferrari
2aeec1e5f6 better validation of statemachine 2026-01-23 11:42:29 +01:00
2 changed files with 20 additions and 33 deletions

View File

@@ -7,7 +7,27 @@ package schema
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: {
[_ = !~"^(Class|[$].*)$"]: _State
...
}
RealTimeState: {

View File

@@ -9,39 +9,6 @@ import (
"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) {
// OrderedClass: First (int), Second (string)
content := `