/*
 *  test_delay_check.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::test_delay_check - sli script to test delay checking

    Synopsis: (test_delay_check) run

    Description: This script creates a number of synapses and tests, whether min_delay and max_delay
    are set as expected. It will report for each test separately, whether it was passed or failed

    FirstVersion: July 2007
    Author: Helias
  */

/unittest (6335) require
/unittest using

% expected_min_delay expected_max_delay check_min_max_delay
/check_min_max_delay
{
  << >> begin
    /e_max_d Set
    /e_min_d Set

    /static_synapse GetDefaults begin
    { min_delay e_min_d eq max_delay e_max_d eq and } assert_or_die
    end

  end
}
def

/iaf_psc_alpha Create /n1 Set
/iaf_psc_alpha Create /n2 Set
/iaf_psc_alpha Create /n3 Set

/static_synapse << /delay 2.0 >> SetDefaults

% test 1: use standard connect
n1 n2 Connect
2.0 2.0 check_min_max_delay

% test 2: check if candidate is _not_ reported
/static_synapse << /delay 10.0 >> SetDefaults
2.0 2.0 check_min_max_delay

% test 3: check if new delay is set as min_delay
/static_synapse << /delay 1.0 >> SetDefaults
n2 n3 Connect
1.0 2.0 check_min_max_delay

% test 4: set if 'gid gid w d Connect' works as expected
n2 n3 1.0 6.0 Connect
1.0 6.0 check_min_max_delay

% test 5: check if min_delay is updated in 'gid gid params Connect'
n2 n3 << /delay 0.5 >> Connect
0.5 6.0 check_min_max_delay

% test 6: check if SetStatus sets min_delay
<< /source n1 /synapse_model /static_synapse >> FindConnections 0 get
<< /delay 0.1 >> SetStatus
0.1 6.0 check_min_max_delay

endusing