This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from dadleyy/bitwise
bitwise updater apis
- Loading branch information
Showing
9 changed files
with
220 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package marlow | ||
|
||
import "go/types" | ||
import "github.com/dadleyy/marlow/marlow/constants" | ||
|
||
// getTypeInfo returns a types.BasicInfo mask value based on the string provided. | ||
func getTypeInfo(fieldType string) types.BasicInfo { | ||
var typeInfo types.BasicInfo | ||
|
||
for _, t := range constants.NumericCustomTypes { | ||
if t == fieldType { | ||
return types.IsNumeric | ||
} | ||
} | ||
|
||
for _, t := range types.Typ { | ||
n := t.Name() | ||
|
||
if fieldType != n { | ||
continue | ||
} | ||
|
||
typeInfo = t.Info() | ||
} | ||
|
||
return typeInfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package marlow | ||
|
||
import "testing" | ||
import "go/types" | ||
import "github.com/franela/goblin" | ||
|
||
func Test_getTypeInfo(t *testing.T) { | ||
g := goblin.Goblin(t) | ||
|
||
g.Describe("getTypeInfo", func() { | ||
g.It("returns a numeric type for time.Time", func() { | ||
v := getTypeInfo("time.Time") | ||
g.Assert(v & types.IsNumeric).Equal(v) | ||
}) | ||
|
||
g.It("returns a boolean type for bools", func() { | ||
v := getTypeInfo("bool") | ||
g.Assert(v & types.IsBoolean).Equal(v) | ||
}) | ||
|
||
g.It("returns a string type for strings", func() { | ||
v := getTypeInfo("string") | ||
g.Assert(v & types.IsString).Equal(v) | ||
}) | ||
|
||
g.It("returns a numeric type for ints", func() { | ||
v := getTypeInfo("int") | ||
g.Assert(v & types.IsNumeric).Equal(v) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.