Show TypeSpec docs are ignored

This commit is contained in:
warnar boekkooi
2019-03-28 16:09:52 +01:00
parent 1de009706d
commit d3fc79bc1b
3 changed files with 58 additions and 1 deletions
+3 -1
View File
@@ -26,7 +26,8 @@ generate: root build
.root/src/$(PKG)/tests/named_type.go \
.root/src/$(PKG)/tests/custom_map_key_type.go \
.root/src/$(PKG)/tests/embedded_type.go \
.root/src/$(PKG)/tests/reference_to_pointer.go
.root/src/$(PKG)/tests/reference_to_pointer.go \
.root/src/$(PKG)/tests/type_declaration.go
.root/bin/easyjson -all .root/src/$(PKG)/tests/data.go
.root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go
@@ -40,6 +41,7 @@ generate: root build
.root/bin/easyjson .root/src/$(PKG)/tests/embedded_type.go
.root/bin/easyjson .root/src/$(PKG)/tests/reference_to_pointer.go
.root/bin/easyjson -disallow_unknown_fields .root/src/$(PKG)/tests/disallow_unknown.go
.root/bin/easyjson .root/src/$(PKG)/tests/type_declaration.go
test: generate root
go test \
+22
View File
@@ -52,6 +52,9 @@ var testCases = []struct {
{&intArrayStructValue, intArrayStructValueString},
{&myUInt8SliceValue, myUInt8SliceString},
{&myUInt8ArrayValue, myUInt8ArrayString},
{&myGenDeclaredValue, myGenDeclaredString},
{&myGenDeclaredWithCommentValue, myGenDeclaredWithCommentString},
{&myTypeDeclaredValue, myTypeDeclaredString},
}
func TestMarshal(t *testing.T) {
@@ -242,3 +245,22 @@ func TestDisallowUnknown(t *testing.T) {
t.Error("want error, got nil")
}
}
var testNotGeneratedTypeCases = []interface{}{
TypeNotDeclared{},
}
func TestMethodsNoGenerated(t *testing.T) {
var ok bool
for i, instance := range testNotGeneratedTypeCases {
_, ok = instance.(json.Marshaler)
if ok {
t.Errorf("[%d, %T] Unexpected MarshalJSON()", i, instance)
}
_, ok = instance.(json.Unmarshaler)
if ok {
t.Errorf("[%d, %T] Unexpected Unmarshaler()", i, instance)
}
}
}
+33
View File
@@ -0,0 +1,33 @@
package tests
//easyjson:json
type (
GenDeclared1 struct {
Value string
}
// A gen declared easyjson struct with a comment
GenDeclaredWithComment struct {
Value string
}
)
type (
//easyjson:json
TypeDeclared struct {
Value string
}
TypeNotDeclared struct {
Value string
}
)
var (
myGenDeclaredValue = TypeDeclared{Value: "GenDeclared"}
myGenDeclaredString = `{"Value":"GenDeclared"}`
myGenDeclaredWithCommentValue = TypeDeclared{Value: "GenDeclaredWithComment"}
myGenDeclaredWithCommentString = `{"Value":"GenDeclaredWithComment"}`
myTypeDeclaredValue = TypeDeclared{Value: "TypeDeclared"}
myTypeDeclaredString = `{"Value":"TypeDeclared"}`
)