|
|
@ -1,6 +1,9 @@
|
|
|
|
package lang
|
|
|
|
package lang
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
@ -110,6 +113,28 @@ func TestRepr(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestReprOfValue(t *testing.T) {
|
|
|
|
|
|
|
|
t.Run("error", func(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Equal(t, "error", reprOfValue(reflect.ValueOf(errors.New("error"))))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Run("stringer", func(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Equal(t, "1.23", reprOfValue(reflect.ValueOf(json.Number("1.23"))))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Run("int", func(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Equal(t, "1", reprOfValue(reflect.ValueOf(1)))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Run("int", func(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Equal(t, "1", reprOfValue(reflect.ValueOf("1")))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.Run("int", func(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Equal(t, "1", reprOfValue(reflect.ValueOf(uint(1))))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type mockStringable struct{}
|
|
|
|
type mockStringable struct{}
|
|
|
|
|
|
|
|
|
|
|
|
func (m mockStringable) String() string {
|
|
|
|
func (m mockStringable) String() string {
|
|
|
|