package ast_test

import (
	"testing"

	"github.com/expr-lang/expr/internal/testify/assert"
	"github.com/expr-lang/expr/internal/testify/require"

	"github.com/expr-lang/expr/ast"
	"github.com/expr-lang/expr/parser"
)

func TestPrint(t *testing.T) {
	tests := []struct {
		input string
		want  string
	}{
		{`nil`, `nil`},
		{`true`, `true`},
		{`false`, `false`},
		{`1`, `1`},
		{`1.1`, `1.1`},
		{`"a"`, `"a"`},
		{`'a'`, `"a"`},
		{`a`, `a`},
		{`a.b`, `a.b`},
		{`a[0]`, `a[0]`},
		{`a["the b"]`, `a["the b"]`},
		{`a.b[0]`, `a.b[0]`},
		{`a?.b`, `a?.b`},
		{`x[0][1]`, `x[0][1]`},
		{`x?.[0]?.[1]`, `x?.[0]?.[1]`},
		{`-a`, `-a`},
		{`!a`, `!a`},
		{`not a`, `not a`},
		{`a + b`, `a + b`},
		{`a + b * c`, `a + b * c`},
		{`(a + b) * c`, `(a + b) * c`},
		{`a * (b + c)`, `a * (b + c)`},
		{`-(a + b) * c`, `-(a + b) * c`},
1:package runtime_test
func TestParse(t *testing.T) {
	tests := []struct {
		input string
		want  Node
	}{
		{
			"a",
			&IdentifierNode{Value: "a"},
		},
		{
			`"str"`,
			&StringNode{Value: "str"},
		},
		{
			"`hello\nworld`",
980:func TestParse_error(t *testing.T) {
981-	var tests = []struct {
982-		input string
983-		err   string
984-	}{
985-		{`foo.`, `unexpected end of expression (1:4)
986- | foo.
987- | ...^`},
988-		{`a+`, `unexpected token EOF (1:2)
989- | a+
990- | .^`},
991-		{`a ? (1+2) c`, `unexpected token Identifier("c") (1:11)
992- | a ? (1+2) c
993- | ..........^`},
994-		{`[a b]`, `unexpected token Identifier("b") (1:4)
995- | [a b]
996- | ...^`},
997-		{`foo.bar(a b)`, `unexpected token Identifier("b") (1:11)
998- | foo.bar(a b)
999- | ..........^`},
1000-		{`{-}`, `a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Operator("-")) (1:2)
