Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exception when connecting fails #693

Merged
merged 5 commits into from Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion nestkernel/connection_manager.cpp
Expand Up @@ -543,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 );
}
Expand Down
73 changes: 31 additions & 42 deletions testsuite/unittests/test_connect.sli
Expand Up @@ -180,49 +180,38 @@ ResetKernel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would make sense to get all devices from the modeldict and loop through all possible combinations instead of listing them manually here? this would avoid the need to add new tests here upon adding a new device and make sure that we do not forget a certain combination.

(Running Connect tests with illegal combinations) =
ResetKernel
/generator /poisson_generator Create def
/multimeter /multimeter Create def
/recordable /iaf_psc_alpha Create def

/n_connections 0 def
modeldict
{
generator generator Connect
} fail_or_die
pop % remove model id
/model_a Set
/type_a model_a GetDefaults /element_type get def
/m_a model_a Create def
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me as if you do not need type_a anywhere, so I think you can shorten this to

pop exch Create /node_a Set

and similarly for b below.

modeldict
{
pop % remove model id
/model_b Set
/type_b model_b GetDefaults /element_type get def
/m_b model_b Create def

% try to connect model_a and model_b
{
m_a m_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

% removing items on stack
pop pop pop pop

{
generator multimeter Connect
} fail_or_die

% removing items on stack
pop pop pop pop

{
% recordable -> multimeter
recordable multimeter Connect
} fail_or_die

% removing items on stack
pop pop pop pop

{
recordable generator Connect
} fail_or_die

% removing items on stack
pop pop pop pop

{
multimeter multimeter Connect
} fail_or_die

% removing items on stack
pop pop pop pop

{
multimeter generator Connect
} fail_or_die
} forall
(All illegal connections throw an error) =

% removing items on stack
pop pop pop pop