diff --git a/nestkernel/connection_manager.cpp b/nestkernel/connection_manager.cpp index 0838a95897..e00efd86a3 100644 --- a/nestkernel/connection_manager.cpp +++ b/nestkernel/connection_manager.cpp @@ -413,7 +413,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, d, w ); } @@ -474,7 +475,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, params, d, w ); } @@ -541,7 +543,8 @@ nest::ConnectionManager::connect( index sgid, // we do not allow to connect a device to a global receiver at the moment if ( not source->has_proxies() ) { - return false; + throw IllegalConnection( "The models " + target->get_name() + " and " + + source->get_name() + " cannot be connected." ); } connect_( *source, *target, sgid, tid, syn, params ); } diff --git a/testsuite/regressiontests/issue-211.sli b/testsuite/regressiontests/issue-211.sli index efd14c893b..d49307fc7f 100644 --- a/testsuite/regressiontests/issue-211.sli +++ b/testsuite/regressiontests/issue-211.sli @@ -68,8 +68,7 @@ n2 d4 << /weight 1. >> Connect [g5 g5] [n1] Connect g5 n3 << /weight 1. >> Connect -% device-device; but g5g5 should be ignored -[g5 g5] [d4 g5] /one_to_one Connect +% device-device [g5 g5] [d4] Connect g5 d4 << /weight 1. >> Connect @@ -83,7 +82,7 @@ n2 v6 Connect /target_conn <[1 3 1] [2 3 1] [2 1 1] [3 1 1] [2 1 1] % neuron-neuron [1 4 1] [1 3 1] [2 4 0] [3 4 1] [2 4 0] % neuron-device [5 2 0] [5 3 1] [5 1 1] [5 1 1] [5 3 1] % device-neuron - [5 4 0] [5 4 0] [5 4 0] [5 4 0] % device-device + [5 4 0] [5 4 0] [5 4 0] % device-device [1 6 0] [1 6 1] [2 6 0] [2 6 1]> def % neuron-globally receiving device conn { diff --git a/testsuite/unittests/test_connect.sli b/testsuite/unittests/test_connect.sli index 4b9c0b9c15..5b645ddb7e 100644 --- a/testsuite/unittests/test_connect.sli +++ b/testsuite/unittests/test_connect.sli @@ -177,3 +177,34 @@ ResetKernel Last /target get 6 eq assert_or_die } forall + +(Running Connect tests with illegal combinations) = +ResetKernel + +/n_connections 0 def +modeldict +{ + pop Create /node_a Set + modeldict + { + pop Create /node_b Set + + % try to connect node_a and node_b + { + node_a node_b Connect + } stopped not + { % if there is no error, check that a connection has been made + { + n_connections 1 add + 0 GetStatus /num_connections get + eq + } assert_or_die + /n_connections n_connections 1 add def + } + { + 5 npop + } ifelse + } forall + +} forall +