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

// t_token_test.go
package expr

import (
	"fmt"
	"testing"

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

func TestDevString(t *testing.T) {
	type inputType struct {
		source     string
		sym        sym.Symbol
		value      any
		wantResult string
	}

	inputs := []inputType{
		/*   1 */ {"100", sym.SymInteger, 100, fmt.Sprintf(`[%d]"100"{100}`, sym.SymInteger)},
		/*   2 */ {"+", sym.SymPlus, nil, fmt.Sprintf(`[%d]"+"{}`, sym.SymPlus)},
	}

	for i, input := range inputs {
		var tk *scan.Token
		if input.value == nil {
			tk = scan.NewToken(0, 0, input.sym, input.source)
		} else {
			tk = scan.NewValueToken(0, 0, input.sym, input.source, input.value)
		}

		t.Logf("Test nr %2d: %q --> %q", i+1, input.source, input.wantResult)

		if s := tk.DevString(); s != input.wantResult {
			t.Errorf("wrong token from symbol '+': expected %q, got %q", input.wantResult, s)
		}
	}
}
