diff options
Diffstat (limited to 'libgo/go/exp/datafmt/datafmt_test.go')
-rw-r--r-- | libgo/go/exp/datafmt/datafmt_test.go | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/libgo/go/exp/datafmt/datafmt_test.go b/libgo/go/exp/datafmt/datafmt_test.go index d7c70b2..87d0716 100644 --- a/libgo/go/exp/datafmt/datafmt_test.go +++ b/libgo/go/exp/datafmt/datafmt_test.go @@ -10,10 +10,8 @@ import ( "go/token" ) - var fset = token.NewFileSet() - func parse(t *testing.T, form string, fmap FormatterMap) Format { f, err := Parse(fset, "", []byte(form), fmap) if err != nil { @@ -23,7 +21,6 @@ func parse(t *testing.T, form string, fmap FormatterMap) Format { return f } - func verify(t *testing.T, f Format, expected string, args ...interface{}) { if f == nil { return // allow other tests to run @@ -36,7 +33,6 @@ func verify(t *testing.T, f Format, expected string, args ...interface{}) { } } - func formatter(s *State, value interface{}, rule_name string) bool { switch rule_name { case "/": @@ -62,7 +58,6 @@ func formatter(s *State, value interface{}, rule_name string) bool { return false } - func TestCustomFormatters(t *testing.T) { fmap0 := FormatterMap{"/": formatter} fmap1 := FormatterMap{"int": formatter, "blank": formatter, "nil": formatter} @@ -92,7 +87,6 @@ func TestCustomFormatters(t *testing.T) { // TODO needs more tests } - // ---------------------------------------------------------------------------- // Formatting of basic and simple composite types @@ -109,7 +103,6 @@ func check(t *testing.T, form, expected string, args ...interface{}) { } } - func TestBasicTypes(t *testing.T) { check(t, ``, ``) check(t, `bool=":%v"`, `:true:false`, true, false) @@ -144,7 +137,6 @@ func TestBasicTypes(t *testing.T) { check(t, `float64="%g"`, fs, float64(f)) } - func TestArrayTypes(t *testing.T) { var a0 [10]int check(t, `array="array";`, `array`, a0) @@ -159,7 +151,6 @@ func TestArrayTypes(t *testing.T) { check(t, `array={* / ", "}; interface=*; string="bar"; default="%v";`, `42, bar, 3.14`, a2) } - func TestChanTypes(t *testing.T) { var c0 chan int check(t, `chan="chan"`, `chan`, c0) @@ -170,7 +161,6 @@ func TestChanTypes(t *testing.T) { // check(t, `chan=*`, `42`, c1); // reflection support for chans incomplete } - func TestFuncTypes(t *testing.T) { var f0 func() int check(t, `func="func"`, `func`, f0) @@ -180,7 +170,6 @@ func TestFuncTypes(t *testing.T) { // check(t, `func=*`, `42`, f1); // reflection support for funcs incomplete } - func TestMapTypes(t *testing.T) { var m0 map[string]int check(t, `map="map"`, `map`, m0) @@ -190,7 +179,6 @@ func TestMapTypes(t *testing.T) { // check(t, `map=*`, ``, m1); // reflection support for maps incomplete } - func TestPointerTypes(t *testing.T) { var p0 *int check(t, `ptr="ptr"`, `ptr`, p0) @@ -203,7 +191,6 @@ func TestPointerTypes(t *testing.T) { check(t, `ptr=*; int="%d"`, `99991`, p1) } - func TestDefaultRule(t *testing.T) { check(t, `default="%v"`, `42foo3.14`, 42, "foo", 3.14) check(t, `default="%v"; int="%x"`, `abcdef`, 10, 11, 12, 13, 14, 15) @@ -211,13 +198,11 @@ func TestDefaultRule(t *testing.T) { check(t, `default="%x"; int=@:default`, `abcdef`, 10, 11, 12, 13, 14, 15) } - func TestGlobalSeparatorRule(t *testing.T) { check(t, `int="%d"; / ="-"`, `1-2-3-4`, 1, 2, 3, 4) check(t, `int="%x%x"; / ="*"`, `aa*aa`, 10, 10) } - // ---------------------------------------------------------------------------- // Formatting of a struct @@ -231,7 +216,6 @@ const F1 = `datafmt "datafmt";` + func TestStruct1(t *testing.T) { check(t, F1, "<42>", T1{42}) } - // ---------------------------------------------------------------------------- // Formatting of a struct with an optional field (ptr) @@ -256,7 +240,6 @@ func TestStruct2(t *testing.T) { check(t, F2b, "fooempty", T2{"foo", nil}) } - // ---------------------------------------------------------------------------- // Formatting of a struct with a repetitive field (slice) @@ -285,7 +268,6 @@ func TestStruct3(t *testing.T) { check(t, F3b, "bal: 2-3-5", T3{"bal", []int{2, 3, 5}}) } - // ---------------------------------------------------------------------------- // Formatting of a struct with alternative field @@ -318,7 +300,6 @@ func TestStruct4(t *testing.T) { check(t, F4b, "<2, 3, 7>", T4{nil, []int{2, 3, 7}}) } - // ---------------------------------------------------------------------------- // Formatting a struct (documentation example) @@ -338,7 +319,6 @@ func TestStructPoint(t *testing.T) { check(t, FPoint, "---foo---{3, 0xf}", p) } - // ---------------------------------------------------------------------------- // Formatting a slice (documentation example) @@ -347,5 +327,4 @@ const FSlice = `int = "%b";` + func TestSlice(t *testing.T) { check(t, FSlice, "10, 11, 101, 111", []int{2, 3, 5, 7}) } - // TODO add more tests |