Skip to content

Commit 179c3f1

Browse files
authored
Merge pull request syyongx#6 from dreamans/master
fix fn "IsNumeric" can not judge whether it is an int
2 parents fc0f3ee + 0f9cad6 commit 179c3f1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

php.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,7 @@ func Empty(val interface{}) bool {
16211621
func IsNumeric(val interface{}) bool {
16221622
switch val.(type) {
16231623
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
1624+
return true
16241625
case float32, float64, complex64, complex128:
16251626
return true
16261627
case string:

php_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,12 @@ func TestVariable(t *testing.T) {
294294
equal(t, false, Empty([1]string{}))
295295
equal(t, true, Empty([]int{}))
296296

297-
tIsNumeric := IsNumeric("-0xaF")
297+
var tIsNumeric bool
298+
299+
tIsNumeric = IsNumeric("-0xaF")
300+
equal(t, true, tIsNumeric)
301+
302+
tIsNumeric = IsNumeric("123456")
298303
equal(t, true, tIsNumeric)
299304
}
300305

0 commit comments

Comments
 (0)