// Copyright (c) 2024-2026 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.

// t_term_test.go
package expr

import (
	"testing"

	"git.portale-stac.it/go-pkg/expr/scan"
	"git.portale-stac.it/go-pkg/expr/sym"
)

func TestString(t *testing.T) {
	tk1 := scan.NewValueToken(0, 0, sym.SymInteger, "100", 100)
	tk2 := scan.NewToken(0, 0, sym.SymPlus, "+")
	tk3 := scan.NewValueToken(0, 0, sym.SymInteger, "50", 500)

	tree := scan.NewAst()
	if gotErr := tree.AddTokens(tk1, tk2, tk3); gotErr == nil {
		t.Log("Tree:", tree)
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}

func TestGetRoom(t *testing.T) {
	tk1 := scan.NewValueToken(0, 0, sym.SymInteger, "100", 100)

	tree := scan.NewAst()
	if gotErr := tree.AddTokens(tk1); gotErr == nil {
		t.Log("Tree-root room:", tree.Root().GetRoom())
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}

func TestGetChildrenCount(t *testing.T) {
	tk1 := scan.NewValueToken(0, 0, sym.SymInteger, "100", 100)

	tree := scan.NewAst()
	if gotErr := tree.AddTokens(tk1); gotErr == nil {
		t.Log("Tree-root children count:", tree.Root().GetChildCount())
	} else {
		t.Errorf("err: got <%v>, want <nil>", gotErr)
	}
}
