Commit 41191e19 authored by Robert Griesemer's avatar Robert Griesemer

go/constant: fix String() implementation

Fixes #14262.

Change-Id: Id590995dd4460e81f6b91bcfb3f02515a97650fe
Reviewed-on: https://go-review.googlesource.com/19361
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 77b4c8d9
......@@ -96,7 +96,7 @@ func (x stringVal) String() string {
// only the first maxLen-3 runes; then add "...".
i := 0
for n := 0; n < maxLen-3; n++ {
_, size := utf8.DecodeRuneInString(s)
_, size := utf8.DecodeRuneInString(s[i:])
i += size
}
s = s[:i] + "..."
......
......@@ -204,6 +204,7 @@ func eql(x, y Value) bool {
// String tests
var xxx = strings.Repeat("x", 68)
var issue14262 = `"بموجب الشروط التالية نسب المصنف — يجب عليك أن تنسب العمل بالطريقة التي تحددها المؤلف أو المرخص (ولكن ليس بأي حال من الأحوال أن توحي وتقترح بتحول أو استخدامك للعمل). المشاركة على قدم المساواة — إذا كنت يعدل ، والتغيير ، أو الاستفادة من هذا العمل ، قد ينتج عن توزيع العمل إلا في ظل تشابه او تطابق فى واحد لهذا الترخيص."`
var stringTests = []struct {
input, short, exact string
......@@ -225,6 +226,7 @@ var stringTests = []struct {
{`"` + xxx + `xx"`, `"` + xxx + `xx"`, `"` + xxx + `xx"`},
{`"` + xxx + `xxx"`, `"` + xxx + `...`, `"` + xxx + `xxx"`},
{`"` + xxx + xxx + `xxx"`, `"` + xxx + `...`, `"` + xxx + xxx + `xxx"`},
{issue14262, `"بموجب الشروط التالية نسب المصنف — يجب عليك أن تنسب العمل بالطريقة ال...`, issue14262},
// Int
{"0", "0", "0"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment