MCPcopy
hub / github.com/google/mangle / TestAnalyzeTemporal

Function TestAnalyzeTemporal

analysis/validation_test.go:1023–1048  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1021}
1022
1023func TestAnalyzeTemporal(t *testing.T) {
1024 program := `
1025Decl temp(Name) temporal bound [/name].
1026Decl derived(Name, Time) bound [/name, /any].
1027
1028temp(/a)@[2024-01-01].
1029derived(X, T) :- temp(X)@[T].
1030`
1031 unit, err := parse.Unit(strings.NewReader(program))
1032 if err != nil {
1033 t.Fatalf("parse error: %v", err)
1034 }
1035 info, err := AnalyzeOneUnit(unit, nil)
1036 if err != nil {
1037 t.Fatalf("AnalyzeOneUnit failed: %v", err)
1038 }
1039 if len(info.InitialFacts) != 1 {
1040 t.Errorf("Expected 1 initial fact, got %d", len(info.InitialFacts))
1041 }
1042 if len(info.InitialFactTimes) != 1 || info.InitialFactTimes[0] == nil {
1043 t.Error("Expected temporal info for initial fact, got nil")
1044 }
1045 if len(info.Rules) != 1 {
1046 t.Errorf("Expected 1 rule, got %d", len(info.Rules))
1047 }
1048}

Callers

nothing calls this directly

Calls 3

UnitFunction · 0.92
AnalyzeOneUnitFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected