tjarratt / fake4swift

A small CLI for generating Swift test doubles
MIT License
24 stars 3 forks source link

Error when unable to parse protocol? #25

Open younata opened 7 years ago

younata commented 7 years ago

a file like

protocol MyFunkyStuff
    func isFunky(name: String) -> Bool
}

(note the lack of opening {)

succeeds when it shouldn't, producing code that looks like:

import Foundation

// this file was generated by fake4swift
// https://github.com/tjarratt/fake4swift

class FakeMyFunkyStuff : MyFunkyStuff, Equatable {
    init() {
    }

    static func reset() {
    }
}

func == (a: FakeMyFunkyStuff, b: FakeMyFunkyStuff) -> Bool {
    return a === b
}
tjarratt commented 7 years ago

This might require some additional changes to SourceKitten (or maybe even sourcekitd ???) since it looks like they are giving us a mostly valid looking structure that fake4swift assumes was generated from a legit AST, free of compilation errors.

In this case, they give us a structure that lacks any methods in the protocol, which is pretty rad.