Skip to content

Commit 18e805f

Browse files
committed
wip: tests arent passing with the parser refactor
1 parent 86da935 commit 18e805f

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/parser/hawk/scoped_template_builder/scoped_template_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace aaltitoad::hawk {
253253
for(auto& decl : global_symbol_declarations)
254254
external_symbols += expression_driver{}.parse(decl).get_symbol_table();
255255
parse_declarations_recursively(t, "");
256-
instantiate_tta_recursively(t, "", builder);
256+
instantiate_tta_recursively(t, "", builder); // TODO: prune duplicates
257257
builder.add_symbols(internal_symbols);
258258
builder.add_external_symbols(external_symbols);
259259
return {

test/verification/parser_tests.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ SCENARIO("parsing fischer-n suite", "[hawk_parser]") {
3131
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/fischer-suite/fischer-2");
3232
WHEN("parsing the network") {
3333
auto parse_result = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
34+
CHECK(parse_result.diagnostics.size() == 1); // TODO: The success state should not result in diagnostics
35+
REQUIRE(parse_result.result.has_value());
3436
auto n = std::move(parse_result.result.value());
3537
std::cout << *n << std::endl;
3638
THEN("three TTAs are constructed (Main, fischer1, and fischer2)") {
@@ -42,6 +44,8 @@ SCENARIO("parsing fischer-n suite", "[hawk_parser]") {
4244
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/fischer-suite/fischer-5");
4345
WHEN("parsing the network") {
4446
auto parse_result = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
47+
CHECK(parse_result.diagnostics.size() == 4); // TODO: The success state should not result in diagnostics
48+
REQUIRE(parse_result.result.has_value());
4549
auto n = std::move(parse_result.result.value());
4650
std::cout << *n << std::endl;
4751
THEN("six TTAs are constructed (fischer instances + main)") {
@@ -53,6 +57,8 @@ SCENARIO("parsing fischer-n suite", "[hawk_parser]") {
5357
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/fischer-suite/fischer-10");
5458
WHEN("parsing the network") {
5559
auto parse_result = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
60+
CHECK(parse_result.diagnostics.size() == 9); // TODO: The success state should not result in diagnostics
61+
REQUIRE(parse_result.result.has_value());
5662
auto n = std::move(parse_result.result.value());
5763
std::cout << *n << std::endl;
5864
THEN("eleven TTAs are constructed (fischer instances + main)") {
@@ -68,7 +74,11 @@ SCENARIO("parsing failing suite", "[hawk_parser]") {
6874
GIVEN("bad-template-params") {
6975
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/failing-suite/bad-template-params");
7076
THEN("parsing the network fails with a parse error") {
71-
REQUIRE_THROWS_AS(aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list), std::logic_error);
77+
auto res = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
78+
REQUIRE(res.diagnostics.size() == 2); // TODO: We should prune duplicates
79+
CHECK(res.diagnostics[0].message() == "Template parameter names must be unique");
80+
CHECK(res.diagnostics[1].message() == "Template parameter names must be unique");
81+
CHECK(!res.result.has_value());
7282
}
7383
}
7484
GIVEN("bad-invocation-args") {
@@ -80,12 +90,17 @@ SCENARIO("parsing failing suite", "[hawk_parser]") {
8090
GIVEN("bad-invocation-args-amount") {
8191
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/failing-suite/bad-invocation-args-amount");
8292
THEN("parsing the network fails with a parse error") {
83-
REQUIRE_THROWS_AS(aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list), std::logic_error);
93+
auto res = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
94+
REQUIRE(res.diagnostics.size() == 2); // TODO: We should prune duplicates
95+
CHECK(res.diagnostics[0].message() == "Provided arguments (3) does not match parameters (2)");
96+
CHECK(res.diagnostics[1].message() == "Provided arguments (3) does not match parameters (2)");
97+
CHECK(!res.result.has_value());
8498
}
8599
}
86100
GIVEN("bad-declarations") {
87101
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/failing-suite/bad-declarations");
88102
THEN("parsing the network fails with a parse error") {
103+
// TODO: This is a bit weird, that _sometimes_ the parser throws and exception, and _sometimes_ it doesnt...
89104
REQUIRE_THROWS_AS(aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list), std::logic_error);
90105
}
91106
}
@@ -98,13 +113,19 @@ SCENARIO("parsing failing suite", "[hawk_parser]") {
98113
GIVEN("bad-duplicated-locations") {
99114
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/failing-suite/bad-duplicated-locations");
100115
THEN("parsing the network fails with a parse error") {
101-
REQUIRE_THROWS_AS(aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list), std::logic_error);
116+
auto res = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
117+
REQUIRE(res.diagnostics.size() == 1);
118+
CHECK(res.diagnostics[0].message() == "Locations with same name is not allowed");
119+
CHECK(!res.result.has_value());
102120
}
103121
}
104122
GIVEN("bad-recursive-instantiation") {
105123
folders.emplace_back(AALTITOAD_PROJECT_DIR "/test/verification/failing-suite/bad-recursive-instantiation");
106124
THEN("parsing the network fails with a parse error") {
107-
REQUIRE_THROWS_AS(aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list), std::logic_error);
125+
auto res = aaltitoad::hawk::huppaal::parser{}.parse_files(folders, ignore_list);
126+
REQUIRE(res.diagnostics.size() == 1);
127+
CHECK(res.diagnostics[0].message().find("There are loops in the instantiation tree") != std::string::npos);
128+
CHECK(!res.result.has_value());
108129
}
109130
}
110131
GIVEN("bad-hawk-project") {

0 commit comments

Comments
 (0)