mirror of
https://github.com/golang/go.git
synced 2025-05-18 05:44:35 +00:00
Run the tests for the testing package. Fix them so that they
work. R=rsc DELTA=16 (1 added, 1 deleted, 14 changed) OCL=34012 CL=34038
This commit is contained in:
parent
b291fc31fc
commit
221d0567e3
@ -122,6 +122,7 @@ TEST=\
|
|||||||
sync\
|
sync\
|
||||||
tabwriter\
|
tabwriter\
|
||||||
template\
|
template\
|
||||||
|
testing\
|
||||||
time\
|
time\
|
||||||
unicode\
|
unicode\
|
||||||
utf8\
|
utf8\
|
||||||
|
@ -6,7 +6,6 @@ package testing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings";
|
"strings";
|
||||||
"testing";
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var good_re = []string{
|
var good_re = []string{
|
||||||
@ -86,7 +85,7 @@ var matches = []tester {
|
|||||||
tester{ `a*(|(b))c*`, "aacc", vec{0,4, 2,2, -1,-1} },
|
tester{ `a*(|(b))c*`, "aacc", vec{0,4, 2,2, -1,-1} },
|
||||||
}
|
}
|
||||||
|
|
||||||
func compileTest(t *testing.T, expr string, error string) *Regexp {
|
func compileTest(t *T, expr string, error string) *Regexp {
|
||||||
re, err := CompileRegexp(expr);
|
re, err := CompileRegexp(expr);
|
||||||
if err != error {
|
if err != error {
|
||||||
t.Error("compiling `", expr, "`; unexpected error: ", err);
|
t.Error("compiling `", expr, "`; unexpected error: ", err);
|
||||||
@ -94,7 +93,7 @@ func compileTest(t *testing.T, expr string, error string) *Regexp {
|
|||||||
return re
|
return re
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVec(t *testing.T, m []int) {
|
func printVec(t *T, m []int) {
|
||||||
l := len(m);
|
l := len(m);
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
t.Log("\t<no match>");
|
t.Log("\t<no match>");
|
||||||
@ -105,7 +104,7 @@ func printVec(t *testing.T, m []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printStrings(t *testing.T, m []string) {
|
func printStrings(t *T, m []string) {
|
||||||
l := len(m);
|
l := len(m);
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
t.Log("\t<no match>");
|
t.Log("\t<no match>");
|
||||||
@ -116,7 +115,7 @@ func printStrings(t *testing.T, m []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printBytes(t *testing.T, b [][]byte) {
|
func printBytes(t *T, b [][]byte) {
|
||||||
l := len(b);
|
l := len(b);
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
t.Log("\t<no match>");
|
t.Log("\t<no match>");
|
||||||
@ -166,7 +165,7 @@ func equalBytes(m1 [][]byte, m2 []string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeTest(t *testing.T, expr string, str string, match []int) {
|
func executeTest(t *T, expr string, str string, match []int) {
|
||||||
re := compileTest(t, expr, "");
|
re := compileTest(t, expr, "");
|
||||||
if re == nil {
|
if re == nil {
|
||||||
return
|
return
|
||||||
@ -188,26 +187,26 @@ func executeTest(t *testing.T, expr string, str string, match []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGoodCompile(t *testing.T) {
|
func TestGoodCompile(t *T) {
|
||||||
for i := 0; i < len(good_re); i++ {
|
for i := 0; i < len(good_re); i++ {
|
||||||
compileTest(t, good_re[i], "");
|
compileTest(t, good_re[i], "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBadCompile(t *testing.T) {
|
func TestBadCompile(t *T) {
|
||||||
for i := 0; i < len(bad_re); i++ {
|
for i := 0; i < len(bad_re); i++ {
|
||||||
compileTest(t, bad_re[i].re, bad_re[i].err)
|
compileTest(t, bad_re[i].re, bad_re[i].err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecute(t *testing.T) {
|
func TestExecute(t *T) {
|
||||||
for i := 0; i < len(matches); i++ {
|
for i := 0; i < len(matches); i++ {
|
||||||
test := &matches[i];
|
test := &matches[i];
|
||||||
executeTest(t, test.re, test.text, test.match)
|
executeTest(t, test.re, test.text, test.match)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchTest(t *testing.T, expr string, str string, match []int) {
|
func matchTest(t *T, expr string, str string, match []int) {
|
||||||
re := compileTest(t, expr, "");
|
re := compileTest(t, expr, "");
|
||||||
if re == nil {
|
if re == nil {
|
||||||
return
|
return
|
||||||
@ -223,14 +222,14 @@ func matchTest(t *testing.T, expr string, str string, match []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMatch(t *testing.T) {
|
func TestMatch(t *T) {
|
||||||
for i := 0; i < len(matches); i++ {
|
for i := 0; i < len(matches); i++ {
|
||||||
test := &matches[i];
|
test := &matches[i];
|
||||||
matchTest(t, test.re, test.text, test.match)
|
matchTest(t, test.re, test.text, test.match)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchStringsTest(t *testing.T, expr string, str string, match []int) {
|
func matchStringsTest(t *T, expr string, str string, match []int) {
|
||||||
re := compileTest(t, expr, "");
|
re := compileTest(t, expr, "");
|
||||||
if re == nil {
|
if re == nil {
|
||||||
return
|
return
|
||||||
@ -256,14 +255,14 @@ func matchStringsTest(t *testing.T, expr string, str string, match []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMatchStrings(t *testing.T) {
|
func TestMatchStrings(t *T) {
|
||||||
for i := 0; i < len(matches); i++ {
|
for i := 0; i < len(matches); i++ {
|
||||||
test := &matches[i];
|
test := &matches[i];
|
||||||
matchTest(t, test.re, test.text, test.match)
|
matchTest(t, test.re, test.text, test.match)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchFunctionTest(t *testing.T, expr string, str string, match []int) {
|
func matchFunctionTest(t *T, expr string, str string, match []int) {
|
||||||
m, err := MatchString(expr, str);
|
m, err := MatchString(expr, str);
|
||||||
if err == "" {
|
if err == "" {
|
||||||
return
|
return
|
||||||
@ -273,7 +272,7 @@ func matchFunctionTest(t *testing.T, expr string, str string, match []int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMatchFunction(t *testing.T) {
|
func TestMatchFunction(t *T) {
|
||||||
for i := 0; i < len(matches); i++ {
|
for i := 0; i < len(matches); i++ {
|
||||||
test := &matches[i];
|
test := &matches[i];
|
||||||
matchFunctionTest(t, test.re, test.text, test.match)
|
matchFunctionTest(t, test.re, test.text, test.match)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user