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

Side by Side Diff: src/pkg/ebnf/ebnf_test.go

Issue 4119056: code review 4119056: go/printer, gofmt: smarter handling of multi-line raw s... (Closed)
Patch Set: diff -r 204118e30fbd https://go.googlecode.com/hg/ Created 14 years, 1 month 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 | « no previous file | src/pkg/go/printer/printer.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 ebnf 5 package ebnf
6 6
7 import ( 7 import (
8 "go/token" 8 "go/token"
9 "io/ioutil" 9 "io/ioutil"
10 "testing" 10 "testing"
11 ) 11 )
12 12
13 13
14 var fset = token.NewFileSet() 14 var fset = token.NewFileSet()
15 15
16 16
17 var grammars = []string{ 17 var grammars = []string{
18 » `Program = . 18 `Program = .
19 » `, 19 `,
20 20
21 » `Program = foo . 21 `Program = foo .
22 » foo = "foo" . 22 foo = "foo" .
23 » `, 23 `,
24 24
25 » `Program = "a" | "b" "c" . 25 `Program = "a" | "b" "c" .
26 » `, 26 `,
27 27
28 » `Program = "a" ... "z" . 28 `Program = "a" ... "z" .
29 » `, 29 `,
30 30
31 » `Program = Song . 31 `Program = Song .
32 » Song = { Note } . 32 Song = { Note } .
33 » Note = Do | (Re | Mi | Fa | So | La) | Ti . 33 Note = Do | (Re | Mi | Fa | So | La) | Ti .
34 » Do = "c" . 34 Do = "c" .
35 » Re = "d" . 35 Re = "d" .
36 » Mi = "e" . 36 Mi = "e" .
37 » Fa = "f" . 37 Fa = "f" .
38 » So = "g" . 38 So = "g" .
39 » La = "a" . 39 La = "a" .
40 » Ti = ti . 40 Ti = ti .
41 » ti = "b" . 41 ti = "b" .
42 » `, 42 `,
43 } 43 }
44 44
45 45
46 func check(t *testing.T, filename string, src []byte) { 46 func check(t *testing.T, filename string, src []byte) {
47 grammar, err := Parse(fset, filename, src) 47 grammar, err := Parse(fset, filename, src)
48 if err != nil { 48 if err != nil {
49 t.Errorf("Parse(%s) failed: %v", src, err) 49 t.Errorf("Parse(%s) failed: %v", src, err)
50 } 50 }
51 if err = Verify(fset, grammar, "Program"); err != nil { 51 if err = Verify(fset, grammar, "Program"); err != nil {
52 t.Errorf("Verify(%s) failed: %v", src, err) 52 t.Errorf("Verify(%s) failed: %v", src, err)
(...skipping 15 matching lines...) Expand all
68 68
69 func TestFiles(t *testing.T) { 69 func TestFiles(t *testing.T) {
70 for _, filename := range files { 70 for _, filename := range files {
71 src, err := ioutil.ReadFile(filename) 71 src, err := ioutil.ReadFile(filename)
72 if err != nil { 72 if err != nil {
73 t.Fatal(err) 73 t.Fatal(err)
74 } 74 }
75 check(t, filename, src) 75 check(t, filename, src)
76 } 76 }
77 } 77 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/go/printer/printer.go » ('j') | no next file with comments »

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