From 1791d20c44d853ffb539175a966525f9830a22b7 Mon Sep 17 00:00:00 2001 From: Eli Polonsky Date: Tue, 16 Mar 2021 01:02:53 +0200 Subject: [PATCH] chore(compliance): golang compliance tests batch (#2690) One more batch related to https://github.com/aws/jsii/issues/2634 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0 --- .../specification/6-compliance-report.md | 238 ++++++------ .../project/compliance_test.go | 352 +++++++++++++++++- tools/jsii-compliance/suite.ts | 8 +- 3 files changed, 474 insertions(+), 124 deletions(-) diff --git a/gh-pages/content/specification/6-compliance-report.md b/gh-pages/content/specification/6-compliance-report.md index 1be5f02c3c..64728a0b27 100644 --- a/gh-pages/content/specification/6-compliance-report.md +++ b/gh-pages/content/specification/6-compliance-report.md @@ -5,122 +5,122 @@ This section details the current state of each language binding with respect to our standard compliance suite. -| number | test | java (100.00%) | golang (28.21%) | Dotnet | Python | -| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------------- | ------ | ------ | -| 1 | asyncOverrides_overrideCallsSuper | 🟢 | ⭕ | ⭕ | ⭕ | -| 2 | [arrayReturnedByMethodCanBeRead]("Array created in the kernel can be queried for its elements") | 🟢 | 🟢 | ⭕ | ⭕ | -| 3 | [unionProperties]("Kernal values that accept a union type can be set, and are returned with the concrete type") | 🟢 | 🟢 | ⭕ | ⭕ | -| 4 | syncOverrides | 🟢 | ⭕ | ⭕ | ⭕ | -| 5 | [useEnumFromScopedModule]("Property that accepts an enum type from a third-party package can be set, and read") | 🟢 | 🟢 | ⭕ | ⭕ | -| 6 | [createObjectAndCtorOverloads]("Class can be instantiated with empty and non empty constructor") | 🟢 | ⚪ | ⭕ | ⭕ | -| 7 | fail_syncOverrides_callsDoubleAsync_method | 🟢 | ⭕ | ⭕ | ⭕ | -| 8 | collectionOfInterfaces_MapOfStructs | 🟢 | ⭕ | ⭕ | ⭕ | -| 9 | asyncOverrides_overrideAsyncMethod | 🟢 | ⭕ | ⭕ | ⭕ | -| 10 | [statics]("Static functions can be invoked and accept and return the correct type") | 🟢 | 🟢 | ⭕ | ⭕ | -| 11 | [structs_returnedLiteralEqualsNativeBuilt]("A struct returned from the kernel is not distinguishable from a struct created natively") | 🟢 | 🟢 | ⭕ | ⭕ | -| 12 | [classesCanSelfReferenceDuringClassInitialization]("Classes can reference other classes during initialization") | 🟢 | 🟢 | ⭕ | ⭕ | -| 13 | [canObtainStructReferenceWithOverloadedSetter]("A class with a settable property of a union type can be returned from the kernel") | 🟢 | 🟢 | ⭕ | ⭕ | -| 14 | [callbacksCorrectlyDeserializeArguments]("Runtime properly deserializes callback arguments from the kernel") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 15 | [canUseInterfaceSetters]("Read-write properties generate the corresponding setters in the target language") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2665) | ⭕ | ⭕ | -| 16 | [propertyOverrides_interfaces]("Target language can override properties of host interfaces") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2665) | ⭕ | ⭕ | -| 17 | syncOverrides_callsSuper | 🟢 | ⭕ | ⭕ | ⭕ | -| 18 | [testJsiiAgent]("Asserts the correct value of the JSII_AGENT env variable for the kernel process") | 🟢 | 🟢 | ⭕ | ⭕ | -| 19 | [doNotOverridePrivates_method_private]("Non public methods on the guest class do not override methods in the host class") | 🟢 | 🟢 | ⭕ | ⭕ | -| 20 | [pureInterfacesCanBeUsedTransparently]("Guest implementation of a pure host interface can be used by host consumers accepting that interface") | 🟢 | 🟢 | ⭕ | ⭕ | -| 21 | [nullShouldBeTreatedAsUndefined]("Null value of target language is treated as undefined by the host") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2442) | ⭕ | ⭕ | -| 22 | [primitiveTypes]("All Primitive types are set and read with their respective types") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | -| 23 | reservedKeywordsAreSlugifiedInClassProperties | 🟢 | ⭕ | ⭕ | ⭕ | -| 24 | objectIdDoesNotGetReallocatedWhenTheConstructorPassesThisOut | 🟢 | ⭕ | ⭕ | ⭕ | -| 25 | interfaceBuilder | 🟢 | ⭕ | ⭕ | ⭕ | -| 26 | unionTypes | 🟢 | ⭕ | ⭕ | ⭕ | -| 27 | arrays | 🟢 | ⭕ | ⭕ | ⭕ | -| 28 | staticMapInClassCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | -| 29 | consts | 🟢 | ⭕ | ⭕ | ⭕ | -| 30 | pureInterfacesCanBeUsedTransparently_WhenTransitivelyImplementing | 🟢 | ⭕ | ⭕ | ⭕ | -| 31 | reservedKeywordsAreSlugifiedInMethodNames | 🟢 | ⭕ | ⭕ | ⭕ | -| 32 | exceptions | 🟢 | ⭕ | ⭕ | ⭕ | -| 33 | testLiteralInterface | 🟢 | ⭕ | ⭕ | ⭕ | -| 34 | structs_nonOptionalhashCode | 🟢 | ⭕ | ⭕ | ⭕ | -| 35 | propertyOverrides_set_throws | 🟢 | ⭕ | ⭕ | ⭕ | -| 36 | canLeverageIndirectInterfacePolymorphism | 🟢 | ⭕ | ⭕ | ⭕ | -| 37 | fluentApi | 🟢 | ⭕ | ⭕ | ⭕ | -| 38 | staticListInClassCanBeReadCorrectly | 🟢 | ⭕ | ⭕ | ⭕ | -| 39 | mapReturnedByMethodCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | -| 40 | receiveInstanceOfPrivateClass | 🟢 | ⭕ | ⭕ | ⭕ | -| 41 | staticMapInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | -| 42 | testNativeObjectsWithInterfaces | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 43 | doNotOverridePrivates_property_getter_public | 🟢 | 🟢 | ⭕ | ⭕ | -| 44 | equalsIsResistantToPropertyShadowingResultVariable | 🟢 | 🟢 | ⭕ | ⭕ | -| 45 | listInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | -| 46 | useNestedStruct | 🟢 | [🔴](https://github.com/aws/jsii/pull/2650) | ⭕ | ⭕ | -| 47 | testFluentApiWithDerivedClasses | 🟢 | 🟢 | ⭕ | ⭕ | -| 48 | interfacesCanBeUsedTransparently_WhenAddedToJsiiType | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 49 | canOverrideProtectedGetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 50 | getAndSetEnumValues | 🟢 | 🟢 | ⭕ | ⭕ | -| 51 | structs_nonOptionalequals | 🟢 | 🟢 | ⭕ | ⭕ | -| 52 | testInterfaceParameter | 🟢 | 🟢 | ⭕ | ⭕ | -| 53 | liftedKwargWithSameNameAsPositionalArg | 🟢 | 🟢 | ⭕ | ⭕ | -| 54 | creationOfNativeObjectsFromJavaScriptObjects | 🟢 | [🔴](??) | ⭕ | ⭕ | -| 55 | canOverrideProtectedMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 56 | canLoadEnumValues | 🟢 | 🟢 | ⭕ | ⭕ | -| 57 | eraseUnsetDataValues | 🟢 | [🔴](https://github.com/aws/jsii/issues/2671) | ⭕ | ⭕ | -| 58 | maps | 🟢 | 🟢 | ⭕ | ⭕ | -| 59 | structs_containsNullChecks | 🟢 | [🔴](https://github.com/aws/jsii/issues/2672) | ⭕ | ⭕ | -| 60 | canOverrideProtectedSetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2673) | ⭕ | ⭕ | -| 61 | asyncOverrides_callAsyncMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | -| 62 | nodeStandardLibrary | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | -| 63 | dates | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | -| 64 | collectionOfInterfaces_ListOfStructs | 🟢 | 🟢 | ⭕ | ⭕ | -| 65 | objRefsAreLabelledUsingWithTheMostCorrectType | 🟢 | 🔴 | ⭕ | ⭕ | -| 66 | unionPropertiesWithBuilder | 🟢 | 🟢 | ⭕ | ⭕ | -| 67 | doNotOverridePrivates_property_getter_private | 🟢 | 🟢 | ⭕ | ⭕ | -| 68 | structs_withDiamondInheritance_correctlyDedupeProperties | 🟢 | 🟢 | ⭕ | ⭕ | -| 69 | abstractMembersAreCorrectlyHandled | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | -| 70 | doNotOverridePrivates_property_by_name_private | 🟢 | 🟢 | ⭕ | ⭕ | -| 71 | testNullIsAValidOptionalMap | 🟢 | 🟢 | ⭕ | ⭕ | -| 72 | mapReturnedByMethodCanBeRead | 🟢 | 🟢 | ⭕ | ⭕ | -| 73 | structs_multiplePropertiesEquals | 🟢 | 🟢 | ⭕ | ⭕ | -| 74 | mapInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | -| 75 | staticListInClassCannotBeModified | 🟢 | ⚪ | ⭕ | ⭕ | -| 76 | collectionOfInterfaces_MapOfInterfaces | 🟢 | 🟢 | ⭕ | ⭕ | -| 77 | asyncOverrides_overrideThrows | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | -| 78 | callMethods | 🟢 | 🟢 | ⭕ | ⭕ | -| 79 | returnAbstract | 🟢 | 🟢 | ⭕ | ⭕ | -| 80 | dynamicTypes | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | -| 81 | hashCodeIsResistantToPropertyShadowingResultVariable | 🟢 | ⭕ | ⭕ | ⭕ | -| 82 | returnSubclassThatImplementsInterface976 | 🟢 | ⭕ | ⭕ | ⭕ | -| 83 | structs_optionalEquals | 🟢 | ⭕ | ⭕ | ⭕ | -| 84 | propertyOverrides_get_calls_super | 🟢 | ⭕ | ⭕ | ⭕ | -| 85 | unmarshallIntoAbstractType | 🟢 | ⭕ | ⭕ | ⭕ | -| 86 | structs_multiplePropertiesHashCode | 🟢 | ⭕ | ⭕ | ⭕ | -| 87 | fail_syncOverrides_callsDoubleAsync_propertyGetter | 🟢 | ⭕ | ⭕ | ⭕ | -| 88 | propertyOverrides_get_set | 🟢 | ⭕ | ⭕ | ⭕ | -| 89 | variadicMethodCanBeInvoked | 🟢 | ⭕ | ⭕ | ⭕ | -| 90 | collectionTypes | 🟢 | ⭕ | ⭕ | ⭕ | -| 91 | asyncOverrides_overrideAsyncMethodByParentClass | 🟢 | ⭕ | ⭕ | ⭕ | -| 92 | structs_optionalHashCode | 🟢 | ⭕ | ⭕ | ⭕ | -| 93 | testStructsCanBeDowncastedToParentType | 🟢 | ⭕ | ⭕ | ⭕ | -| 94 | propertyOverrides_get_throws | 🟢 | ⭕ | ⭕ | ⭕ | -| 95 | getSetPrimitiveProperties | 🟢 | ⭕ | ⭕ | ⭕ | -| 96 | getAndSetNonPrimitiveProperties | 🟢 | ⭕ | ⭕ | ⭕ | -| 97 | reservedKeywordsAreSlugifiedInStructProperties | 🟢 | ⭕ | ⭕ | ⭕ | -| 98 | fail_syncOverrides_callsDoubleAsync_propertySetter | 🟢 | ⭕ | ⭕ | ⭕ | -| 99 | doNotOverridePrivates_method_public | 🟢 | ⭕ | ⭕ | ⭕ | -| 100 | testNullIsAValidOptionalList | 🟢 | ⭕ | ⭕ | ⭕ | -| 101 | mapInClassCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | -| 102 | doNotOverridePrivates_property_by_name_public | 🟢 | ⭕ | ⭕ | ⭕ | -| 103 | asyncOverrides_twoOverrides | 🟢 | ⭕ | ⭕ | ⭕ | -| 104 | propertyOverrides_set_calls_super | 🟢 | ⭕ | ⭕ | ⭕ | -| 105 | iso8601DoesNotDeserializeToDate | 🟢 | ⭕ | ⭕ | ⭕ | -| 106 | collectionOfInterfaces_ListOfInterfaces | 🟢 | ⭕ | ⭕ | ⭕ | -| 107 | undefinedAndNull | 🟢 | ⭕ | ⭕ | ⭕ | -| 108 | structs_serializeToJsii | 🟢 | ⭕ | ⭕ | ⭕ | -| 109 | structsAreUndecoratedOntheWayToKernel | 🟢 | ⭕ | ⭕ | ⭕ | -| 110 | canObtainReferenceWithOverloadedSetter | 🟢 | ⭕ | ⭕ | ⭕ | -| 111 | testJSObjectLiteralToNative | 🟢 | ⭕ | ⭕ | ⭕ | -| 112 | structs_stepBuilders | 🟢 | ⭕ | ⭕ | ⭕ | -| 113 | classWithPrivateConstructorAndAutomaticProperties | 🟢 | ⭕ | ⭕ | ⭕ | -| 114 | arrayReturnedByMethodCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | -| 115 | correctlyDeserializesStructUnions | 🟢 | ⭕ | ⭕ | ⭕ | -| 116 | subclassing | 🟢 | ⭕ | ⭕ | ⭕ | -| 117 | testInterfaces | 🟢 | ⭕ | ⭕ | ⭕ | +| number | test | java (100.00%) | golang (34.19%) | Dotnet | Python | +| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------------- | ------ | ------ | +| 1 | asyncOverrides_overrideCallsSuper | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | +| 2 | [arrayReturnedByMethodCanBeRead]("Array created in the kernel can be queried for its elements") | 🟢 | 🟢 | ⭕ | ⭕ | +| 3 | [unionProperties]("Kernal values that accept a union type can be set, and are returned with the concrete type") | 🟢 | 🟢 | ⭕ | ⭕ | +| 4 | syncOverrides | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 5 | [useEnumFromScopedModule]("Property that accepts an enum type from a third-party package can be set, and read") | 🟢 | 🟢 | ⭕ | ⭕ | +| 6 | [createObjectAndCtorOverloads]("Class can be instantiated with empty and non empty constructor") | 🟢 | ⚪ | ⭕ | ⭕ | +| 7 | fail_syncOverrides_callsDoubleAsync_method | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 8 | collectionOfInterfaces_MapOfStructs | 🟢 | 🟢 | ⭕ | ⭕ | +| 9 | asyncOverrides_overrideAsyncMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | +| 10 | [statics]("Static functions can be invoked and accept and return the correct type") | 🟢 | 🟢 | ⭕ | ⭕ | +| 11 | [structs_returnedLiteralEqualsNativeBuilt]("A struct returned from the kernel is not distinguishable from a struct created natively") | 🟢 | 🟢 | ⭕ | ⭕ | +| 12 | [classesCanSelfReferenceDuringClassInitialization]("Classes can reference other classes during initialization") | 🟢 | 🟢 | ⭕ | ⭕ | +| 13 | [canObtainStructReferenceWithOverloadedSetter]("A class with a settable property of a union type can be returned from the kernel") | 🟢 | 🟢 | ⭕ | ⭕ | +| 14 | [callbacksCorrectlyDeserializeArguments]("Runtime properly deserializes callback arguments from the kernel") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 15 | [canUseInterfaceSetters]("Read-write properties generate the corresponding setters in the target language") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2665) | ⭕ | ⭕ | +| 16 | [propertyOverrides_interfaces]("Target language can override properties of host interfaces") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2665) | ⭕ | ⭕ | +| 17 | syncOverrides_callsSuper | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 18 | [testJsiiAgent]("Asserts the correct value of the JSII_AGENT env variable for the kernel process") | 🟢 | 🟢 | ⭕ | ⭕ | +| 19 | [doNotOverridePrivates_method_private]("Non public methods on the guest class do not override methods in the host class") | 🟢 | 🟢 | ⭕ | ⭕ | +| 20 | [pureInterfacesCanBeUsedTransparently]("Guest implementation of a pure host interface can be used by host consumers accepting that interface") | 🟢 | 🟢 | ⭕ | ⭕ | +| 21 | [nullShouldBeTreatedAsUndefined]("Null value of target language is treated as undefined by the host") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2442) | ⭕ | ⭕ | +| 22 | [primitiveTypes]("All Primitive types are set and read with their respective types") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | +| 23 | [reservedKeywordsAreSlugifiedInClassProperties]("TS code that uses reserved words as class property names get slugified so it is usable in the target language") | 🟢 | ⚪ | ⭕ | ⭕ | +| 24 | [objectIdDoesNotGetReallocatedWhenTheConstructorPassesThisOut]("Ensure the JSII kernel can pass 'this' out to JSII remotes from within the constructor") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 25 | [interfaceBuilder]("Seems to be a duplicate of 'propertyOverrides_interfaces'?") | 🟢 | [🔴](https://github.com/aws/jsii/issues/2665) | ⭕ | ⭕ | +| 26 | unionTypes | 🟢 | [🔴](https://github.com/aws/jsii/issues/2686) | ⭕ | ⭕ | +| 27 | arrays | 🟢 | [🔴](https://github.com/aws/jsii/issues/2686) | ⭕ | ⭕ | +| 28 | staticMapInClassCannotBeModified | 🟢 | ⚪ | ⭕ | ⭕ | +| 29 | consts | 🟢 | 🟢 | ⭕ | ⭕ | +| 30 | pureInterfacesCanBeUsedTransparently_WhenTransitivelyImplementing | 🟢 | 🟢 | ⭕ | ⭕ | +| 31 | reservedKeywordsAreSlugifiedInMethodNames | 🟢 | ⚪ | ⭕ | ⭕ | +| 32 | exceptions | 🟢 | 🟢 | ⭕ | ⭕ | +| 33 | testLiteralInterface | 🟢 | 🟢 | ⭕ | ⭕ | +| 34 | structs_nonOptionalhashCode | 🟢 | ⚪ | ⭕ | ⭕ | +| 35 | propertyOverrides_set_throws | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 36 | canLeverageIndirectInterfacePolymorphism | 🟢 | [🔴](https://github.com/aws/jsii/issues/2688) | ⭕ | ⭕ | +| 37 | fluentApi | 🟢 | ⚪ | ⭕ | ⭕ | +| 38 | staticListInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | +| 39 | mapReturnedByMethodCannotBeModified | 🟢 | ⚪ | ⭕ | ⭕ | +| 40 | receiveInstanceOfPrivateClass | 🟢 | 🟢 | ⭕ | ⭕ | +| 41 | staticMapInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | +| 42 | testNativeObjectsWithInterfaces | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 43 | doNotOverridePrivates_property_getter_public | 🟢 | 🟢 | ⭕ | ⭕ | +| 44 | equalsIsResistantToPropertyShadowingResultVariable | 🟢 | 🟢 | ⭕ | ⭕ | +| 45 | listInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | +| 46 | useNestedStruct | 🟢 | [🔴](https://github.com/aws/jsii/pull/2650) | ⭕ | ⭕ | +| 47 | testFluentApiWithDerivedClasses | 🟢 | 🟢 | ⭕ | ⭕ | +| 48 | interfacesCanBeUsedTransparently_WhenAddedToJsiiType | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 49 | canOverrideProtectedGetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 50 | getAndSetEnumValues | 🟢 | 🟢 | ⭕ | ⭕ | +| 51 | structs_nonOptionalequals | 🟢 | 🟢 | ⭕ | ⭕ | +| 52 | testInterfaceParameter | 🟢 | 🟢 | ⭕ | ⭕ | +| 53 | liftedKwargWithSameNameAsPositionalArg | 🟢 | 🟢 | ⭕ | ⭕ | +| 54 | creationOfNativeObjectsFromJavaScriptObjects | 🟢 | [🔴](??) | ⭕ | ⭕ | +| 55 | canOverrideProtectedMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 56 | canLoadEnumValues | 🟢 | 🟢 | ⭕ | ⭕ | +| 57 | eraseUnsetDataValues | 🟢 | [🔴](https://github.com/aws/jsii/issues/2671) | ⭕ | ⭕ | +| 58 | maps | 🟢 | 🟢 | ⭕ | ⭕ | +| 59 | structs_containsNullChecks | 🟢 | [🔴](https://github.com/aws/jsii/issues/2672) | ⭕ | ⭕ | +| 60 | canOverrideProtectedSetter | 🟢 | [🔴](https://github.com/aws/jsii/issues/2673) | ⭕ | ⭕ | +| 61 | asyncOverrides_callAsyncMethod | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | +| 62 | nodeStandardLibrary | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | +| 63 | dates | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | +| 64 | collectionOfInterfaces_ListOfStructs | 🟢 | 🟢 | ⭕ | ⭕ | +| 65 | objRefsAreLabelledUsingWithTheMostCorrectType | 🟢 | 🔴 | ⭕ | ⭕ | +| 66 | unionPropertiesWithBuilder | 🟢 | 🟢 | ⭕ | ⭕ | +| 67 | doNotOverridePrivates_property_getter_private | 🟢 | 🟢 | ⭕ | ⭕ | +| 68 | structs_withDiamondInheritance_correctlyDedupeProperties | 🟢 | 🟢 | ⭕ | ⭕ | +| 69 | abstractMembersAreCorrectlyHandled | 🟢 | [🔴](https://github.com/aws/jsii/issues/2048) | ⭕ | ⭕ | +| 70 | doNotOverridePrivates_property_by_name_private | 🟢 | 🟢 | ⭕ | ⭕ | +| 71 | testNullIsAValidOptionalMap | 🟢 | 🟢 | ⭕ | ⭕ | +| 72 | mapReturnedByMethodCanBeRead | 🟢 | 🟢 | ⭕ | ⭕ | +| 73 | structs_multiplePropertiesEquals | 🟢 | 🟢 | ⭕ | ⭕ | +| 74 | mapInClassCanBeReadCorrectly | 🟢 | 🟢 | ⭕ | ⭕ | +| 75 | staticListInClassCannotBeModified | 🟢 | ⚪ | ⭕ | ⭕ | +| 76 | collectionOfInterfaces_MapOfInterfaces | 🟢 | 🟢 | ⭕ | ⭕ | +| 77 | asyncOverrides_overrideThrows | 🟢 | [🔴](https://github.com/aws/jsii/issues/2670) | ⭕ | ⭕ | +| 78 | callMethods | 🟢 | 🟢 | ⭕ | ⭕ | +| 79 | returnAbstract | 🟢 | 🟢 | ⭕ | ⭕ | +| 80 | dynamicTypes | 🟢 | [🔴](https://github.com/aws/jsii/issues/2659) | ⭕ | ⭕ | +| 81 | hashCodeIsResistantToPropertyShadowingResultVariable | 🟢 | ⭕ | ⭕ | ⭕ | +| 82 | returnSubclassThatImplementsInterface976 | 🟢 | ⭕ | ⭕ | ⭕ | +| 83 | structs_optionalEquals | 🟢 | ⭕ | ⭕ | ⭕ | +| 84 | propertyOverrides_get_calls_super | 🟢 | ⭕ | ⭕ | ⭕ | +| 85 | unmarshallIntoAbstractType | 🟢 | ⭕ | ⭕ | ⭕ | +| 86 | structs_multiplePropertiesHashCode | 🟢 | ⭕ | ⭕ | ⭕ | +| 87 | fail_syncOverrides_callsDoubleAsync_propertyGetter | 🟢 | ⭕ | ⭕ | ⭕ | +| 88 | propertyOverrides_get_set | 🟢 | ⭕ | ⭕ | ⭕ | +| 89 | variadicMethodCanBeInvoked | 🟢 | ⭕ | ⭕ | ⭕ | +| 90 | collectionTypes | 🟢 | ⭕ | ⭕ | ⭕ | +| 91 | asyncOverrides_overrideAsyncMethodByParentClass | 🟢 | ⭕ | ⭕ | ⭕ | +| 92 | structs_optionalHashCode | 🟢 | ⭕ | ⭕ | ⭕ | +| 93 | testStructsCanBeDowncastedToParentType | 🟢 | ⭕ | ⭕ | ⭕ | +| 94 | propertyOverrides_get_throws | 🟢 | ⭕ | ⭕ | ⭕ | +| 95 | getSetPrimitiveProperties | 🟢 | ⭕ | ⭕ | ⭕ | +| 96 | getAndSetNonPrimitiveProperties | 🟢 | ⭕ | ⭕ | ⭕ | +| 97 | reservedKeywordsAreSlugifiedInStructProperties | 🟢 | ⭕ | ⭕ | ⭕ | +| 98 | fail_syncOverrides_callsDoubleAsync_propertySetter | 🟢 | ⭕ | ⭕ | ⭕ | +| 99 | doNotOverridePrivates_method_public | 🟢 | ⭕ | ⭕ | ⭕ | +| 100 | testNullIsAValidOptionalList | 🟢 | ⭕ | ⭕ | ⭕ | +| 101 | mapInClassCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | +| 102 | doNotOverridePrivates_property_by_name_public | 🟢 | ⭕ | ⭕ | ⭕ | +| 103 | asyncOverrides_twoOverrides | 🟢 | ⭕ | ⭕ | ⭕ | +| 104 | propertyOverrides_set_calls_super | 🟢 | ⭕ | ⭕ | ⭕ | +| 105 | iso8601DoesNotDeserializeToDate | 🟢 | ⭕ | ⭕ | ⭕ | +| 106 | collectionOfInterfaces_ListOfInterfaces | 🟢 | ⭕ | ⭕ | ⭕ | +| 107 | undefinedAndNull | 🟢 | ⭕ | ⭕ | ⭕ | +| 108 | structs_serializeToJsii | 🟢 | ⭕ | ⭕ | ⭕ | +| 109 | structsAreUndecoratedOntheWayToKernel | 🟢 | ⭕ | ⭕ | ⭕ | +| 110 | canObtainReferenceWithOverloadedSetter | 🟢 | ⭕ | ⭕ | ⭕ | +| 111 | testJSObjectLiteralToNative | 🟢 | ⭕ | ⭕ | ⭕ | +| 112 | structs_stepBuilders | 🟢 | ⭕ | ⭕ | ⭕ | +| 113 | classWithPrivateConstructorAndAutomaticProperties | 🟢 | ⭕ | ⭕ | ⭕ | +| 114 | arrayReturnedByMethodCannotBeModified | 🟢 | ⭕ | ⭕ | ⭕ | +| 115 | correctlyDeserializesStructUnions | 🟢 | ⭕ | ⭕ | ⭕ | +| 116 | subclassing | 🟢 | ⭕ | ⭕ | ⭕ | +| 117 | testInterfaces | 🟢 | ⭕ | ⭕ | ⭕ | diff --git a/packages/@jsii/go-runtime-test/project/compliance_test.go b/packages/@jsii/go-runtime-test/project/compliance_test.go index 41ada56c3e..95ab785df0 100644 --- a/packages/@jsii/go-runtime-test/project/compliance_test.go +++ b/packages/@jsii/go-runtime-test/project/compliance_test.go @@ -7,11 +7,12 @@ import ( "testing" "time" - "github.com/aws/jsii/jsii-calc/go/jcb" calc "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3" "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/composition" "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/submodule/child" calclib "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib" + "github.com/aws/jsii/jsii-calc/go/jcb" + "github.com/stretchr/testify/assert" "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib/customsubmodulename" "github.com/stretchr/testify/suite" ) @@ -571,7 +572,7 @@ func (i *TestPropertyOverridesInterfacesIInterfaceWithProperties) ReadWriteStrin return i.x + "?" } -// Note this method is not currently part of the generated interface for some reason (??). +// Note this method is not currently part of the generated interface for some reason (https://github.com/aws/jsii/issues/2665). func (i *TestPropertyOverridesInterfacesIInterfaceWithProperties) SetReadWriteString(value string) { i.x = value + "!" } @@ -905,6 +906,353 @@ func (suite *ComplianceSuite) TestAsyncOverrides_overrideThrows() { assert.Panics(func() { obj.CallMe() }) } +func (suite *ComplianceSuite) TestReservedKeywordsAreSlugifiedInClassProperties() { + suite.NotApplicableTest("Golang doesnt have any reserved words that can be used in public API") +} + +func (suite *ComplianceSuite) TestObjectIdDoesNotGetReallocatedWhenTheConstructorPassesThisOut() { + reflector := PartiallyInitializedThisConsumerImpl{ + assert: suite.Assert(), + }; + suite.FailTest("Test relies on overrides, which are not supported yet", "https://github.com/aws/jsii/issues/2048") + calc.NewConstructorPassesThisOut(&reflector); +} + +type PartiallyInitializedThisConsumerImpl struct { + assert *assert.Assertions +} + +func (p PartiallyInitializedThisConsumerImpl) ConsumePartiallyInitializedThis(obj calc.ConstructorPassesThisOut, dt string, ev calc.AllTypesEnum) string { + + epoch := time.Date(1970, time.January, 1, 0, 0, 0, 0, nil) + + p.assert.NotNil(obj); + p.assert.Equal(epoch, dt); + p.assert.Equal(calc.AllTypesEnum_THIS_IS_GREAT, ev); + + return "OK"; + +} + +func (suite *ComplianceSuite) TestInterfaceBuilder() { + + assert := suite.Assert() + + interact := calc.NewUsesInterfaceWithProperties(&TestInterfaceBuilderIInterfaceWithProperties{value: "READ_WRITE"}); + assert.Equal("READ_ONLY", interact.JustRead()); + + suite.FailTest("Not sure. Most likely related to the missing setters on interfaces", "https://github.com/aws/jsii/issues/2665") + assert.Equal("Hello", interact.WriteAndRead("Hello")); +} + +type TestInterfaceBuilderIInterfaceWithProperties struct { + value string +} + +func (i *TestInterfaceBuilderIInterfaceWithProperties) ReadOnlyString() string { + return "READ_ONLY" +} + +func (i *TestInterfaceBuilderIInterfaceWithProperties) ReadWriteString() string { + return i.value +} + +func (i *TestInterfaceBuilderIInterfaceWithProperties) SetReadWriteString(val string) { + i.value = val +} + +func (suite *ComplianceSuite) TestUnionTypes() { + + assert := suite.Assert() + + types := calc.NewAllTypes(); + + // single valued property + types.SetUnionProperty(1234); + assert.Equal(float64(1234), types.UnionProperty()); + + types.SetUnionProperty("Hello"); + assert.Equal("Hello", types.UnionProperty()); + + types.SetUnionProperty(calc.NewMultiply(calclib.NewNumber(2), calclib.NewNumber(12))); + multiply, ok := types.UnionProperty().(calc.Multiply) + + assert.True(ok) + assert.Equal(float64(24), multiply.Value()); + + // map + m := map[string]interface{}{"Foo": calclib.NewNumber(99)}; + types.SetUnionMapProperty(m); + + number, ok := types.UnionMapProperty()["Foo"].(calclib.Number) + assert.True(ok) + assert.Equal(float64(99), number.Value()); + + // array + suite.FailTest("Unable to set an array of interfaces", "https://github.com/aws/jsii/issues/2686") + a := []interface{}{123, calclib.NewNumber(33)} + types.SetUnionArrayProperty(a); + + number, ok = types.UnionArrayProperty()[1].(calclib.Number) + assert.True(ok) + assert.Equal(33, number.Value()); +} + +func (suite *ComplianceSuite) TestArrays() { + assert := suite.Assert() + sum := calc.NewSum(); + + suite.FailTest("Unable to set an array of interfaces", "https://github.com/aws/jsii/issues/2686") + sum.SetParts([]calclib.NumericValue{calclib.NewNumber(5), calclib.NewNumber(10), calc.NewMultiply(calclib.NewNumber(2), calclib.NewNumber(3))}); + assert.Equal(10 + 5 + (2 * 3), sum.Value()); + assert.Equal(5, sum.Parts()[0].Value()); + assert.Equal(6, sum.Parts()[2].Value()); + assert.Equal("(((0 + 5) + 10) + (2 * 3))", sum.ToString()); +} + +func (suite *ComplianceSuite) TestStaticMapInClassCannotBeModified() { + suite.NotApplicableTest("Golang does not have unmodifiable maps") +} + +func (suite *ComplianceSuite) TestConsts() { + + assert := suite.Assert() + + assert.Equal("hello", calc.Statics_Foo()); + obj := calc.Statics_ConstObj(); + assert.Equal("world", obj.Hello()); + + assert.Equal(float64(1234), calc.Statics_Bar()); + assert.Equal("world", calc.Statics_ZooBar()["hello"]); + +} + +func (suite *ComplianceSuite) TestReceiveInstanceOfPrivateClass() { + assert := suite.Assert() + assert.True(calc.NewReturnsPrivateImplementationOfInterface().PrivateImplementation().Success()); +} + +func (suite *ComplianceSuite) TestMapReturnedByMethodCannotBeModified() { + suite.NotApplicableTest("Golang does not have unmodifiable maps") +} + +func (suite *ComplianceSuite) TestStaticListInClassCanBeReadCorrectly() { + assert := suite.Assert() + + arr := calc.ClassWithCollections_StaticArray() + assert.Contains(arr, "one"); + assert.Contains(arr, "two"); +} + +func (suite *ComplianceSuite) TestFluentApi() { + suite.NotApplicableTest("Golang props are intentionally not designed to be fluent") +} + +func (suite *ComplianceSuite) TestCanLeverageIndirectInterfacePolymorphism() { + provider := calc.NewAnonymousImplementationProvider(); + assert := suite.Assert() + assert.Equal(float64(1337), provider.ProvideAsClass().Value()); + + suite.FailTest("Unable to reuse instances between parent/child interfaces", "https://github.com/aws/jsii/issues/2688") + assert.Equal(float64(1337), provider.ProvideAsInterface().Value()); + assert.Equal("to implement", provider.ProvideAsInterface().Verb()); +} + +func (suite *ComplianceSuite) TestPropertyOverrides_Set_Throws() { + + assert := suite.Assert() + so := TestPropertyOverrides_Set_ThrowsSyncVirtualMethods{ + SyncVirtualMethods: calc.NewSyncVirtualMethods(), + } + + suite.FailTest("This test relies on overrides which are not supported yet", "https://github.com/aws/jsii/issues/2048") + assert.Panics(func () { so.ModifyValueOfTheProperty("Hii"); }) +} + +type TestPropertyOverrides_Set_ThrowsSyncVirtualMethods struct { + calc.SyncVirtualMethods +} + +func (s *TestPropertyOverrides_Set_ThrowsSyncVirtualMethods) SetTheProperty(val string) { + panic("Exception from overloaded setter") +} + +func (suite *ComplianceSuite) TestStructs_NonOptionalhashCode() { + suite.NotApplicableTest("Golang does not have hashCode") +} + +func (suite *ComplianceSuite) TestTestLiteralInterface() { + + assert := suite.Assert() + obj := calc.NewJsObjectLiteralForInterface(); + friendly := obj.GiveMeFriendly(); + assert.Equal("I am literally friendly!", friendly.Hello()); + + gen := obj.GiveMeFriendlyGenerator(); + assert.Equal("giveMeFriendlyGenerator", gen.Hello()); + assert.Equal(float64(42), gen.Next()); +} + +func (suite *ComplianceSuite) TestReservedKeywordsAreSlugifiedInMethodNames() { + suite.NotApplicableTest("Golang doesnt have any reserved words that can be used in public API") +} + +func (suite *ComplianceSuite) TestPureInterfacesCanBeUsedTransparently_WhenTransitivelyImplementing() { + assert := suite.Assert() + expected := calc.StructB{ + RequiredString: "It's Britney b**ch!", + } + delegate := NewIndirectlyImplementsStructReturningDelegate(expected); + consumer := calc.NewConsumePureInterface(delegate); + assert.Equal(expected, consumer.WorkItBaby()); +} + +func NewIndirectlyImplementsStructReturningDelegate(expected calc.StructB) calc.IStructReturningDelegate { + return &IndirectlyImplementsStructReturningDelegate{ImplementsStructReturningDelegate: ImplementsStructReturningDelegate{expected: expected}} +} + +type IndirectlyImplementsStructReturningDelegate struct { + ImplementsStructReturningDelegate +} + +type ImplementsStructReturningDelegate struct { + expected calc.StructB +} + +func (i ImplementsStructReturningDelegate) ReturnStruct() calc.StructB { + return i.expected +} + +func (suite *ComplianceSuite) TestExceptions() { + + assert := suite.Assert() + + calc3 := calc.NewCalculator(calc.CalculatorProps{InitialValue: 20, MaximumValue: 30}) + calc3.Add(3); + assert.Equal(float64(23), calc3.Value()); + + // TODO: should assert the actual error here - not working for some reasons + assert.Panics(func() { + calc3.Add(10) + }) + + calc3.SetMaxValue(40); + calc3.Add(10); + assert.Equal(float64(33), calc3.Value()); + +} + +func (suite *ComplianceSuite) TestSyncOverrides_CallsSuper() { + + assert := suite.Assert() + + obj := SyncOverrides{returnSuper: true, SyncVirtualMethods: calc.NewSyncVirtualMethods(), multiplier: 1}; + + suite.FailTest("Overrides are not supported yet", "https://github.com/aws/jsii/issues/2048") + assert.Equal(float64(10 * 5), obj.CallerIsProperty()); + + obj.returnSuper = true; // js code returns n * 2 + assert.Equal(float64(10 * 2), obj.CallerIsProperty()); +} + +type SyncOverrides struct { + calc.SyncVirtualMethods + returnSuper bool + multiplier float64 + callAsync bool +} + +func (s *SyncOverrides) VirtualMethod(n float64) float64 { + if (s.returnSuper) { + return s.SyncVirtualMethods.VirtualMethod(n) + } + if (s.callAsync) { + obj := OverrideAsyncMethods{AsyncVirtualMethods: calc.NewAsyncVirtualMethods()}; + return obj.CallMe(); + } + return 5 * n * s.multiplier +} + +func (suite *ComplianceSuite) TestAsyncOverrides_OverrideCallsSuper() { + + assert := suite.Assert() + + obj := OverrideCallsSuper{AsyncVirtualMethods: calc.NewAsyncVirtualMethods()}; + + suite.FailTest("Async methods are not implemented", "https://github.com/aws/jsii/issues/2670") + assert.Equal(1441, obj.OverrideMe(12)); + assert.Equal(1209, obj.CallMe()); +} + +type OverrideCallsSuper struct { + calc.AsyncVirtualMethods +} + +func (o *OverrideCallsSuper) OverrideMe(mult float64) float64 { + superRet := o.AsyncVirtualMethods.OverrideMe(mult); + return superRet * 10 + 1; +} + +func (suite *ComplianceSuite) TestSyncOverrides() { + + assert := suite.Assert() + + obj := SyncOverrides{returnSuper: false, SyncVirtualMethods: calc.NewSyncVirtualMethods(), multiplier: 1}; + + suite.FailTest("Overrides not supported", "https://github.com/aws/jsii/issues/2048") + assert.Equal(float64(10 * 5), obj.CallerIsMethod()); + + // affect the result + obj.multiplier = 5; + assert.Equal(float64(10 * 5 * 5), obj.CallerIsMethod()); + + // verify callbacks are invoked from a property + assert.Equal(float64(10 * 5 * 5), obj.CallerIsProperty()); + + // and from an async method + obj.multiplier = 3; + assert.Equal(float64(10 * 5 * 3), obj.CallerIsAsync()); +} + +func (suite *ComplianceSuite) TestAsyncOverrides_OverrideAsyncMethod() { + + assert := suite.Assert() + + obj := OverrideAsyncMethods{AsyncVirtualMethods: calc.NewAsyncVirtualMethods()}; + + suite.FailTest("Async methods are not implemented", "https://github.com/aws/jsii/issues/2670") + assert.Equal(float64(4452), obj.CallMe()); +} + +type OverrideAsyncMethods struct { + calc.AsyncVirtualMethods +} + +func (o *OverrideAsyncMethods) OverrideMe(mult float64) float64 { + return o.foo() * 2 +} + +// Implement another method, which doesn't override anything in the base class. +// This should obviously be possible. +func (o *OverrideAsyncMethods) foo() float64 { + return 2222 +} + +func (suite *ComplianceSuite) TestFail_SyncOverrides_CallsDoubleAsync_Method() { + suite.Assert().Panics(func() { + obj := SyncOverrides{SyncVirtualMethods: calc.NewSyncVirtualMethods()}; + obj.callAsync = true; + suite.FailTest("Overrides not supported", "https://github.com/aws/jsii/issues/2048") + obj.CallerIsMethod(); + }) +} + +func (suite *ComplianceSuite) TestCollectionOfInterfaces_MapOfStructs() { + assert := suite.Assert() + m := calc.InterfaceCollections_MapOfStructs() + assert.Equal("Hello, I'm String!", m["A"].RequiredString) +} + // required to make `go test` recognize the suite. func TestComplianceSuite(t *testing.T) { suite.Run(t, new(ComplianceSuite)) diff --git a/tools/jsii-compliance/suite.ts b/tools/jsii-compliance/suite.ts index b4234b967c..1f581285c0 100644 --- a/tools/jsii-compliance/suite.ts +++ b/tools/jsii-compliance/suite.ts @@ -123,15 +123,17 @@ export const suite: schema.Suite = { }, { name: 'reservedKeywordsAreSlugifiedInClassProperties', - description: '', + description: + 'TS code that uses reserved words as class property names get slugified so it is usable in the target language', }, { name: 'objectIdDoesNotGetReallocatedWhenTheConstructorPassesThisOut', - description: '', + description: + "Ensure the JSII kernel can pass 'this' out to JSII remotes from within the constructor", }, { name: 'interfaceBuilder', - description: '', + description: "Seems to be a duplicate of 'propertyOverrides_interfaces'?", }, { name: 'unionTypes',