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

Side by Side Diff: src/pkg/go/parser/short_test.go

Issue 112970044: code review 112970044: go/*: permit "for range x" (Closed)
Patch Set: diff -r 1739cf8be3ea https://code.google.com/p/go/ Created 10 years, 8 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/go/parser/parser.go ('k') | src/pkg/go/printer/nodes.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 // This file contains test cases for short valid and invalid programs. 5 // This file contains test cases for short valid and invalid programs.
6 6
7 package parser 7 package parser
8 8
9 import "testing" 9 import "testing"
10 10
(...skipping 20 matching lines...) Expand all
31 `package p; func f() { select { case <- c: case c <- d: case c <- <- d: case <-c <- d: } };`, 31 `package p; func f() { select { case <- c: case c <- d: case c <- <- d: case <-c <- d: } };`,
32 `package p; func f() { select { case x := (<-c): } };`, 32 `package p; func f() { select { case x := (<-c): } };`,
33 `package p; func f() { if ; true {} };`, 33 `package p; func f() { if ; true {} };`,
34 `package p; func f() { switch ; {} };`, 34 `package p; func f() { switch ; {} };`,
35 `package p; func f() { for _ = range "foo" + "bar" {} };`, 35 `package p; func f() { for _ = range "foo" + "bar" {} };`,
36 `package p; func f() { var s []int; g(s[:], s[i:], s[:j], s[i:j], s[i:j: k], s[:j:k]) };`, 36 `package p; func f() { var s []int; g(s[:], s[i:], s[:j], s[i:j], s[i:j: k], s[:j:k]) };`,
37 `package p; var ( _ = (struct {*T}).m; _ = (interface {T}).m )`, 37 `package p; var ( _ = (struct {*T}).m; _ = (interface {T}).m )`,
38 `package p; func ((T),) m() {}`, 38 `package p; func ((T),) m() {}`,
39 `package p; func ((*T),) m() {}`, 39 `package p; func ((*T),) m() {}`,
40 `package p; func (*(T),) m() {}`, 40 `package p; func (*(T),) m() {}`,
41 `package p; func _(x []int) { for range x {} }`,
41 } 42 }
42 43
43 func TestValid(t *testing.T) { 44 func TestValid(t *testing.T) {
44 for _, src := range valids { 45 for _, src := range valids {
45 checkErrors(t, src, src) 46 checkErrors(t, src, src)
46 } 47 }
47 } 48 }
48 49
49 var invalids = []string{ 50 var invalids = []string{
50 `foo /* ERROR "expected 'package'" */ !`, 51 `foo /* ERROR "expected 'package'" */ !`,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 `package p; func f() { go f /* ERROR HERE "function must be invoked" */ }`, 93 `package p; func f() { go f /* ERROR HERE "function must be invoked" */ }`,
93 `package p; func f() { defer func() {} /* ERROR HERE "function must be i nvoked" */ }`, 94 `package p; func f() { defer func() {} /* ERROR HERE "function must be i nvoked" */ }`,
94 `package p; func f() { go func() { func() { f(x func /* ERROR "expected '\)'" */ (){}) } } }`, 95 `package p; func f() { go func() { func() { f(x func /* ERROR "expected '\)'" */ (){}) } } }`,
95 } 96 }
96 97
97 func TestInvalid(t *testing.T) { 98 func TestInvalid(t *testing.T) {
98 for _, src := range invalids { 99 for _, src := range invalids {
99 checkErrors(t, src, src) 100 checkErrors(t, src, src)
100 } 101 }
101 } 102 }
OLDNEW
« no previous file with comments | « src/pkg/go/parser/parser.go ('k') | src/pkg/go/printer/nodes.go » ('j') | no next file with comments »

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