MCPcopy
hub / github.com/dgraph-io/dgraph / TestParseQueryWithVarValAggNestedConditional

Function TestParseQueryWithVarValAggNestedConditional

dql/parser_test.go:648–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

646}
647
648func TestParseQueryWithVarValAggNestedConditional(t *testing.T) {
649 query := `
650 {
651 me(func: uid(L), orderasc: val(d) ) {
652 name
653 val(f)
654 }
655
656 var(func: uid(0x0a)) {
657 L as friends {
658 a as age
659 b as count(friends)
660 c as count(relatives)
661 d as math(cond(a <= 10.0, exp(a + b + 1.0), ln(c)) + 10*a)
662 e as math(cond(a!=10.0, exp(a + b + 1.0), ln(d)))
663 f as math(cond(a==10.0, exp(a + b + 1.0), ln(e)))
664 }
665 }
666 }
667`
668 res, err := Parse(Request{Str: query})
669 require.NoError(t, err)
670 require.EqualValues(t, "(+ (cond (<= a 1E+01) (exp (+ (+ a b) 1E+00)) (ln c)) (* 10 a))",
671 res.Query[1].Children[0].Children[3].MathExp.debugString())
672 require.EqualValues(t, "(cond (!= a 1E+01) (exp (+ (+ a b) 1E+00)) (ln d))",
673 res.Query[1].Children[0].Children[4].MathExp.debugString())
674 require.EqualValues(t, "(cond (== a 1E+01) (exp (+ (+ a b) 1E+00)) (ln e))",
675 res.Query[1].Children[0].Children[5].MathExp.debugString())
676}
677
678func TestParseQueryWithVarValAggNested3(t *testing.T) {
679 query := `

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.70
debugStringMethod · 0.45

Tested by

no test coverage detected