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

fix(kernel): revert behavior change around any serialization #932

Merged
merged 13 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from 12 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
138 changes: 138 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2017,3 +2017,141 @@ export class StructUnionConsumer {

private constructor() { }
}


/**
* Test calling back to consumers that implement interfaces
*
* Check that if a JSII consumer implements IConsumerWithInterfaceParam, they can call
* the method on the argument that they're passed...
*/
export class ConsumerCanRingBell {
/**
* ...if the interface is implemented using an object literal.
*
* Returns whether the bell was rung.
*/
public static staticImplementedByObjectLiteral(ringer: IBellRinger) {
let rung = false;
ringer.yourTurn({
ring() {
rung = true;
}
});
return rung;
}

/**
* ...if the interface is implemented using a public class.
*
* Return whether the bell was rung.
*/
public static staticImplementedByPublicClass(ringer: IBellRinger) {
const bell = new Bell();
ringer.yourTurn(bell);
return bell.rung;
}

/**
* ...if the interface is implemented using a private class.
*
* Return whether the bell was rung.
*/
public static staticImplementedByPrivateClass(ringer: IBellRinger) {
const bell = new PrivateBell();
ringer.yourTurn(bell);
return bell.rung;
}

/**
* If the parameter is a concrete class instead of an interface
*
* Return whether the bell was rung.
*/
public static staticWhenTypedAsClass(ringer: IConcreteBellRinger) {
const bell = new Bell();
ringer.yourTurn(bell);
return bell.rung;
}
/**
* ...if the interface is implemented using an object literal.
*
* Returns whether the bell was rung.
*/
public implementedByObjectLiteral(ringer: IBellRinger) {
let rung = false;
ringer.yourTurn({
ring() {
rung = true;
}
});
return rung;
}

/**
* ...if the interface is implemented using a public class.
*
* Return whether the bell was rung.
*/
public implementedByPublicClass(ringer: IBellRinger) {
const bell = new Bell();
ringer.yourTurn(bell);
return bell.rung;
}

/**
* ...if the interface is implemented using a private class.
*
* Return whether the bell was rung.
*/
public implementedByPrivateClass(ringer: IBellRinger) {
const bell = new PrivateBell();
ringer.yourTurn(bell);
return bell.rung;
}

/**
* If the parameter is a concrete class instead of an interface
*
* Return whether the bell was rung.
*/
public whenTypedAsClass(ringer: IConcreteBellRinger) {
const bell = new Bell();
ringer.yourTurn(bell);
return bell.rung;
}
}

/**
* Takes the object parameter as an interface
*/
export interface IBellRinger {
yourTurn(bell: IBell): void;
}

/**
* Takes the object parameter as a calss
*/
export interface IConcreteBellRinger {
yourTurn(bell: Bell): void;
}

export interface IBell {
ring(): void;
}

export class Bell implements IBell {
public rung = false;

public ring() {
this.rung = true;
}
}

class PrivateBell implements IBell {
public rung = false;

public ring() {
this.rung = true;
}
}
Loading