Skip to content

Commit

Permalink
test(rosetta): Extend submodule import test case for nested structs i…
Browse files Browse the repository at this point in the history
…n submodules
  • Loading branch information
ansgarm committed Apr 13, 2023
1 parent ac667df commit fc24685
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
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" } });

// 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"),
},
})

// 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"))

# 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' } });

0 comments on commit fc24685

Please sign in to comment.