Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(477)

Delta Between Two Patch Sets: src/pkg/go/ast/ast_test.go

Issue 6206096: code review 6206096: go/ast: document CommentGroup.Text and add test case. (Closed)
Left Patch Set: diff -r c6213d8a9118 https://code.google.com/p/go Created 12 years, 10 months ago
Right Patch Set: diff -r 2c1cc7b715e6 https://code.google.com/p/go Created 12 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/go/ast/ast.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package ast 5 package ast
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 ) 9 )
10 10
11 var comments = []struct { 11 var comments = []struct {
12 list []string 12 list []string
13 text string 13 text string
14 }{ 14 }{
15 {[]string{"//"}, ""}, 15 {[]string{"//"}, ""},
16 {[]string{"// "}, ""}, 16 {[]string{"// "}, ""},
17 {[]string{"//", "//", "// "}, ""}, 17 {[]string{"//", "//", "// "}, ""},
18 » {[]string{"// foo "}, " foo\n"}, 18 » {[]string{"// foo "}, "foo\n"},
19 » {[]string{"//", "//", "// foo"}, " foo\n"}, 19 » {[]string{"//", "//", "// foo"}, "foo\n"},
20 » {[]string{"// foo bar "}, " foo bar\n"}, 20 » {[]string{"// foo bar "}, "foo bar\n"},
21 » {[]string{"// foo", "// bar"}, " foo\n bar\n"}, 21 » {[]string{"// foo", "// bar"}, "foo\nbar\n"},
22 » {[]string{"// foo", "//", "//", "//", "// bar"}, " foo\n\n bar\n"}, 22 » {[]string{"// foo", "//", "//", "//", "// bar"}, "foo\n\nbar\n"},
23 » {[]string{"// foo", "/* bar */"}, " foo\n bar\n"}, 23 » {[]string{"// foo", "/* bar */"}, "foo\n bar\n"},
24 » {[]string{"//", "//", "//", "// foo", "//", "//", "//"}, " foo\n"}, 24 » {[]string{"//", "//", "//", "// foo", "//", "//", "//"}, "foo\n"},
25 25
26 {[]string{"/**/"}, ""}, 26 {[]string{"/**/"}, ""},
27 {[]string{"/* */"}, ""}, 27 {[]string{"/* */"}, ""},
28 {[]string{"/**/", "/**/", "/* */"}, ""}, 28 {[]string{"/**/", "/**/", "/* */"}, ""},
29 {[]string{"/* Foo */"}, " Foo\n"}, 29 {[]string{"/* Foo */"}, " Foo\n"},
30 {[]string{"/* Foo Bar */"}, " Foo Bar\n"}, 30 {[]string{"/* Foo Bar */"}, " Foo Bar\n"},
31 {[]string{"/* Foo*/", "/* Bar*/"}, " Foo\n Bar\n"}, 31 {[]string{"/* Foo*/", "/* Bar*/"}, " Foo\n Bar\n"},
32 » {[]string{"/* Foo*/", "/**/", "/**/", "/**/", "// Bar"}, " Foo\n\n Bar\n "}, 32 » {[]string{"/* Foo*/", "/**/", "/**/", "/**/", "// Bar"}, " Foo\n\nBar\n" },
33 » {[]string{"/* Foo*/", "/*\n*/", "//", "/*\n*/", "// Bar"}, " Foo\n\n Bar \n"}, 33 » {[]string{"/* Foo*/", "/*\n*/", "//", "/*\n*/", "// Bar"}, " Foo\n\nBar\ n"},
34 » {[]string{"/* Foo*/", "// Bar"}, " Foo\n Bar\n"}, 34 » {[]string{"/* Foo*/", "// Bar"}, " Foo\nBar\n"},
35 {[]string{"/* Foo\n Bar*/"}, " Foo\n Bar\n"}, 35 {[]string{"/* Foo\n Bar*/"}, " Foo\n Bar\n"},
36 } 36 }
37 37
38 func TestCommentText(t *testing.T) { 38 func TestCommentText(t *testing.T) {
39 for i, c := range comments { 39 for i, c := range comments {
40 list := make([]*Comment, len(c.list)) 40 list := make([]*Comment, len(c.list))
41 for i, s := range c.list { 41 for i, s := range c.list {
42 list[i] = &Comment{Text: s} 42 list[i] = &Comment{Text: s}
43 } 43 }
44 44
45 text := (&CommentGroup{list}).Text() 45 text := (&CommentGroup{list}).Text()
46 if text != c.text { 46 if text != c.text {
47 t.Errorf("case %d: got %q; expected %q", i, text, c.text ) 47 t.Errorf("case %d: got %q; expected %q", i, text, c.text )
48 } 48 }
49 } 49 }
50 } 50 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b