LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 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 // This file implements a simple typechecker test harness. Packages found | 5 // This file implements a simple typechecker test harness. Packages found |
6 // in the testDir directory are typechecked. Error messages reported by | 6 // in the testDir directory are typechecked. Error messages reported by |
7 // the typechecker are compared against the error messages expected for | 7 // the typechecker are compared against the error messages expected for |
8 // the test files. | 8 // the test files. |
9 // | 9 // |
10 // Expected errors are indicated in the test files by putting a comment | 10 // Expected errors are indicated in the test files by putting a comment |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 file := fset.AddFile(filename, fset.Base(), len(src)) | 71 file := fset.AddFile(filename, fset.Base(), len(src)) |
72 s.Init(file, src, nil, scanner.ScanComments) | 72 s.Init(file, src, nil, scanner.ScanComments) |
73 var prev token.Pos // position of last non-comment token | 73 var prev token.Pos // position of last non-comment token |
74 loop: | 74 loop: |
75 for { | 75 for { |
76 pos, tok, lit := s.Scan() | 76 pos, tok, lit := s.Scan() |
77 switch tok { | 77 switch tok { |
78 case token.EOF: | 78 case token.EOF: |
79 break loop | 79 break loop |
80 case token.COMMENT: | 80 case token.COMMENT: |
81 » » » » s := errRx.FindSubmatch(lit) | 81 » » » » s := errRx.FindStringSubmatch(lit) |
82 if len(s) == 2 { | 82 if len(s) == 2 { |
83 list = append(list, &scanner.Error{fset.
Position(prev), string(s[1])}) | 83 list = append(list, &scanner.Error{fset.
Position(prev), string(s[1])}) |
84 } | 84 } |
85 default: | 85 default: |
86 prev = pos | 86 prev = pos |
87 } | 87 } |
88 } | 88 } |
89 } | 89 } |
90 sort.Sort(list) // multiple files may not be sorted | 90 sort.Sort(list) // multiple files may not be sorted |
91 return | 91 return |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 t.Errorf("TypeCheck(%s): %d errors expec
ted but %d reported", pkg.Name, len(xlist), len(elist)) | 159 t.Errorf("TypeCheck(%s): %d errors expec
ted but %d reported", pkg.Name, len(xlist), len(elist)) |
160 } | 160 } |
161 } else { | 161 } else { |
162 t.Errorf("TypeCheck(%s): %v", pkg.Name, err) | 162 t.Errorf("TypeCheck(%s): %v", pkg.Name, err) |
163 } | 163 } |
164 } else if len(xlist) > 0 { | 164 } else if len(xlist) > 0 { |
165 t.Errorf("TypeCheck(%s): %d errors expected but 0 report
ed", pkg.Name, len(xlist)) | 165 t.Errorf("TypeCheck(%s): %d errors expected but 0 report
ed", pkg.Name, len(xlist)) |
166 } | 166 } |
167 } | 167 } |
168 } | 168 } |
LEFT | RIGHT |