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

Function TestIntegration_EternalFacts

engine/temporal_integration_test.go:412–464  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

410}
411
412func TestIntegration_EternalFacts(t *testing.T) {
413 // Create a temporal store
414 store := factstore.NewTemporalStore()
415
416 // Add an eternal fact (valid for all time)
417 admin := ast.NewAtom("admin", name("/root"))
418 store.AddEternal(admin)
419
420 tests := []struct {
421 name string
422 evalTime time.Time
423 wantMatch bool
424 }{
425 {
426 name: "Past: eternal fact is valid",
427 evalTime: ast.Date(1990, 1, 1),
428 wantMatch: true,
429 },
430 {
431 name: "Present: eternal fact is valid",
432 evalTime: ast.Date(2024, 1, 1),
433 wantMatch: true,
434 },
435 {
436 name: "Future: eternal fact is valid",
437 evalTime: ast.Date(2100, 1, 1),
438 wantMatch: true,
439 },
440 }
441
442 for _, test := range tests {
443 t.Run(test.name, func(t *testing.T) {
444 te := NewTemporalEvaluator(store, test.evalTime)
445
446 query := ast.NewAtom("admin", name("/root"))
447 tl := ast.TemporalLiteral{
448 Literal: query,
449 Operator: nil,
450 Interval: nil,
451 }
452
453 solutions, err := te.EvalTemporalLiteral(tl, unionfind.New())
454 if err != nil {
455 t.Fatalf("EvalTemporalLiteral failed: %v", err)
456 }
457
458 gotMatch := len(solutions) > 0
459 if gotMatch != test.wantMatch {
460 t.Errorf("Got match = %v, want %v", gotMatch, test.wantMatch)
461 }
462 })
463 }
464}
465
466func TestIntegration_IntervalFunctions(t *testing.T) {
467 // Test the interval extraction functions

Callers

nothing calls this directly

Calls 8

AddEternalMethod · 0.95
EvalTemporalLiteralMethod · 0.95
NewTemporalStoreFunction · 0.92
NewAtomFunction · 0.92
DateFunction · 0.92
NewFunction · 0.92
NewTemporalEvaluatorFunction · 0.85
nameFunction · 0.70

Tested by

no test coverage detected