Merge pull request #66 from Hexilee/master

Result.Bool() can parse 'false' as false
This commit is contained in:
Josh Baker 2018-02-23 08:48:56 -07:00 committed by GitHub
commit 01f00f1296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

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

View File

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