mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 07:55:00 +01:00
Insert fn for void functions (#596)
This commit is contained in:
@@ -30,13 +30,12 @@ TEST_F(FnInserterTest, Inline) {
|
||||
}
|
||||
|
||||
TEST_F(FnInserterTest, Void) {
|
||||
// TODO: void needs to be handled.
|
||||
constexpr char Before[] = "void A();";
|
||||
ExpectReplacement(Before, Before);
|
||||
constexpr char After[] = "fn A();";
|
||||
ExpectReplacement(Before, After);
|
||||
}
|
||||
|
||||
TEST_F(FnInserterTest, Methods) {
|
||||
// TODO: void needs to be handled.
|
||||
// TODO: Need to re-lex tokens, this should probably be "fn virtual" for now.
|
||||
constexpr char Before[] = R"cpp(
|
||||
class Shape {
|
||||
@@ -58,13 +57,13 @@ TEST_F(FnInserterTest, Methods) {
|
||||
constexpr char After[] = R"(
|
||||
class Shape {
|
||||
public:
|
||||
virtual void Draw() = 0;
|
||||
fn void Draw() = 0;
|
||||
fn auto NumSides() -> int = 0;
|
||||
};
|
||||
|
||||
class Circle : public Shape {
|
||||
public:
|
||||
void Draw() override;
|
||||
fn Draw() override;
|
||||
fn NumSides() -> int override;
|
||||
fn Radius() -> double { return radius_; }
|
||||
|
||||
@@ -75,6 +74,17 @@ TEST_F(FnInserterTest, Methods) {
|
||||
ExpectReplacement(Before, After);
|
||||
}
|
||||
|
||||
TEST_F(FnInserterTest, ConstructorDestructor) {
|
||||
constexpr char Before[] = R"cpp(
|
||||
class Shape {
|
||||
public:
|
||||
Shape() {}
|
||||
~Shape() {}
|
||||
};
|
||||
)cpp";
|
||||
ExpectReplacement(Before, Before);
|
||||
}
|
||||
|
||||
TEST_F(FnInserterTest, LegacyReturn) {
|
||||
// Code should be migrated to trailing returns by clang-tidy, so this is okay
|
||||
// to miss.
|
||||
|
||||
Reference in New Issue
Block a user