MCPcopy
hub / github.com/grafana/tempo / TestSpansetExpressionPrecedence

Function TestSpansetExpressionPrecedence

pkg/traceql/parse_test.go:586–643  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

584}
585
586func TestSpansetExpressionPrecedence(t *testing.T) {
587 tests := []struct {
588 in string
589 expected SpansetOperation
590 expectedStr string
591 }{
592 {
593 in: "{ true } && { false } >> { `a` }",
594 expected: newSpansetOperation(OpSpansetAnd,
595 newSpansetFilter(NewStaticBool(true)),
596 newSpansetOperation(OpSpansetDescendant, newSpansetFilter(NewStaticBool(false)), newSpansetFilter(NewStaticString("a"))),
597 ),
598 expectedStr: "({ true }) && (({ false }) >> ({ `a` }))",
599 },
600 {
601 in: "{ true } >> { false } && { `a` }",
602 expected: newSpansetOperation(OpSpansetAnd,
603 newSpansetOperation(OpSpansetDescendant, newSpansetFilter(NewStaticBool(true)), newSpansetFilter(NewStaticBool(false))),
604 newSpansetFilter(NewStaticString("a")),
605 ),
606 expectedStr: "(({ true }) >> ({ false })) && ({ `a` })",
607 },
608 {
609 in: "({ true } >> { false }) && { `a` }",
610 expected: newSpansetOperation(OpSpansetAnd,
611 newSpansetOperation(OpSpansetDescendant, newSpansetFilter(NewStaticBool(true)), newSpansetFilter(NewStaticBool(false))),
612 newSpansetFilter(NewStaticString("a")),
613 ),
614 expectedStr: "(({ true }) >> ({ false })) && ({ `a` })",
615 },
616 {
617 in: "{ true } >> { false } ~ { `a` }",
618 expected: newSpansetOperation(OpSpansetSibling,
619 newSpansetOperation(OpSpansetDescendant, newSpansetFilter(NewStaticBool(true)), newSpansetFilter(NewStaticBool(false))),
620 newSpansetFilter(NewStaticString("a")),
621 ),
622 expectedStr: "(({ true }) >> ({ false })) ~ ({ `a` })",
623 },
624 {
625 in: "{ true } ~ { false } >> { `a` }",
626 expected: newSpansetOperation(OpSpansetDescendant,
627 newSpansetOperation(OpSpansetSibling, newSpansetFilter(NewStaticBool(true)), newSpansetFilter(NewStaticBool(false))),
628 newSpansetFilter(NewStaticString("a")),
629 ),
630 expectedStr: "(({ true }) ~ ({ false })) >> ({ `a` })",
631 },
632 }
633
634 for _, tc := range tests {
635 t.Run(tc.in, func(t *testing.T) {
636 actual, err := Parse(tc.in)
637
638 require.NoError(t, err)
639 require.Equal(t, newRootExpr(newPipeline(tc.expected)), actual)
640 require.Equal(t, tc.expectedStr, actual.String())
641 })
642 }
643}

Callers

nothing calls this directly

Calls 10

newSpansetOperationFunction · 0.85
newSpansetFilterFunction · 0.85
NewStaticBoolFunction · 0.85
NewStaticStringFunction · 0.85
ParseFunction · 0.85
newRootExprFunction · 0.85
newPipelineFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected