mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Make the kind of int, *big.Int and *big.Rat "number".
This commit is contained in:
parent
3f0e89d223
commit
2e9e0289cc
|
@ -51,7 +51,7 @@ func TestConcat(t *testing.T) {
|
|||
Args(concatter{}, "bar").Rets("concatter bar", nil),
|
||||
// LHS implements Concatter but returns ErrConcatNotImplemented; RHS
|
||||
// does not implement RConcatter
|
||||
Args(concatter{}, 12).Rets(nil, cannotConcat{"!!vals.concatter", "!!int"}),
|
||||
Args(concatter{}, 12).Rets(nil, cannotConcat{"!!vals.concatter", "number"}),
|
||||
// LHS implements Concatter but returns another error
|
||||
Args(concatter{}, 12.0).Rets(nil, errBadFloat64),
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package vals
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// Kinder wraps the Kind method.
|
||||
|
@ -27,7 +28,7 @@ func Kind(v interface{}) string {
|
|||
return "bool"
|
||||
case string:
|
||||
return "string"
|
||||
case float64:
|
||||
case int, *big.Int, *big.Rat, float64:
|
||||
return "number"
|
||||
case Kinder:
|
||||
return v.Kind()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package vals
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
@ -14,6 +15,9 @@ func TestKind(t *testing.T) {
|
|||
Args(nil).Rets("nil"),
|
||||
Args(true).Rets("bool"),
|
||||
Args("").Rets("string"),
|
||||
Args(1).Rets("number"),
|
||||
Args(bigInt(z)).Rets("number"),
|
||||
Args(big.NewRat(1, 2)).Rets("number"),
|
||||
Args(1.0).Rets("number"),
|
||||
Args(os.Stdin).Rets("file"),
|
||||
Args(EmptyList).Rets("list"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user