-
-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are three cases tested plus a test for nothing can be suggested.
- Loading branch information
1 parent
291c5aa
commit 8789ab1
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <gtest/gtest.h> | ||
#include <platform.h> | ||
|
||
#include "util.h" | ||
|
||
#define TEST_ERRORS(src, err1) \ | ||
{ const char* errs[] = {err1, NULL}; \ | ||
DO(test_expected_errors(src, "ir", errs)); } | ||
|
||
class SuggestAltNameTest : public PassTest | ||
{}; | ||
|
||
TEST_F(SuggestAltNameTest, SuggestAltName_Private) | ||
{ | ||
const char* src = | ||
"actor Main\n" | ||
" var _aStr: String = \"help\"\n" | ||
|
||
" new create(env: Env) =>\n" | ||
" _aStr = xx()\n" | ||
|
||
" fun xx(): String =>\n" | ||
" aStr // Undefined suggest _aStr\n"; | ||
|
||
TEST_ERRORS(src, | ||
"can't find declaration of 'aStr', did you mean '_aStr'?"); | ||
} | ||
|
||
TEST_F(SuggestAltNameTest, SuggestAltName_DifferentCaseVariable) | ||
{ | ||
const char* src = | ||
"actor Main\n" | ||
" var aStr: String = \"help\"\n" | ||
|
||
" new create(env: Env) =>\n" | ||
" aStr = xx()\n" | ||
|
||
" fun xx(): String =>\n" | ||
" astr // Undefined, suggest aStr\n"; | ||
|
||
TEST_ERRORS(src, | ||
"can't find declaration of 'astr', did you mean 'aStr'?"); | ||
} | ||
|
||
TEST_F(SuggestAltNameTest, SuggestAltName_DifferentCaseMethod) | ||
{ | ||
const char* src = | ||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" doit() // Undefined, suggest doIt\n" | ||
|
||
" fun doIt() =>\n" | ||
" None\n"; | ||
|
||
TEST_ERRORS(src, | ||
"can't find declaration of 'doit', did you mean 'doIt'?"); | ||
} | ||
|
||
TEST_F(SuggestAltNameTest, SuggestAltName_NothingToSuggest) | ||
{ | ||
const char* src = | ||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" doIt() // Undefined, nothing to suggest\n"; | ||
|
||
TEST_ERRORS(src, | ||
"can't find declaration of 'doIt'"); | ||
} |