@@ -2,17 +2,19 @@ package main
2
2
3
3
import (
4
4
"path/filepath"
5
+ "runtime"
5
6
"strconv"
6
7
"testing"
7
8
)
8
9
9
10
type F map [TagField ]string
10
11
11
12
var testCases = []struct {
12
- filename string
13
- relative bool
14
- basepath string
15
- tags []Tag
13
+ filename string
14
+ relative bool
15
+ basepath string
16
+ minversion string
17
+ tags []Tag
16
18
}{
17
19
{filename : "tests/const.go-src" , tags : []Tag {
18
20
tag ("Test" , 1 , "p" , F {}),
@@ -88,10 +90,20 @@ var testCases = []struct {
88
90
{filename : "tests/simple.go-src" , relative : true , basepath : "dir" , tags : []Tag {
89
91
Tag {Name : "main" , File : "../tests/simple.go-src" , Address : "1" , Type : "p" , Fields : F {"line" : "1" }},
90
92
}},
93
+ {filename : "tests/range.go-src" , minversion : "go1.4" , tags : []Tag {
94
+ tag ("main" , 1 , "p" , F {}),
95
+ tag ("fmt" , 3 , "i" , F {}),
96
+ tag ("main" , 5 , "f" , F {"access" : "private" , "signature" : "()" }),
97
+ }},
91
98
}
92
99
93
100
func TestParse (t * testing.T ) {
94
101
for _ , testCase := range testCases {
102
+ if testCase .minversion != "" && runtime .Version () < testCase .minversion {
103
+ t .Skipf ("[%s] skipping test. Version is %s, but test requires %s" , testCase .filename , runtime .Version (), testCase .minversion )
104
+ continue
105
+ }
106
+
95
107
basepath , err := filepath .Abs (testCase .basepath )
96
108
if err != nil {
97
109
t .Errorf ("[%s] could not determine base path: %s\n " , testCase .filename , err )
0 commit comments