mal-go/read/read_test.go
2025-11-04 05:50:37 -10:00

24 lines
737 B
Go

package read
import (
"github.com/stretchr/testify/assert"
"mal-go/symbol"
"testing"
)
func TestReadSymbol(t *testing.T) {
input := "foo"
sym, err, end_pos := readSymbol(input, 0, "user")
assert.Equal(t, sym, symbol.Intern("user", "foo"), "should read user/foo symbol")
assert.Equal(t, err, nil, "should read without error")
assert.Equal(t, end_pos, len(input), "should read the whole string")
}
func TestReadSymbolWithNamespace(t *testing.T) {
input := "foo/bar"
sym, err, end_pos := readSymbol(input, 0, "user")
assert.Equal(t, sym, symbol.Intern("foo", "bar"), "should read user/foo symbol")
assert.Equal(t, err, nil, "should read without error")
assert.Equal(t, end_pos, len(input), "should read the whole string")
}