~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/pkg/go/ast/ast_test.go

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý, Ondřej Surý, Michael Stapelberg
  • Date: 2012-06-28 12:14:15 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20120628121415-w1b0076ixkarr1ml
[ Ondřej Surý ]
* Imported Upstream version 1.0.2
* Update Vcs fields to reflect new git repository location
* Kill get-orig-source, since 1.0.0, the tarballs can be downloaded
  from webpage

[ Michael Stapelberg ]
* golang-mode: use debian-pkg-add-load-path-item (Closes: #664802)
* Add manpages (Closes: #632964)
* Use updated pt.po from Pedro Ribeiro (Closes: #674958)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2012 The Go Authors. All rights reserved.
 
2
// Use of this source code is governed by a BSD-style
 
3
// license that can be found in the LICENSE file.
 
4
 
 
5
package ast
 
6
 
 
7
import (
 
8
        "testing"
 
9
)
 
10
 
 
11
var comments = []struct {
 
12
        list []string
 
13
        text string
 
14
}{
 
15
        {[]string{"//"}, ""},
 
16
        {[]string{"//   "}, ""},
 
17
        {[]string{"//", "//", "//   "}, ""},
 
18
        {[]string{"// foo   "}, "foo\n"},
 
19
        {[]string{"//", "//", "// foo"}, "foo\n"},
 
20
        {[]string{"// foo  bar  "}, "foo  bar\n"},
 
21
        {[]string{"// foo", "// bar"}, "foo\nbar\n"},
 
22
        {[]string{"// foo", "//", "//", "//", "// bar"}, "foo\n\nbar\n"},
 
23
        {[]string{"// foo", "/* bar */"}, "foo\n bar\n"},
 
24
        {[]string{"//", "//", "//", "// foo", "//", "//", "//"}, "foo\n"},
 
25
 
 
26
        {[]string{"/**/"}, ""},
 
27
        {[]string{"/*   */"}, ""},
 
28
        {[]string{"/**/", "/**/", "/*   */"}, ""},
 
29
        {[]string{"/* Foo   */"}, " Foo\n"},
 
30
        {[]string{"/* Foo  Bar  */"}, " Foo  Bar\n"},
 
31
        {[]string{"/* Foo*/", "/* Bar*/"}, " Foo\n Bar\n"},
 
32
        {[]string{"/* Foo*/", "/**/", "/**/", "/**/", "// Bar"}, " Foo\n\nBar\n"},
 
33
        {[]string{"/* Foo*/", "/*\n*/", "//", "/*\n*/", "// Bar"}, " Foo\n\nBar\n"},
 
34
        {[]string{"/* Foo*/", "// Bar"}, " Foo\nBar\n"},
 
35
        {[]string{"/* Foo\n Bar*/"}, " Foo\n Bar\n"},
 
36
}
 
37
 
 
38
func TestCommentText(t *testing.T) {
 
39
        for i, c := range comments {
 
40
                list := make([]*Comment, len(c.list))
 
41
                for i, s := range c.list {
 
42
                        list[i] = &Comment{Text: s}
 
43
                }
 
44
 
 
45
                text := (&CommentGroup{list}).Text()
 
46
                if text != c.text {
 
47
                        t.Errorf("case %d: got %q; expected %q", i, text, c.text)
 
48
                }
 
49
        }
 
50
}