Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Тесты на crazy стринг #112

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ void testMergeHighlightingTokens() {
// given
context = SensorContextTester.create(Path.of("."));
highlighter = new BSLHighlighter(context);
String content = "А = \"ВЫБРАТЬ РАЗРЕШЕННЫЕ Поле.Один \n" +
String content = "А = \"\" \"ВЫБРАТЬ РАЗРЕШЕННЫЕ Поле.Один \n" +
"|КАК \n" +
"| Один, 2 \n" +
" | КАК Два ИЗ Справочник.Поле\n" +
"|АВТОУПОРЯДОЧИВАНИЕ;\";";
documentContext = new DocumentContext(URI.create("file:///fake.bsl"));
documentContext.rebuild(content, 1);
documentContext.rebuild(content, 0);

inputFile = Tools.inputFileBSL(FILE_NAME, BASE_DIR, content);

Expand All @@ -101,12 +101,65 @@ void testMergeHighlightingTokens() {
// then
String componentKey = "moduleKey:" + FILE_NAME;

checkTokenTypeAtPosition(componentKey, 1, 4, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 5, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 6, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 12, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 13, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 25, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 7, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 8, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 9, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 15, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 16, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 28, TypeOfText.STRING);

checkTokenTypeAtPosition(componentKey, 2, 0, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 2, 1, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 2, 2, TypeOfText.KEYWORD);

checkTokenTypeAtPosition(componentKey, 3, 0, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 3, 1, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 3, 5, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 3, 9, TypeOfText.CONSTANT);

checkTokenTypeAtPosition(componentKey, 4, 1, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 4, 2, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 4, 6, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 4, 10, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 4, 13, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 4, 16, TypeOfText.KEYWORD_LIGHT);

checkTokenTypeAtPosition(componentKey, 5, 0, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 5, 1, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 5, 18, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 5, 19, TypeOfText.KEYWORD_LIGHT);
checkTokenTypeAtPosition(componentKey, 5, 20, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 5, 21, TypeOfText.KEYWORD_LIGHT);

}

@Test
void testCrazyStrings() {
// given
context = SensorContextTester.create(Path.of("."));
highlighter = new BSLHighlighter(context);
String content = "ТекстПредупреждения = " +
"\"выбрать пункт меню \"" +
"\" и следовать подсказкам мастера обновления\';uk=\'Увага, використовується застаріла версія FREDO Звіт!\"" +
"\" і слідувати підказкам майстра оновлення\'";

documentContext = new DocumentContext(URI.create("file:///fake.bsl"));
documentContext.rebuild(content, 0);

inputFile = Tools.inputFileBSL(FILE_NAME, BASE_DIR, content);

// when
highlighter.saveHighlighting(inputFile, documentContext);

// then
String componentKey = "moduleKey:" + FILE_NAME;

checkTokenTypeAtPosition(componentKey, 1, 7, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 8, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 9, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 15, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 1, 16, TypeOfText.KEYWORD);
checkTokenTypeAtPosition(componentKey, 1, 28, TypeOfText.STRING);

checkTokenTypeAtPosition(componentKey, 2, 0, TypeOfText.STRING);
checkTokenTypeAtPosition(componentKey, 2, 1, TypeOfText.KEYWORD);
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/src/test.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
Проверка = Истина;
Число = 0.01;
// Комментарий?

F = "F" "f";
#КонецОбласти