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

Side by Side Diff: src/go/format/format_test.go

Issue 142360043: code review 142360043: go/format, cmd/gofmt: fix issues with partial Go code w... (Closed)
Patch Set: diff -r 8f36a32a9d036f86fb956c8538142eb384bd1a4a https://code.google.com/p/go Created 9 years, 6 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/go/format/format.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 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 format 5 package format
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "go/parser" 9 "go/parser"
10 "go/token" 10 "go/token"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // statement lists 81 // statement lists
82 "x := 0", 82 "x := 0",
83 "f(a, b, c)\nvar x int = f(1, 2, 3)", 83 "f(a, b, c)\nvar x int = f(1, 2, 3)",
84 84
85 // indentation, leading and trailing space 85 // indentation, leading and trailing space
86 "\tx := 0\n\tgo f()", 86 "\tx := 0\n\tgo f()",
87 "\tx := 0\n\tgo f()\n\n\n", 87 "\tx := 0\n\tgo f()\n\n\n",
88 "\n\t\t\n\n\tx := 0\n\tgo f()\n\n\n", 88 "\n\t\t\n\n\tx := 0\n\tgo f()\n\n\n",
89 "\n\t\t\n\n\t\t\tx := 0\n\t\t\tgo f()\n\n\n", 89 "\n\t\t\n\n\t\t\tx := 0\n\t\t\tgo f()\n\n\n",
90 » "\n\t\t\n\n\t\t\tx := 0\n\t\t\tconst s = `\nfoo\n`\n\n\n", // no indenta tion inside raw strings 90 » "\n\t\t\n\n\t\t\tx := 0\n\t\t\tconst s = `\nfoo\n`\n\n\n", // no ind entation added inside raw strings
91 » "\n\t\t\n\n\t\t\tx := 0\n\t\t\tconst s = `\n\t\tfoo\n`\n\n\n", // no ind entation removed inside raw strings
92
93 » // comments
94 » "i := 5 /* Comment */", // Issue 5551.
91 95
92 // erroneous programs 96 // erroneous programs
93 "ERROR1 + 2 +", 97 "ERROR1 + 2 +",
94 "ERRORx := 0", 98 "ERRORx := 0",
95 } 99 }
96 100
97 func String(s string) (string, error) { 101 func String(s string) (string, error) {
98 res, err := Source([]byte(s)) 102 res, err := Source([]byte(s))
99 if err != nil { 103 if err != nil {
100 return "", err 104 return "", err
(...skipping 14 matching lines...) Expand all
115 // test expected to succeed 119 // test expected to succeed
116 res, err := String(src) 120 res, err := String(src)
117 if err != nil { 121 if err != nil {
118 t.Errorf("formatting failed (%s):\n%q", err, src ) 122 t.Errorf("formatting failed (%s):\n%q", err, src )
119 } else if res != src { 123 } else if res != src {
120 t.Errorf("formatting incorrect:\nsource: %q\nres ult: %q", src, res) 124 t.Errorf("formatting incorrect:\nsource: %q\nres ult: %q", src, res)
121 } 125 }
122 } 126 }
123 } 127 }
124 } 128 }
OLDNEW
« no previous file with comments | « src/go/format/format.go ('k') | no next file » | no next file with comments »

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