restructured some test files
This commit is contained in:
@@ -33,13 +33,24 @@ func TestFuncOs(t *testing.T) {
|
|||||||
/* 19 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); string(it)`, `$(fileLineIterator@"test-file.txt")`, nil},
|
/* 19 */ {`builtin "os.file"; it=fileLineIterator("test-file.txt"); string(it)`, `$(fileLineIterator@"test-file.txt")`, nil},
|
||||||
/* 20 */ {`builtin "os.file"; handle=fileOpen("/etc/hosts"); fileClose(handle); string(handle)`, `reader`, nil},
|
/* 20 */ {`builtin "os.file"; handle=fileOpen("/etc/hosts"); fileClose(handle); string(handle)`, `reader`, nil},
|
||||||
/* 21 */ {`builtin "os.file"; handle=fileCreate("/tmp/dummy"); fileClose(handle); string(handle)`, `writer`, nil},
|
/* 21 */ {`builtin "os.file"; handle=fileCreate("/tmp/dummy"); fileClose(handle); string(handle)`, `writer`, nil},
|
||||||
/* 22 */ {`builtin "os.file"; it=fileByteIterator("test-file.txt"); string(it)`, `$(fileByteIterator@"test-file.txt")`, nil},
|
|
||||||
/* 23 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); char(it++)`, `u`, nil},
|
|
||||||
/* 24 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); it++; it.reset; char(it++)`, `u`, nil},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.Setenv("EXPR_PATH", ".")
|
// t.Setenv("EXPR_PATH", ".")
|
||||||
|
|
||||||
runTestSuiteSpec(t, section, inputs, 24)
|
// runTestSuiteSpec(t, section, inputs, 24)
|
||||||
// runTestSuite(t, section, inputs)
|
runTestSuite(t, section, inputs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFuncOsByteIter(t *testing.T) {
|
||||||
|
section := "Builtin-OS-File-Byte-Iter"
|
||||||
|
inputs := []inputType{
|
||||||
|
/* 1 */ {`builtin "os.file"; it=fileByteIterator("test-file.txt"); string(it)`, `$(fileByteIterator@"test-file.txt")`, nil},
|
||||||
|
/* 2 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); char(it++)`, `u`, nil},
|
||||||
|
/* 3 */ {`builtin ["os.file", "string"]; it=fileByteIterator("test-file.txt"); it++; it.reset; char(it++)`, `u`, nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
// t.Setenv("EXPR_PATH", ".")
|
||||||
|
|
||||||
|
// runTestSuiteSpec(t, section, inputs, 24)
|
||||||
|
runTestSuite(t, section, inputs)
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -23,13 +23,19 @@ func runCtxTestSuiteSpec(t *testing.T, ctx kern.ExprContext, section string, inp
|
|||||||
succeeded := 0
|
succeeded := 0
|
||||||
failed := 0
|
failed := 0
|
||||||
for _, count := range spec {
|
for _, count := range spec {
|
||||||
good := doTest(t, ctx, section, &inputs[count-1], count)
|
index := count - 1
|
||||||
|
if index >= 0 && index < len(inputs) {
|
||||||
|
good := doTest(t, ctx, section, &inputs[index], count)
|
||||||
|
|
||||||
if good {
|
if good {
|
||||||
succeeded++
|
succeeded++
|
||||||
} else {
|
} else {
|
||||||
failed++
|
failed++
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
t.Errorf("%s -- test count: %d, invalid index", section, count)
|
||||||
|
failed++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t.Logf("%s -- test count: %d, succeeded: %d, failed: %d", section, len(spec), succeeded, failed)
|
t.Logf("%s -- test count: %d, succeeded: %d, failed: %d", section, len(spec), succeeded, failed)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -11,16 +11,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestIterIterator(t *testing.T) {
|
func TestIterIterator(t *testing.T) {
|
||||||
section := "Iterator"
|
section := "Iter-Iter"
|
||||||
inputs := []inputType{
|
inputs := []inputType{
|
||||||
/* 1 */ {`it=$(4); $(it) filter ${_}==100`, kern.NewListA(), nil},
|
/* 1 */ {`it=$(4); $$($(it) filter ${_}==100)`, kern.NewListA(), nil},
|
||||||
/* 2 */ {`it=$(4); $(it, $_) filter ${_}==100`, kern.NewListA(), nil},
|
/* 2 */ {`it=$(4); $$($(it, $_) filter ${_}==100)`, kern.NewListA(), nil},
|
||||||
/* 3 */ {`it=$(4); $(it, 10+$_, last-1) digest ${_}`, int64(12), nil},
|
/* 3 */ {`it=$(4); $(it, 10+$_, last-1) digest ${_}`, int64(12), nil},
|
||||||
/* 4 */ {`f=func(n){last-n}; it=$(4); $(it, 10+$_, f(-1)) digest ${_}`, int64(14), nil},
|
/* 4 */ {`f=func(n){last-n}; it=$(4); $(it, 10+$_, f(-1)) digest ${_}`, int64(14), nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestSuiteSpec(t, section, inputs, 4)
|
// runTestSuiteSpec(t, section, inputs, 4)
|
||||||
// runTestSuite(t, section, inputs)
|
runTestSuite(t, section, inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func TestNewIterIterator(t *testing.T) {
|
// func TestNewIterIterator(t *testing.T) {
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ func TestIteratorParser(t *testing.T) {
|
|||||||
/* 22 */ {`it=$({1:"one",2:"two",3:"three"}, "asc", "item"); it++`, kern.NewList([]any{int64(1), "one"}), nil},
|
/* 22 */ {`it=$({1:"one",2:"two",3:"three"}, "asc", "item"); it++`, kern.NewList([]any{int64(1), "one"}), nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
// runTestSuiteSpec(t, section, inputs, 10)
|
// runTestSuiteSpec(t, section, inputs, 1)
|
||||||
runTestSuite(t, section, inputs)
|
runTestSuite(t, section, inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -80,6 +80,6 @@ func TestOperatorGroupBy(t *testing.T) {
|
|||||||
nil},
|
nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestSuiteSpec(t, section, inputs, 3)
|
// runTestSuiteSpec(t, section, inputs, 3)
|
||||||
// runTestSuite(t, section, inputs)
|
runTestSuite(t, section, inputs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user