<commit_before>( function _l0_l3_Time_test_s_()
{

'use strict';

if( typeof module !== 'undefined' )
{
  require( '../Include3.s' );
  require( 'wTesting' );
}

const _global = _global_;
const _ = _global_.wTools;
const __ = _globals_.testing.wTools;

// --
// tests
// --

function _sleep( test )
{

  test.case = 'delay - 0';
  var start = _.time.now();
  _.time._sleep( 0 );
  var got = _.time.now() - start;
  test.true( 0 <= got );

  test.case = 'delay - 2';
  var start = _.time.now();
  _.time._sleep( 2 );
  var got = _.time.now() - start;
  test.true( 1 <= got );

  test.case = 'delay - 100';
  var start = _.time.now();
  _.time._sleep( 100 );
  var got = _.time.now() - start;
  test.true( 99 <= got );

  test.case = 'delay - 2000';
  var start = _.time.now();
  _.time._sleep( 2000 );
  var got = _.time.now() - start;
  test.true( 1999 <= got );

  /* - */

  if( !Config.debug )
  return;

  test.case = 'without arguments';
  test.shouldThrowErrorSync( () => _.time._sleep() );

  test.case = 'wrong type of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( '10' ) );

  test.case = 'negative value of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( -1 ) );

  test.case = 'Infinity value of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( Infinity ) );

  test.case = 'delay has NaN value';
  test.shouldThrowErrorSync( () => _.time._sleep( NaN ) );
}

_sleep.timeOut = 30000;

//

function sleep( test )
{

  test.case = 'delay - 0';
  var start = _.time.now();
  _.time.sleep( 0 );
  var got = _.time.now() - start;
  test.true( 0 <= got );

  test.case = 'delay - 2';
  var start = _.time.now();
  _.time.sleep( 2 );
  var got = _.time.now() - start;
  test.true( 1 <= got );

  test.case = 'delay - 100';
  var start = _.time.now();
  _.time.sleep( 100 );
  var got = _.time.now() - start;
  test.true( 99 <= got );

  test.case = 'delay - 2000';
  var start = _.time.now();
  _.time.sleep( 2000 );
  var got = _.time.now() - start;
  test.true( 1999 <= got );

  /* - */

  if( !Config.debug )
  return;

  test.case = 'without arguments';
  test.shouldThrowErrorSync( () => _.time.sleep() );

  test.case = 'extra arguments';
  test.shouldThrowErrorSync( () => _.time.sleep( 10, new _.Procedure(), 10 ) );

  test.case = 'wrong type of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( '10' ) );

  test.case = 'negative value of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( -1 ) );

  test.case = 'Infinity value of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( Infinity ) );

  test.case = 'delay has NaN value';
  test.shouldThrowErrorSync( () => _.time.sleep( NaN ) );
}

sleep.timeOut = 30000;

//

function timeOutCancelInsideOfCallback( test )
{
  let context = this;
  let visited = [];

  var timer = _.time.begin( 1, () =>
  {
    visited.push( 'v1' );
    _.time.cancel( timer );
    visited.push( 'v2' );
  });<commit_msg>Fix test routine `sleep`, close procedure after test check<commit_after>( function _l0_l3_Time_test_s_()
{

'use strict';

if( typeof module !== 'undefined' )
{
  require( '../Include3.s' );
  require( 'wTesting' );
}

const _global = _global_;
const _ = _global_.wTools;
const __ = _globals_.testing.wTools;

// --
// tests
// --

function _sleep( test )
{

  test.case = 'delay - 0';
  var start = _.time.now();
  _.time._sleep( 0 );
  var got = _.time.now() - start;
  test.true( 0 <= got );

  test.case = 'delay - 2';
  var start = _.time.now();
  _.time._sleep( 2 );
  var got = _.time.now() - start;
  test.true( 1 <= got );

  test.case = 'delay - 100';
  var start = _.time.now();
  _.time._sleep( 100 );
  var got = _.time.now() - start;
  test.true( 99 <= got );

  test.case = 'delay - 2000';
  var start = _.time.now();
  _.time._sleep( 2000 );
  var got = _.time.now() - start;
  test.true( 1999 <= got );

  /* - */

  if( !Config.debug )
  return;

  test.case = 'without arguments';
  test.shouldThrowErrorSync( () => _.time._sleep() );

  test.case = 'wrong type of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( '10' ) );

  test.case = 'negative value of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( -1 ) );

  test.case = 'Infinity value of delay';
  test.shouldThrowErrorSync( () => _.time._sleep( Infinity ) );

  test.case = 'delay has NaN value';
  test.shouldThrowErrorSync( () => _.time._sleep( NaN ) );
}

_sleep.timeOut = 30000;

//

function sleep( test )
{

  test.case = 'delay - 0';
  var start = _.time.now();
  _.time.sleep( 0 );
  var got = _.time.now() - start;
  test.true( 0 <= got );

  test.case = 'delay - 2';
  var start = _.time.now();
  _.time.sleep( 2 );
  var got = _.time.now() - start;
  test.true( 1 <= got );

  test.case = 'delay - 100';
  var start = _.time.now();
  _.time.sleep( 100 );
  var got = _.time.now() - start;
  test.true( 99 <= got );

  test.case = 'delay - 2000';
  var start = _.time.now();
  _.time.sleep( 2000 );
  var got = _.time.now() - start;
  test.true( 1999 <= got );

  /* - */

  if( !Config.debug )
  return;

  test.case = 'without arguments';
  test.shouldThrowErrorSync( () => _.time.sleep() );

  test.case = 'extra arguments';
  var procedure = new __.Procedure();
  procedure.begin();
  test.shouldThrowErrorSync( () => _.time.sleep( 10, procedure, 10 ) );
  procedure.end();

  test.case = 'wrong type of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( '10' ) );

  test.case = 'negative value of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( -1 ) );

  test.case = 'Infinity value of delay';
  test.shouldThrowErrorSync( () => _.time.sleep( Infinity ) );

  test.case = 'delay has NaN value';
  test.shouldThrowErrorSync( () => _.time.sleep( NaN ) );
}

sleep.timeOut = 30000;

//

function timeOutCancelInsideOfCallback( test )
{
  let context = this;
  let visited = [];

  var timer = _.time.begin( 1, () =>
  {
    visited.push( 'v1' );
    _.time.cancel( timer );
    visited.push( 'v2' );
  });
{'fraction_non_alphanumeric': 0.1927407158460763, 'fraction_numerical': 0.02621408166694673, 'mean_word_length': 2.7457520453115167, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2481372', 'n_tokens_mistral': 2315, 'n_tokens_neox': 2122, 'n_words': 529}