mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
* Static-check fixes from @lespea #1657, batch 2/n * Static-check fixes from @lespea #1657, batch 3/n * Static-check fixes from @lespea #1657, batch 4/n * Static-check fixes from @lespea #1657, batch 5/n
This commit is contained in:
parent
8c791f5466
commit
02bd5344b9
5 changed files with 34 additions and 25 deletions
|
|
@ -495,6 +495,9 @@ func (root *RootNode) BuildUDF(
|
|||
"function return value",
|
||||
returnValueTypeName,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lib.InternalCodingErrorIf(parameterListASTNode.Type != dsl.NodeTypeParameterList)
|
||||
lib.InternalCodingErrorIf(parameterListASTNode.Children == nil)
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ func (reader *PseudoReaderGen) process(
|
|||
|
||||
if recordsAndContexts.Len() > 0 {
|
||||
readerChannel <- recordsAndContexts
|
||||
recordsAndContexts = list.New()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ import (
|
|||
|
||||
func OpenOutboundHalfPipe(commandString string) (*os.File, error) {
|
||||
readPipe, writePipe, err := os.Pipe()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var procAttr os.ProcAttr
|
||||
procAttr.Files = []*os.File{
|
||||
|
|
@ -56,6 +59,9 @@ func OpenOutboundHalfPipe(commandString string) (*os.File, error) {
|
|||
|
||||
func OpenInboundHalfPipe(commandString string) (*os.File, error) {
|
||||
readPipe, writePipe, err := os.Pipe()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var procAttr os.ProcAttr
|
||||
procAttr.Files = []*os.File{
|
||||
|
|
|
|||
|
|
@ -12,23 +12,23 @@ import (
|
|||
|
||||
func TestGetString(t *testing.T) {
|
||||
mv := FromInferredType("234")
|
||||
stringval, ok := mv.GetStringValue()
|
||||
_, ok := mv.GetStringValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("234")
|
||||
stringval, ok = mv.GetStringValue()
|
||||
_, ok = mv.GetStringValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("234.5")
|
||||
stringval, ok = mv.GetStringValue()
|
||||
_, ok = mv.GetStringValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("234.5")
|
||||
stringval, ok = mv.GetStringValue()
|
||||
_, ok = mv.GetStringValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("abc")
|
||||
stringval, ok = mv.GetStringValue()
|
||||
stringval, ok := mv.GetStringValue()
|
||||
assert.Equal(t, "abc", stringval)
|
||||
assert.True(t, ok)
|
||||
|
||||
|
|
@ -60,33 +60,33 @@ func TestGetIntValue(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
|
||||
mv = FromInferredType("123.4")
|
||||
intval, ok = mv.GetIntValue()
|
||||
_, ok = mv.GetIntValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("123.4")
|
||||
intval, ok = mv.GetIntValue()
|
||||
_, ok = mv.GetIntValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("abc")
|
||||
intval, ok = mv.GetIntValue()
|
||||
_, ok = mv.GetIntValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("abc")
|
||||
intval, ok = mv.GetIntValue()
|
||||
_, ok = mv.GetIntValue()
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
func TestGetFloatValue(t *testing.T) {
|
||||
mv := FromInferredType("234")
|
||||
floatval, ok := mv.GetFloatValue()
|
||||
_, ok := mv.GetFloatValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("234")
|
||||
floatval, ok = mv.GetFloatValue()
|
||||
_, ok = mv.GetFloatValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("234.5")
|
||||
floatval, ok = mv.GetFloatValue()
|
||||
floatval, ok := mv.GetFloatValue()
|
||||
assert.Equal(t, 234.5, floatval)
|
||||
assert.True(t, ok)
|
||||
|
||||
|
|
@ -96,11 +96,11 @@ func TestGetFloatValue(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
|
||||
mv = FromInferredType("abc")
|
||||
floatval, ok = mv.GetFloatValue()
|
||||
_, ok = mv.GetFloatValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("abc")
|
||||
floatval, ok = mv.GetFloatValue()
|
||||
_, ok = mv.GetFloatValue()
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
|
|
@ -126,38 +126,38 @@ func TestGetNumericToFloatValue(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
|
||||
mv = FromInferredType("abc")
|
||||
floatval, ok = mv.GetNumericToFloatValue()
|
||||
_, ok = mv.GetNumericToFloatValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("abc")
|
||||
floatval, ok = mv.GetNumericToFloatValue()
|
||||
_, ok = mv.GetNumericToFloatValue()
|
||||
assert.False(t, ok)
|
||||
}
|
||||
|
||||
func TestGetBoolValue(t *testing.T) {
|
||||
mv := FromInferredType("234")
|
||||
boolval, ok := mv.GetBoolValue()
|
||||
_, ok := mv.GetBoolValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("234")
|
||||
boolval, ok = mv.GetBoolValue()
|
||||
_, ok = mv.GetBoolValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("abc")
|
||||
boolval, ok = mv.GetBoolValue()
|
||||
_, ok = mv.GetBoolValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromDeferredType("abc")
|
||||
boolval, ok = mv.GetBoolValue()
|
||||
_, ok = mv.GetBoolValue()
|
||||
assert.False(t, ok)
|
||||
|
||||
mv = FromInferredType("true")
|
||||
boolval, ok = mv.GetBoolValue()
|
||||
boolval, ok := mv.GetBoolValue()
|
||||
assert.True(t, boolval)
|
||||
assert.True(t, ok)
|
||||
|
||||
mv = FromDeferredType("false")
|
||||
boolval, ok = mv.GetBoolValue()
|
||||
_, ok = mv.GetBoolValue()
|
||||
assert.False(t, ok, "from-data-file \"false\" should infer to string")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,9 @@ func MlrvalDecodeFromJSON(decoder *json.Decoder) (
|
|||
)
|
||||
}
|
||||
|
||||
mv := FromPending()
|
||||
// Will be assigned as an array or a map
|
||||
var mv *Mlrval
|
||||
|
||||
if isArray {
|
||||
mv = FromEmptyArray()
|
||||
|
||||
|
|
@ -203,7 +205,6 @@ func MlrvalDecodeFromJSON(decoder *json.Decoder) (
|
|||
}
|
||||
mv.ArrayAppend(element)
|
||||
}
|
||||
|
||||
} else {
|
||||
mv = FromEmptyMap()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue