Fix fn placement around keywords (#613)

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Meow
2021-07-01 09:43:14 -07:00
committed by GitHub
co-authored by Geoff Romer
parent 1071ec52b7
commit e7a1093eb9
7 changed files with 43 additions and 21 deletions
@@ -23,9 +23,8 @@ TEST_F(FnInserterTest, TrailingReturn) {
}
TEST_F(FnInserterTest, Inline) {
// TODO: Need to re-lex tokens, this should probably be "fn inline" for now.
constexpr char Before[] = "inline auto A() -> int;";
constexpr char After[] = "fn auto A() -> int;";
constexpr char After[] = "fn inline A() -> int;";
ExpectReplacement(Before, After);
}
@@ -36,7 +35,6 @@ TEST_F(FnInserterTest, Void) {
}
TEST_F(FnInserterTest, Methods) {
// TODO: Need to re-lex tokens, this should probably be "fn virtual" for now.
constexpr char Before[] = R"cpp(
class Shape {
public:
@@ -53,12 +51,14 @@ TEST_F(FnInserterTest, Methods) {
private:
double radius_;
};
void Shape::Draw() {}
)cpp";
constexpr char After[] = R"(
class Shape {
public:
fn void Draw() = 0;
fn auto NumSides() -> int = 0;
fn virtual Draw() = 0;
fn virtual NumSides() -> int = 0;
};
class Circle : public Shape {
@@ -70,6 +70,8 @@ TEST_F(FnInserterTest, Methods) {
private:
double radius_;
};
fn Shape::Draw() {}
)";
ExpectReplacement(Before, After);
}