/*
 *  ticket-683.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::ticket-683 - Ensure that NEST raises error when number of threads changed too late.

Synopsis: (ticket-683) run -> NEST exits if test fails

Description: 
Ensures that NEST throws an error if the number of threads is being changed after 1. custom neuron
models have been created or 2. model defaults have been changed. Each test is also run with
number of threads changed first, this should work.
 
Author: Maximilian Schmidt, 2014-10-08
 */

(unittest) run
/unittest using

M_ERROR setverbosity

[
  { /iaf_neuron /test_neuron CopyModel }
  { /static_synapse /test_synapse CopyModel }
  { /iaf_neuron << /V_reset -100. >> SetDefaults }
  { /static_synapse << /weight 10. >> SetDefaults }  
]
{
   /task Set
   [
     << /local_num_threads 2 >>
     << /total_num_virtual_procs 2 >>
   ]
   {
     /kstatdict Set

	 % copying/setting defaults before setting threads
	 % this should fail
     { 
       ResetKernel
       task        % this executes the task
       0 kstatdict SetStatus
     } fail_or_die

	 % copying/setting defaults after setting threads
	 % this should pass
     { 
       ResetKernel
       0 kstatdict SetStatus
       task        % this executes the task
     } pass_or_die

   }
   forall
}
forall

