summaryrefslogtreecommitdiff
path: root/src/pkg/json
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
commit758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch)
tree6d6b34f8c678862fe9b56c945a7b63f68502c245 /src/pkg/json
parent3e45412327a2654a77944249962b3652e6142299 (diff)
downloadgolang-758ff64c69e34965f8af5b2d6ffd65e8d7ab2150.tar.gz
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'src/pkg/json')
-rw-r--r--src/pkg/json/decode.go2
-rw-r--r--src/pkg/json/decode_test.go12
-rw-r--r--src/pkg/json/scanner.go4
-rw-r--r--src/pkg/json/stream_test.go4
4 files changed, 7 insertions, 15 deletions
diff --git a/src/pkg/json/decode.go b/src/pkg/json/decode.go
index c704cacbd..ff91dd83c 100644
--- a/src/pkg/json/decode.go
+++ b/src/pkg/json/decode.go
@@ -749,7 +749,7 @@ func (d *decodeState) literalInterface() interface{} {
}
n, err := strconv.Atof64(string(item))
if err != nil {
- d.saveError(&UnmarshalTypeError{"number " + string(item), reflect.Typeof(float64(0))})
+ d.saveError(&UnmarshalTypeError{"number " + string(item), reflect.Typeof(0.0)})
}
return n
}
diff --git a/src/pkg/json/decode_test.go b/src/pkg/json/decode_test.go
index 68cdea051..9cb27af41 100644
--- a/src/pkg/json/decode_test.go
+++ b/src/pkg/json/decode_test.go
@@ -52,7 +52,7 @@ var unmarshalTests = []unmarshalTest{
// basic types
{`true`, new(bool), true, nil},
{`1`, new(int), 1, nil},
- {`1.2`, new(float), 1.2, nil},
+ {`1.2`, new(float64), 1.2, nil},
{`-5`, new(int16), int16(-5), nil},
{`"a\u1234"`, new(string), "a\u1234", nil},
{`"http:\/\/"`, new(string), "http://", nil},
@@ -220,7 +220,6 @@ type All struct {
Uint32 uint32
Uint64 uint64
Uintptr uintptr
- Float float
Float32 float32
Float64 float64
@@ -238,7 +237,6 @@ type All struct {
PUint32 *uint32
PUint64 *uint64
PUintptr *uintptr
- PFloat *float
PFloat32 *float32
PFloat64 *float64
@@ -291,7 +289,6 @@ var allValue = All{
Uint32: 10,
Uint64: 11,
Uintptr: 12,
- Float: 13.1,
Float32: 14.1,
Float64: 15.1,
Foo: "foo",
@@ -312,7 +309,7 @@ var allValue = All{
ByteSlice: []byte{27, 28, 29},
Small: Small{Tag: "tag30"},
PSmall: &Small{Tag: "tag31"},
- Interface: float64(5.2),
+ Interface: 5.2,
}
var pallValue = All{
@@ -328,7 +325,6 @@ var pallValue = All{
PUint32: &allValue.Uint32,
PUint64: &allValue.Uint64,
PUintptr: &allValue.Uintptr,
- PFloat: &allValue.Float,
PFloat32: &allValue.Float32,
PFloat64: &allValue.Float64,
PString: &allValue.String,
@@ -353,7 +349,6 @@ var allValueIndent = `{
"Uint32": 10,
"Uint64": 11,
"Uintptr": 12,
- "Float": 13.1,
"Float32": 14.1,
"Float64": 15.1,
"bar": "foo",
@@ -369,7 +364,6 @@ var allValueIndent = `{
"PUint32": null,
"PUint64": null,
"PUintptr": null,
- "PFloat": null,
"PFloat32": null,
"PFloat64": null,
"String": "16",
@@ -449,7 +443,6 @@ var pallValueIndent = `{
"Uint32": 0,
"Uint64": 0,
"Uintptr": 0,
- "Float": 0,
"Float32": 0,
"Float64": 0,
"bar": "",
@@ -465,7 +458,6 @@ var pallValueIndent = `{
"PUint32": 10,
"PUint64": 11,
"PUintptr": 12,
- "PFloat": 13.1,
"PFloat32": 14.1,
"PFloat64": 15.1,
"String": "",
diff --git a/src/pkg/json/scanner.go b/src/pkg/json/scanner.go
index 112c8f9c3..e98ddef5c 100644
--- a/src/pkg/json/scanner.go
+++ b/src/pkg/json/scanner.go
@@ -416,7 +416,7 @@ func state0(s *scanner, c int) int {
s.step = stateDot
return scanContinue
}
- if c == 'e' {
+ if c == 'e' || c == 'E' {
s.step = stateE
return scanContinue
}
@@ -440,7 +440,7 @@ func stateDot0(s *scanner, c int) int {
s.step = stateDot0
return scanContinue
}
- if c == 'e' {
+ if c == 'e' || c == 'E' {
s.step = stateE
return scanContinue
}
diff --git a/src/pkg/json/stream_test.go b/src/pkg/json/stream_test.go
index c83cfe3a9..6ddaed9fe 100644
--- a/src/pkg/json/stream_test.go
+++ b/src/pkg/json/stream_test.go
@@ -13,14 +13,14 @@ import (
// Test values for the stream test.
// One of each JSON kind.
var streamTest = []interface{}{
- float64(0.1),
+ 0.1,
"hello",
nil,
true,
false,
[]interface{}{"a", "b", "c"},
map[string]interface{}{"K": "Kelvin", "ß": "long s"},
- float64(3.14), // another value to make sure something can follow map
+ 3.14, // another value to make sure something can follow map
}
var streamEncoded = `0.1