/*
 *  issue-351.sli
 *
 *  This file is part of NEST.
 *
 *  Copyright (C) 2004 The NEST Initiative
 *
 *  NEST is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  NEST is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/* BeginDocumentation

Name: testsuite::issue-351 Ensure Connect raises exception if connecting to device with unusable rule

Synopsis: (issue-351) run -> NEST exits if test fails

Description:
This test makes sure that connections to devices without proxies are
prohibited for probabilistic connection rules.

Author: Hans Ekkehard Plesser, 2016-11-22
 */

(unittest) run
/unittest using

M_ERROR setverbosity

/prob_rules 
[
   << /rule /fixed_indegree /indegree 1 >>
   << /rule /fixed_outdegree /outdegree 1 >>
   << /rule /fixed_total_number /N 1 >>
   << /rule /pairwise_bernoulli /p 1.0 >>
] def
              
/skip_list [ /multimeter /voltmeter % inverse order 
             /weight_recorder    % attaches to synapses 
             /correlation_detector % has proxies
             /correlomatrix_detector % has proxies
             /spin_detector      % binary recorders
             /correlospinmatrix_detector
           ] def          
              
modeldict keys
{
  /model Set
  model GetDefaults /element_type get /recorder eq
  skip_list model MemberQ not and
  {
    prob_rules 
    {
      /ruledict Set
      (Testing ) =only model =only ( ) =only ruledict/rule :: =
      { 
        ResetKernel
        1 /iaf_psc_alpha Create cvgidcollection
        2 model Create cvgidcollection
        ruledict Connect
      }
      fail_or_die
      clear
    }
    forall
  }
  if
} 
forall

endusing