MCPcopy Index your code
hub / github.com/google/mangle / TestParseTemporalDecl

Function TestParseTemporalDecl

parse/temporal_test.go:447–515  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

445}
446
447func TestParseTemporalDecl(t *testing.T) {
448 tests := []struct {
449 name string
450 str string
451 wantTemporal bool
452 wantErr bool
453 }{
454 {
455 name: "simple temporal declaration",
456 str: "Decl foo(X) temporal.",
457 wantTemporal: true,
458 wantErr: false,
459 },
460 {
461 name: "temporal declaration with bounds",
462 str: "Decl event(X, Y) temporal bound [/name, /number].",
463 wantTemporal: true,
464 wantErr: false,
465 },
466 {
467 name: "temporal declaration with descr",
468 str: `Decl activity(X) temporal descr [doc("A temporal predicate")].`,
469 wantTemporal: true,
470 wantErr: false,
471 },
472 {
473 name: "non-temporal declaration",
474 str: "Decl bar(X, Y) bound [/string, /number].",
475 wantTemporal: false,
476 wantErr: false,
477 },
478 {
479 name: "temporal declaration with multiple bounds",
480 str: "Decl status(X, Y, Z) temporal bound [/name, /string, /number].",
481 wantTemporal: true,
482 wantErr: false,
483 },
484 }
485
486 for _, test := range tests {
487 t.Run(test.name, func(t *testing.T) {
488 unit, err := Unit(strings.NewReader(test.str))
489 if (err != nil) != test.wantErr {
490 t.Fatalf("Unit(%q) error = %v, wantErr = %v", test.str, err, test.wantErr)
491 }
492 if err != nil {
493 return
494 }
495
496 // The parser adds a default Package decl when none specified, so we look for
497 // the user's declaration (second one) or find the non-Package declaration.
498 var decl ast.Decl
499 for _, d := range unit.Decls {
500 if d.DeclaredAtom.Predicate.Symbol != "Package" {
501 decl = d
502 break
503 }
504 }

Callers

nothing calls this directly

Calls 2

IsTemporalMethod · 0.95
UnitFunction · 0.85

Tested by

no test coverage detected