[go] cmd/compile/internal/syntax: refactor/reword new line directives tests

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
4:19 PM (2 hours ago) 4:19 PM
to Robert Griesemer, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Robert Griesemer, Michael Podtserkovskii, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/cmd/compile/internal/syntax/parser_test.go
Insertions: 7, Deletions: 8.

@@ -271,11 +271,9 @@
{fmt.Sprintf("//line foo:10:%d\n", tooLarge), fmt.Sprintf("invalid column number: %d", tooLarge), filename, 1, 15},

// effect of valid //line directives on lines
- {"//line foo:123\n foo", valid, "foo", 123, 0},
- {"//line foo:123\n foo", valid, " foo", 123, 0},
+ {"//line foo:123\n", valid, "foo", 123, 0},
+ {"//line foo:123\n", valid, " foo", 123, 0},
{"//line foo:123\n//line bar:345\nfoo", valid, "bar", 345, 0},
- {"//line C:foo:123\n", valid, "C:foo", 123, 0},
- {"//line /src/a/a.go:123\n foo", valid, "/src/a/a.go", 123, 0},
{"//line :x:1\n", valid, ":x", 1, 0},
{"//line foo ::1\n", valid, "foo :", 1, 0},
{"//line foo:123abc:1\n", valid, "foo:123abc", 1, 0},
@@ -324,10 +322,8 @@
{fmt.Sprintf("/*line foo:10:%d*/", tooLarge), fmt.Sprintf("invalid column number: %d", tooLarge), filename, 1, 15},

// effect of valid /*line directives on lines
- {"/*line foo:123*/ foo", valid, "foo", 123, 0},
+ {"/*line foo:123*/", valid, "foo", 123, 0},
{"/*line foo:123*/\n//line bar:345\nfoo", valid, "bar", 345, 0},
- {"/*line C:foo:123*/", valid, "C:foo", 123, 0},
- {"/*line /src/a/a.go:123*/ foo", valid, "/src/a/a.go", 123, 0},
{"/*line :x:1*/", valid, ":x", 1, 0},
{"/*line foo ::1*/", valid, "foo :", 1, 0},
{"/*line foo:123abc:1*/", valid, "foo:123abc", 1, 0},
@@ -348,9 +344,12 @@
{"//line bar:1\n/*line :10:20*/", valid, "bar", 10, 20},

// effect of cleaning filenames
+ {"//line C:foo:123\n", valid, filepath.Clean("C:foo"), 123, 0},
{"//line /src/a/a.go:123\n", valid, filepath.Clean("/src/a/a.go"), 123, 0},
- {"/*line /src/a/a.go:123*/", valid, filepath.Clean("/src/a/a.go"), 123, 0},
{"//line foo/../bar:1\n", valid, filepath.Clean("foo/../bar"), 1, 0},
+ {"/*line C:foo:123*/", valid, filepath.Clean("C:foo"), 123, 0},
+ {"/*line /src/a/a.go:123*/", valid, filepath.Clean("/src/a/a.go"), 123, 0},
+ {"/*line foo/../bar:1*/", valid, filepath.Clean("foo/../bar"), 1, 0},
} {
base := NewFileBase(filename)
_, err := Parse(base, strings.NewReader(test.src), nil, nil, 0)
```

Change information

Commit message:
cmd/compile/internal/syntax: refactor/reword new line directives tests

- added a handfull of test cases to TestLineDirectives that were
removed and added to TestLineDirectivesPaths in CL 706795
- rewrote TestLineDirectivesWithDir into a simpler, more readable form
- removed TestLineDirectivesPaths and moved its cases into the
existing TestLineDirectives function

This cleanup now leaves one dedicated, simple test function that
tests the new directory-relative line-directive behavior.

Follow-up on CL 706795.
Change-Id: I1025a54ba9de034235bceaaa0cc416b7acb5cb73
Reviewed-by: Robert Griesemer <g...@google.com>
Auto-Submit: Robert Griesemer <g...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Reviewed-by: Michael Podtserkovskii <mich...@meta.com>
Files:
  • M src/cmd/compile/internal/syntax/parser_test.go
Change size: M
Delta: 1 file changed, 35 insertions(+), 89 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I1025a54ba9de034235bceaaa0cc416b7acb5cb73
Gerrit-Change-Number: 780660
Gerrit-PatchSet: 4
Gerrit-Owner: Robert Griesemer <g...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Podtserkovskii <mich...@meta.com>
Gerrit-Reviewer: Robert Griesemer <g...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages