Skip to content

Commit

Permalink
remove error argument types from generated arguments
Browse files Browse the repository at this point in the history
We currently don't support them anyways, therefore
we can just leave them out
  • Loading branch information
DanielMSchmidt authored and Daniel Schmidt committed May 21, 2018
1 parent fa4e2f2 commit fdf526c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
19 changes: 17 additions & 2 deletions generation/__tests__/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,16 @@ describe('iOS generation', () => {
expect(ExampleClass.performAction).toBeInstanceOf(Function);
});

it('should have the first arg set as invocation', () => {
expect(ExampleClass.performAction('MyClass', 'Foo')).toEqual({
it("should have the first arg set as invocation", () => {
expect(
ExampleClass.performAction(
{
type: "Invocation",
value: "MyClass"
},
"Foo"
)
).toEqual({
target: {
type: 'Invocation',
value: 'MyClass'
Expand All @@ -317,6 +325,13 @@ describe('iOS generation', () => {
});
});

describe("filtered argument types", () => {
it("should remove them from the method", () => {
// gets the expected arguments
expect(ExampleClass.rotateDeviceToOrientationErrorOrNil.length).toBe(1);
});
});

afterAll(() => {
// Clean up
remove.removeSync('./__tests__/generated-ios');
Expand Down
6 changes: 6 additions & 0 deletions generation/core/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ module.exports = function getGenerator({
);
}

const blacklistedArgumentTypes = ["__strong NSError **"];
function filterBlacklistedArguments(arg) {
return !blacklistedArgumentTypes.includes(arg.type);
}

function createMethod(classJson, json) {
json.args = json.args.filter(filterBlacklistedArguments);
const args = json.args.map(({ name }) => t.identifier(name));

if (!json.static) {
Expand Down
6 changes: 5 additions & 1 deletion generation/fixtures/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@
// This method is an instance method
// For us this means that we don't set the class type, but let it be set from the outside
// This is an assumption based on our current experience with EarlGrey, we might need to rework this at some point
- (instancetype)performAction:(NSString *)action;
- (instancetype)performAction:(NSString *)action;

// This method has a blacklisted argument type, so it should only have one arg
+ (BOOL)rotateDeviceToOrientation:(UIDeviceOrientation)deviceOrientation
errorOrNil:(__strong NSError **)errorOrNil;

0 comments on commit fdf526c

Please sign in to comment.