From f84f8b4606cf3c8346d56e6d07bd782b46540179 Mon Sep 17 00:00:00 2001 From: Omar Awile Date: Wed, 20 Sep 2023 14:35:09 +0200 Subject: [PATCH] Additional fixes after rebasing --- src/visitors/CMakeLists.txt | 1 + src/visitors/check_random_statement_visitor.cpp | 10 ++++++---- test/unit/modtoken/modtoken.cpp | 6 +++--- test/unit/parser/parser.cpp | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/visitors/CMakeLists.txt b/src/visitors/CMakeLists.txt index 8871c9f80d..99e5964cce 100644 --- a/src/visitors/CMakeLists.txt +++ b/src/visitors/CMakeLists.txt @@ -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 diff --git a/src/visitors/check_random_statement_visitor.cpp b/src/visitors/check_random_statement_visitor.cpp index 66a6b19bb6..80afb856a6 100644 --- a/src/visitors/check_random_statement_visitor.cpp +++ b/src/visitors/check_random_statement_visitor.cpp @@ -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)); } } diff --git a/test/unit/modtoken/modtoken.cpp b/test/unit/modtoken/modtoken.cpp index 6af6298584..d473b3307b 100644 --- a/test/unit/modtoken/modtoken.cpp +++ b/test/unit/modtoken/modtoken.cpp @@ -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"); } } @@ -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); } } diff --git a/test/unit/parser/parser.cpp b/test/unit/parser/parser.cpp index 8acdc0ce93..020fadc55c 100644 --- a/test/unit/parser/parser.cpp +++ b/test/unit/parser/parser.cpp @@ -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") { @@ -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(*ast)), - Catch::Contains("Validation Error")); + Catch::Matchers::ContainsSubstring("Validation Error")); } } -} \ No newline at end of file +}