~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/go/parser/error_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
const testdata = "testdata"
36
36
 
 
37
var fsetErrs *token.FileSet
 
38
 
37
39
// getFile assumes that each filename occurs at most once
38
40
func getFile(filename string) (file *token.File) {
39
 
        fset.Iterate(func(f *token.File) bool {
 
41
        fsetErrs.Iterate(func(f *token.File) bool {
40
42
                if f.Name() == filename {
41
43
                        if file != nil {
42
44
                                panic(filename + " used multiple times")
87
89
                        prev = pos
88
90
                }
89
91
        }
90
 
 
91
 
        panic("unreachable")
92
92
}
93
93
 
94
94
// compareErrors compares the map of expected error messages with the list
125
125
        if len(expected) > 0 {
126
126
                t.Errorf("%d errors not reported:", len(expected))
127
127
                for pos, msg := range expected {
128
 
                        t.Errorf("%s: %s\n", fset.Position(pos), msg)
 
128
                        t.Errorf("%s: %s\n", fsetErrs.Position(pos), msg)
129
129
                }
130
130
        }
131
131
}
137
137
                return
138
138
        }
139
139
 
140
 
        _, err = ParseFile(fset, filename, src, DeclarationErrors)
 
140
        _, err = ParseFile(fsetErrs, filename, src, DeclarationErrors|AllErrors)
141
141
        found, ok := err.(scanner.ErrorList)
142
142
        if err != nil && !ok {
143
143
                t.Error(err)
144
144
                return
145
145
        }
 
146
        found.RemoveMultiples()
146
147
 
147
148
        // we are expecting the following errors
148
149
        // (collect these after parsing a file so that it is found in the file set)
153
154
}
154
155
 
155
156
func TestErrors(t *testing.T) {
 
157
        fsetErrs = token.NewFileSet()
156
158
        list, err := ioutil.ReadDir(testdata)
157
159
        if err != nil {
158
160
                t.Fatal(err)