From 48038ffbea17e3fb98017178d0ed36507bba206a Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Wed, 1 Aug 2018 07:40:16 +1000 Subject: [PATCH] fix(match-float): differentiate float vs int in dsl.Match. Fixes #93 --- dsl/matcher.go | 5 +++-- dsl/matcher_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dsl/matcher.go b/dsl/matcher.go index 563816177..4669f85f0 100644 --- a/dsl/matcher.go +++ b/dsl/matcher.go @@ -251,9 +251,10 @@ func match(srcType reflect.Type, params params) Matcher { case reflect.Bool: return Like(true) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Float32, reflect.Float64: + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return Like(1) + case reflect.Float32, reflect.Float64: + return Like(1.1) default: panic(fmt.Sprintf("match: unhandled type: %v", srcType)) } diff --git a/dsl/matcher_test.go b/dsl/matcher_test.go index d0811310f..a66426f70 100644 --- a/dsl/matcher_test.go +++ b/dsl/matcher_test.go @@ -684,14 +684,14 @@ func TestMatch(t *testing.T) { args: args{ src: float32(1), }, - want: Like(1), + want: Like(1.1), }, { name: "base case - float64", args: args{ src: float64(1), }, - want: Like(1), + want: Like(1.1), }, { name: "error - unhandled type",