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

Function TestParseTermPositive

parse/parse_test.go:741–910  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

739}
740
741func TestParseTermPositive(t *testing.T) {
742 tests := []struct {
743 name string
744 str string
745 want ast.Term
746 }{
747 {
748 name: "constant",
749 str: "/bar",
750 want: name("/bar"),
751 },
752 {
753 name: "constant 2",
754 str: "/bar/baz",
755 want: name("/bar/baz"),
756 },
757 {
758 name: "number",
759 str: "42",
760 want: ast.Number(42),
761 },
762 {
763 name: "negative number",
764 str: "-42",
765 want: ast.Number(-42),
766 },
767 {
768 name: "number constant",
769 str: "0000",
770 want: ast.Number(0),
771 },
772 {
773 name: "float64 constant",
774 str: "-100.123",
775 want: ast.Float64(-100.123),
776 },
777
778 {
779 name: "variable",
780 str: "X",
781 want: ast.Variable{"X"},
782 },
783 {
784 name: "atom",
785 str: "foo(/bar)",
786 want: ast.NewAtom("foo", name("/bar")),
787 },
788 {
789 name: "atom whitespace",
790 str: " foo( /bar ,/baz , /bak )",
791 want: ast.NewAtom("foo", name("/bar"), name("/baz"), name("/bak")),
792 },
793 {
794 name: "atom number",
795 str: "foo(100)",
796 want: ast.NewAtom("foo", ast.Number(100)),
797 },
798 {

Callers

nothing calls this directly

Calls 7

NumberFunction · 0.92
Float64Function · 0.92
NewAtomFunction · 0.92
StringFunction · 0.92
nameFunction · 0.70
TermFunction · 0.70
EqualsMethod · 0.65

Tested by

no test coverage detected