Skip to content

Commit

Permalink
test: AINSERT grammar tests improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimosinger authored May 18, 2022
1 parent 1a5e8a3 commit e2fa7d8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 33 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#### Fixed
- Incorrect attribute values generated when literals are substituted in CA expressions
- AINSERT grammar tests improved

## [1.2.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.1.0...1.2.0) (2022-05-11)

Expand Down
100 changes: 67 additions & 33 deletions parser_library/test/processing/ainsert_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ TEST(ainsert, grammar_unknown_label)
analyzer a(input);
a.analyze();
a.collect_diags();
EXPECT_EQ(a.diags().size(), (size_t)8);
EXPECT_TRUE(matches_message_codes(a.diags(), { "E010", "E076", "E010", "E076", "E010", "E076", "E010", "E076" }));
}

Expand All @@ -340,7 +339,6 @@ TEST(ainsert, grammar_unknown_variable)
analyzer a(input);
a.analyze();
a.collect_diags();
EXPECT_EQ(a.diags().size(), (size_t)2);
EXPECT_TRUE(matches_message_codes(a.diags(),
{
"E010",
Expand Down Expand Up @@ -372,7 +370,6 @@ TEST(ainsert, grammar_invalid_string)
analyzer a(input);
a.analyze();
a.collect_diags();
EXPECT_EQ(a.diags().size(), (size_t)6);
EXPECT_TRUE(matches_message_codes(a.diags(),
{
"E022",
Expand All @@ -384,55 +381,77 @@ TEST(ainsert, grammar_invalid_string)
}));
}

TEST(ainsert, grammar_non_matching_apostrophes_by_two)
/*
Original valid strings:
AINSERT '&&C SETC ''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).'''x
'''''''''',BACK
*/
TEST(ainsert, grammar_non_matching_apostrophes_by_two_01)
{
std::string input = R"(
MACRO
MAC
AINSERT ' MACRO',BACK
AINSERT ' MAC_GEN',BACK
AINSERT '&&C1 SETC ''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).'''x
AINSERT '&&C SETC ''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).'''x
'''''''',BACK
AINSERT ' MEND',BACK
AINSERT '&&C2 SETC ''C''''''.''&SYSLIST(N''&SYSLIST)''(1,1).'''''x
MEND
MAC 1,2,3,4,5
MAC_GEN 6,7,8,9
)";

analyzer a(input);
a.analyze();
a.collect_diags();
EXPECT_TRUE(matches_message_codes(a.diags(), { "E022" }));
}

/*
Original valid strings:
AINSERT '&&C SETC ''C''''''.''&SYSLIST(N'&SYSLIST)''(1,1).'''''x
'''''''',BACK
*/
TEST(ainsert, grammar_non_matching_apostrophes_by_two_02)
{
std::string input = R"(
MACRO
MAC
AINSERT '&&C SETC ''C''''''.''&SYSLIST(N'&SYSLIST)''(1,1).'''''x
'''''',BACK
MEND
MAC 1,2,3,4,5
MAC_GEN 6,7,8,9
)";

analyzer a(input);
a.analyze();
a.collect_diags();
EXPECT_EQ(a.diags().size(), (size_t)4);
EXPECT_TRUE(matches_message_codes(a.diags(),
{
"E022",
"E022",
"E076",
"E076",
}));
EXPECT_TRUE(matches_message_codes(a.diags(), { "E022" }));
}

TEST(ainsert, grammar_non_matching_apostrophes_by_one)
/*
Original valid strings:
AINSERT '&&C SETC ''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).'''x
'''''''''',BACK
*/
TEST(ainsert, grammar_non_matching_apostrophes_by_one_01)
{
std::string input = R"(
MACRO
MAC
AINSERT ' MACRO',BACK
AINSERT ' MAC_GEN',BACK
AINSERT '&&C1 SETC '''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).''x
''''''''',BACK
AINSERT '&&C SETC ''C''''''.''&&SYSLIST(N''&&SYSLIST)''(1,1).'''x
''''''''''',BACK
AINSERT ' MEND',BACK
AINSERT '&&C2 SETC '''C''''''.''&SYSLIST(N''&SYSLIST)''(1,1).''''x
''''''',BACK
MEND
MAC 1,2,3,4,5
Expand All @@ -443,16 +462,31 @@ TEST(ainsert, grammar_non_matching_apostrophes_by_one)
a.analyze();
a.collect_diags();

EXPECT_TRUE(matches_message_codes(a.diags(),
{
"S0002",
"S0002",
"S0003",
"S0003",
"A011",
"E076",
"E076",
"S0003",
"A011",
}));
EXPECT_TRUE(matches_message_codes(a.diags(), { "A011", "S0002", "S0005" }));
}

/*
Original valid strings:
AINSERT '&&C SETC ''C''''''.''&SYSLIST(N'&SYSLIST)''(1,1).'''''x
'''''''',BACK
*/
TEST(ainsert, grammar_non_matching_apostrophes_by_one_02)
{
std::string input = R"(
MACRO
MAC
AINSERT '&&C SETC ''C''''''.''&SYSLIST(N'&SYSLIST)''(1,1).'''''x
''''''''',BACK
MEND
MAC 1,2,3,4,5
)";

analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(matches_message_codes(a.diags(), { "S0003", "A011", "E076", "E076" }));
}

0 comments on commit e2fa7d8

Please sign in to comment.