Skip to content

Commit

Permalink
Additional fixes after rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Awile committed Sep 20, 2023
1 parent 8028763 commit f84f8b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/visitors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include_directories(${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
add_library(
visitor STATIC
after_cvode_to_cnexp_visitor.cpp
check_random_statement_visitor.cpp
constant_folder_visitor.cpp
defuse_analyze_visitor.cpp
global_var_visitor.cpp
Expand Down
10 changes: 6 additions & 4 deletions src/visitors/check_random_statement_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ void CheckRandomStatementVisitor::visit_program(const ast::Program& node) {

void CheckRandomStatementVisitor::visit_random(const ast::Random& node) {
logger->info(to_nmodl(node));
auto& distribution = node.get_distribution();
auto distribution = node.get_distribution();
auto distribution_name = distribution->get_node_name();
auto& params = node.get_distribution_params();
if (distributions.find(distribution_name) != distributions.end()) {
if (distributions.at(distribution_name) != params.size()) {
throw std::logic_error(
"Validation Error: {} declared with {} instead of {} parameters"_format(
distribution_name, params.size(), distributions.at(distribution_name)));
fmt::format("Validation Error: {} declared with {} instead of {} parameters",
distribution_name,
params.size(),
distributions.at(distribution_name)));
}
} else {
throw std::logic_error(
"Validation Error: distribution {} unknown"_format(distribution_name));
fmt::format("Validation Error: distribution {} unknown", distribution_name));

Check warning on line 44 in src/visitors/check_random_statement_visitor.cpp

View check run for this annotation

Codecov / codecov/patch

src/visitors/check_random_statement_visitor.cpp#L44

Added line #L44 was not covered by tests
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/modtoken/modtoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ TEST_CASE("NMODL Lexer returning valid ModToken object", "[token][modtoken]") {
std::stringstream ss;
symbol_type("text", value);
ss << *(value.get_token());
REQUIRE(ss.str() == " text at [1.1-4] type 358");
REQUIRE(ss.str() == " text at [1.1-4] type 343");
}

{
std::stringstream ss;
symbol_type(" some_text", value);
ss << *(value.get_token());
REQUIRE(ss.str() == " some_text at [1.3-11] type 358");
REQUIRE(ss.str() == " some_text at [1.3-11] type 343");
}
}

Expand All @@ -64,7 +64,7 @@ TEST_CASE("NMODL Lexer returning valid ModToken object", "[token][modtoken]") {
std::stringstream ss;
symbol_type("h'' = ", value);
ss << *(value.get_token());
REQUIRE(ss.str() == " h'' at [1.1-3] type 365");
REQUIRE(ss.str() == " h'' at [1.1-3] type 350");
REQUIRE(value.get_order()->eval() == 2);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ SCENARIO("NEURON block can add RANDOM variable", "[parser][random]") {
GIVEN("Incomplete RANDOM variable declaration") {
THEN("parser throws an error") {
REQUIRE_THROWS_WITH(is_valid_construct("NEURON { RANDOM UNIFORM ur1, ur2 }"),
Catch::Contains("Parser Error"));
Catch::Matchers::ContainsSubstring("Parser Error"));
}
}
GIVEN("Wrong number of parameters to the RANDOM distribution type") {
Expand All @@ -318,7 +318,7 @@ SCENARIO("NEURON block can add RANDOM variable", "[parser][random]") {
auto ast = driver.parse_string(construct);
REQUIRE_THROWS_WITH(nmodl::visitor::CheckRandomStatementVisitor().visit_program(
static_cast<const nmodl::ast::Program&>(*ast)),
Catch::Contains("Validation Error"));
Catch::Matchers::ContainsSubstring("Validation Error"));
}
}
}
}

0 comments on commit f84f8b4

Please sign in to comment.