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

Side by Side Diff: src/pkg/exp/eval/eval_test.go

Issue 3050041: code review 3050041: go/ast: use token.Pos instead of token.Position; adjus... (Closed)
Patch Set: code review 3050041: go/ast: use token.Pos instead of token.Position; adjus... Created 14 years, 3 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/exp/eval/compiler.go ('k') | src/pkg/exp/eval/expr.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 eval 5 package eval
6 6
7 import ( 7 import (
8 "big" 8 "big"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "go/token"
11 "log" 12 "log"
12 "os" 13 "os"
13 "reflect" 14 "reflect"
14 "regexp" 15 "regexp"
15 "testing" 16 "testing"
16 ) 17 )
17 18
19 // All tests are done using the same file set.
20 var fset = token.NewFileSet()
21
18 // Print each statement or expression before parsing it 22 // Print each statement or expression before parsing it
19 var noisy = false 23 var noisy = false
20 24
21 func init() { flag.BoolVar(&noisy, "noisy", false, "chatter during eval tests") } 25 func init() { flag.BoolVar(&noisy, "noisy", false, "chatter during eval tests") }
22 26
23 /* 27 /*
24 * Generic statement/expression test framework 28 * Generic statement/expression test framework
25 */ 29 */
26 30
27 type test []job 31 type test []job
(...skipping 14 matching lines...) Expand all
42 } 46 }
43 47
44 func (a test) run(t *testing.T, name string) { 48 func (a test) run(t *testing.T, name string) {
45 w := newTestWorld() 49 w := newTestWorld()
46 for _, j := range a { 50 for _, j := range a {
47 src := j.code + ";" // trailing semicolon to finish statement 51 src := j.code + ";" // trailing semicolon to finish statement
48 if noisy { 52 if noisy {
49 println("code:", src) 53 println("code:", src)
50 } 54 }
51 55
52 » » code, err := w.Compile(src) 56 » » code, err := w.Compile(fset, src)
53 if err != nil { 57 if err != nil {
54 if j.cerr == "" { 58 if j.cerr == "" {
55 t.Errorf("%s: Compile %s: %v", name, src, err) 59 t.Errorf("%s: Compile %s: %v", name, src, err)
56 break 60 break
57 } 61 }
58 if !match(t, err, j.cerr) { 62 if !match(t, err, j.cerr) {
59 t.Errorf("%s: Compile %s = error %s; want %v", n ame, src, err, j.cerr) 63 t.Errorf("%s: Compile %s = error %s; want %v", n ame, src, err, j.cerr)
60 break 64 break
61 } 65 }
62 continue 66 continue
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 def("ai", NewArrayType(2, IntType), varray{1, 2}) 250 def("ai", NewArrayType(2, IntType), varray{1, 2})
247 def("aai", NewArrayType(2, NewArrayType(2, IntType)), varray{varray{1, 2 }, varray{3, 4}}) 251 def("aai", NewArrayType(2, NewArrayType(2, IntType)), varray{varray{1, 2 }, varray{3, 4}})
248 def("aai2", NewArrayType(2, NewArrayType(2, IntType)), varray{varray{5, 6}, varray{7, 8}}) 252 def("aai2", NewArrayType(2, NewArrayType(2, IntType)), varray{varray{5, 6}, varray{7, 8}})
249 def("fn", NewFuncType([]Type{IntType}, false, []Type{IntType}), &testFun c{}) 253 def("fn", NewFuncType([]Type{IntType}, false, []Type{IntType}), &testFun c{})
250 def("oneTwo", NewFuncType([]Type{}, false, []Type{IntType, IntType}), &o neTwoFunc{}) 254 def("oneTwo", NewFuncType([]Type{}, false, []Type{IntType, IntType}), &o neTwoFunc{})
251 def("void", NewFuncType([]Type{}, false, []Type{}), &voidFunc{}) 255 def("void", NewFuncType([]Type{}, false, []Type{}), &voidFunc{})
252 def("sli", NewSliceType(IntType), vslice{varray{1, 2, 3}, 2, 3}) 256 def("sli", NewSliceType(IntType), vslice{varray{1, 2, 3}, 2, 3})
253 257
254 return w 258 return w
255 } 259 }
OLDNEW
« no previous file with comments | « src/pkg/exp/eval/compiler.go ('k') | src/pkg/exp/eval/expr.go » ('j') | no next file with comments »

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