Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(rosetta): Extend submodule import test case for nested structs in submodules #4056

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/jsii-calc/lib/submodule/child/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export class OuterClass {
export enum SomeEnum {
SOME = 'SOME',
}

export interface AnotherStruct {
readonly stringProperty: string;
}
export interface SomeStruct {
readonly prop: SomeEnum;
readonly nestedStruct?: AnotherStruct;
}
export class InnerClass {
public static readonly staticProp: SomeStruct = { prop: SomeEnum.SOME };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
});

// Accesses two distinct points of the submodule hierarchy
var myClass = new Submodule.MyClass(new SomeStruct { Prop = Submodule.Child.SomeEnum.SOME });
var myClass = new Submodule.MyClass(new SomeStruct { Prop = Submodule.Child.SomeEnum.SOME, NestedStruct = new Submodule.Child.AnotherStruct { StringProperty = "hello" } });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently fails as the result from Rosetta is missing the Submodule.Child. for AnotherStruct
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While looking at this once more, I noticed that the original test already seems to have a small error, too:

Suggested change
var myClass = new Submodule.MyClass(new SomeStruct { Prop = Submodule.Child.SomeEnum.SOME, NestedStruct = new Submodule.Child.AnotherStruct { StringProperty = "hello" } });
var myClass = new Submodule.MyClass(new Submodule.Child.SomeStruct { Prop = Submodule.Child.SomeEnum.SOME, NestedStruct = new Submodule.Child.AnotherStruct { StringProperty = "hello" } });


// Access via a renamed import
Foo.Consumer.Consume(new ConsumerProps { Homonymous = new Homonymous { StringProperty = "yes" } });
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ awsKmsKeyExamplekms := kms.NewKmsKey(this, jsii.String("examplekms"), map[string
// Accesses two distinct points of the submodule hierarchy
myClass := submodule.NewMyClass(&SomeStruct{
Prop: child.SomeEnum_SOME,
NestedStruct: &AnotherStruct{
stringProperty: jsii.String("hello"),
},
Comment on lines +16 to +18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently fails as the result from Rosetta is returning anotherStruct instead of AnotherStruct
image

})

// Access via a renamed import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.build();

// Accesses two distinct points of the submodule hierarchy
MyClass myClass = MyClass.Builder.create().prop(SomeEnum.SOME).build();
MyClass myClass = MyClass.Builder.create().prop(SomeEnum.SOME).nestedStruct(new AnotherStruct().stringProperty("hello")).build();

// Access via a renamed import
Consumer.consume(ConsumerProps.builder().homonymous(Homonymous.builder().stringProperty("yes").build()).build());
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

# Accesses two distinct points of the submodule hierarchy
my_class = calc.submodule.MyClass(prop=calc.submodule.child.SomeEnum.SOME)
my_class = calc.submodule.MyClass(prop=calc.submodule.child.SomeEnum.SOME, nested_struct=calc.submodule.child.AnotherStruct(string_property="hello"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently fails as the result from Rosetta is missing the calc.submodule.child. for AnotherStruct
image


# Access via a renamed import
ns.foo.Consumer.consume(homonymous=ns.foo.Homonymous(string_property="yes"))
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const awsKmsKeyExamplekms = new aws.kms.KmsKey(this, 'examplekms', {
});

// Accesses two distinct points of the submodule hierarchy
const myClass = new calc.submodule.MyClass({ prop: calc.submodule.child.SomeEnum.SOME });
const myClass = new calc.submodule.MyClass({ prop: calc.submodule.child.SomeEnum.SOME, nestedStruct: { stringProperty: "hello" } });

// Access via a renamed import
ns.foo.Consumer.consume({ homonymous: { stringProperty: 'yes' } });