Result.Bool() can parse 'false' as false

This commit is contained in:
Hexilee 2018-02-23 20:25:48 +08:00
parent aff9dcea3c
commit 9fa9086994
2 changed files with 2 additions and 2 deletions

View File

@ -96,7 +96,7 @@ func (t Result) Bool() bool {
case True:
return true
case String:
return t.Str != "" && t.Str != "0"
return t.Str != "" && t.Str != "0" && t.Str != "false"
case Number:
return t.Num != 0
}

View File

@ -148,7 +148,7 @@ func TestTimeResult(t *testing.T) {
func TestParseAny(t *testing.T) {
assert(t, Parse("100").Float() == 100)
assert(t, Parse("true").Bool())
assert(t, Parse("valse").Bool() == false)
assert(t, Parse("false").Bool() == false)
}
func TestManyVariousPathCounts(t *testing.T) {