mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
Fixup for #1342.
This commit is contained in:
parent
3da541c719
commit
4afab8804b
|
@ -658,8 +658,12 @@ func fromLines(fm *Frame) error {
|
|||
// ```
|
||||
//
|
||||
// Takes bytes stdin, parses it as JSON and puts the result on structured stdout.
|
||||
// The input can contain multiple JSONs, which can, but do not have to, be
|
||||
// separated with whitespaces.
|
||||
// The input can contain multiple JSONs, and whitespace between them are ignored.
|
||||
//
|
||||
// Note that JSON's only number type corresponds to Elvish's floating-point
|
||||
// number type, and is always considered [inexact](language.html#exactness).
|
||||
// It may be necessary to coerce JSON numbers to exact numbers using
|
||||
// [exact-num](#exact-num).
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
|
@ -715,7 +719,6 @@ func fromJSONInterface(v interface{}) (interface{}, error) {
|
|||
case nil, bool, string:
|
||||
return v, nil
|
||||
case float64:
|
||||
// TODO: Decide if we want to normalize ints here.
|
||||
return v, nil
|
||||
case []interface{}:
|
||||
vec := vals.EmptyList
|
||||
|
|
|
@ -69,9 +69,9 @@ func TestStyledConcat(t *testing.T) {
|
|||
// segment+text
|
||||
That("print (styled-segment abc &underlined=$true)(styled abc bright-cyan)").Prints("\033[4mabc\033[m\033[96mabc\033[m"),
|
||||
// segment+num
|
||||
That("print (float64 99)(styled-segment abc &blink)").Prints("99.0\033[5mabc\033[m"),
|
||||
That("print (num 99.0)(styled-segment abc &blink)").Prints("99.0\033[5mabc\033[m"),
|
||||
That("print (num 66)(styled-segment abc &blink)").Prints("66\033[5mabc\033[m"),
|
||||
That("print (num 33)(styled-segment abc &blink)").Prints("33\033[5mabc\033[m"),
|
||||
That("print (num 3/2)(styled-segment abc &blink)").Prints("3/2\033[5mabc\033[m"),
|
||||
// num+segment
|
||||
That("print (styled-segment abc &blink)(float64 88)").Prints("\033[5mabc\033[m88.0"),
|
||||
That("print (styled-segment abc &blink)(num 44/3)").Prints("\033[5mabc\033[m44/3"),
|
||||
|
|
|
@ -27,8 +27,9 @@ func TestEqual(t *testing.T) {
|
|||
Args("1.0", 1.0).Rets(false),
|
||||
Args(1, 1.0).Rets(false),
|
||||
Args(1, 1).Rets(true),
|
||||
Args(big.NewInt(1), big.NewInt(1)).Rets(true),
|
||||
Args(big.NewInt(1), 1).Rets(false),
|
||||
Args(bigInt(z), bigInt(z)).Rets(true),
|
||||
Args(bigInt(z), 1).Rets(false),
|
||||
Args(bigInt(z), bigInt(z1)).Rets(false),
|
||||
Args(big.NewRat(1, 2), big.NewRat(1, 2)).Rets(true),
|
||||
Args(big.NewRat(1, 2), 0.5).Rets(false),
|
||||
|
||||
|
|
|
@ -20,9 +20,8 @@ func ToString(v interface{}) string {
|
|||
case int:
|
||||
return strconv.Itoa(v)
|
||||
case float64:
|
||||
// Float64 is special-cased for historical reasons. The other number types are handled by
|
||||
// the Stringer interface.
|
||||
return formatFloat64(v)
|
||||
// Other number types handled by "case Stringer"
|
||||
case string:
|
||||
return v
|
||||
case Stringer:
|
||||
|
|
Loading…
Reference in New Issue
Block a user