Skip to content

Commit 52063ca

Browse files
committed
add docu + fix copyright year
1 parent 3c9831d commit 52063ca

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
8.82 MB
Binary file not shown.

staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ go_test(
3737
srcs = [
3838
"cmd_test.go",
3939
"namer_test.go",
40+
"parser_test.go",
4041
],
4142
embed = [":go_default_library"],
4243
)

staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/parser_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Kubernetes Authors.
2+
Copyright 2020 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -21,12 +21,33 @@ import (
2121
"testing"
2222
)
2323

24+
/*
25+
struct fields in go AST:
26+
27+
type Struct struct {
28+
// fields with a direct field Name as <Ident>
29+
A X // regular fields
30+
B *X // pointer fields
31+
C // embedded type field
32+
33+
// qualified embedded type fields use an <SelExpr> in the AST
34+
v1.TypeMeta // X=v1, Sel=TypeMeta
35+
36+
// fields without a direct name, but
37+
// a <StarExpr> in the go-AST
38+
*D // type field embedded as pointer
39+
*v1.ListMeta // qualified type field embedded as pointer
40+
// with <StarExpr> pointing to <SelExpr>
41+
}
42+
*/
43+
2444
func TestProtoParser(t *testing.T) {
2545
ident := ast.NewIdent("FieldName")
2646
tests := []struct {
2747
expr ast.Expr
2848
err bool
2949
}{
50+
// valid struct field expressions
3051
{
3152
expr: ident,
3253
err: false,
@@ -60,6 +81,7 @@ func TestProtoParser(t *testing.T) {
6081
err: false,
6182
},
6283

84+
// something else should provide an error
6385
{
6486
expr: &ast.KeyValueExpr{
6587
Key: ident,

0 commit comments

Comments
 (0)