(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr)
| 641 | } |
| 642 | |
| 643 | func mathGreatest(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { |
| 644 | if !macroTargetMatchesNamespace(mathNamespace, target) { |
| 645 | return nil, nil |
| 646 | } |
| 647 | switch len(args) { |
| 648 | case 0: |
| 649 | return nil, mef.NewError(target.ID(), "math.greatest() requires at least one argument") |
| 650 | case 1: |
| 651 | if isListLiteralWithNumericArgs(args[0]) || isNumericArgType(args[0]) { |
| 652 | return mef.NewCall(maxFunc, args[0]), nil |
| 653 | } |
| 654 | return nil, mef.NewError(args[0].ID(), "math.greatest() invalid single argument value") |
| 655 | case 2: |
| 656 | err := checkInvalidArgs(mef, "math.greatest()", args) |
| 657 | if err != nil { |
| 658 | return nil, err |
| 659 | } |
| 660 | return mef.NewCall(maxFunc, args...), nil |
| 661 | default: |
| 662 | err := checkInvalidArgs(mef, "math.greatest()", args) |
| 663 | if err != nil { |
| 664 | return nil, err |
| 665 | } |
| 666 | return mef.NewCall(maxFunc, mef.NewList(args...)), nil |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | func identity(val ref.Val) ref.Val { |
| 671 | return val |
nothing calls this directly
no test coverage detected