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

Function TestBoundOfArgTimeDuration

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

Source from the content-addressed store, hash-verified

981 }
982}
983func TestBoundOfArgTimeDuration(t *testing.T) {
984 // Setup a minimal analyzer/context if needed, or just test boundOfArg directly if possible.
985 // boundOfArg is private, so we need to test it via exported function or be in the same package.
986 // We are in 'analysis' package.
987
988 // Helper to create a dummy name trie
989 nameTrie := symbols.NewNameTrie()
990
991 tests := []struct {
992 name string
993 arg ast.BaseTerm
994 want ast.BaseTerm
995 }{
996 {
997 name: "Time constant",
998 arg: ast.Time(123456789),
999 want: ast.TimeBound,
1000 },
1001 {
1002 name: "Duration constant",
1003 arg: ast.Duration(1000),
1004 want: ast.DurationBound,
1005 },
1006 {
1007 name: "Float64 constant",
1008 arg: ast.Float64(3.14),
1009 want: ast.Float64Bound,
1010 },
1011 }
1012
1013 for _, tt := range tests {
1014 t.Run(tt.name, func(t *testing.T) {
1015 got := boundOfArg(tt.arg, nil, nameTrie)
1016 if !got.Equals(tt.want) {
1017 t.Errorf("boundOfArg(%v) = %v, want %v", tt.arg, got, tt.want)
1018 }
1019 })
1020 }
1021}
1022
1023func TestAnalyzeTemporal(t *testing.T) {
1024 program := `

Callers

nothing calls this directly

Calls 6

NewNameTrieFunction · 0.92
TimeFunction · 0.92
DurationFunction · 0.92
Float64Function · 0.92
boundOfArgFunction · 0.85
EqualsMethod · 0.65

Tested by

no test coverage detected