<commit_before>import test from 'ava' ;

import { list , map , group } from '../../..' ;
import { identity } from 'aureooms-js-operator' ;

test( "group", t => {

	const x = ( key, iterable, expected ) => {

		t.deepEqual( list( map( ( [ k , g ] ) => [ k , list( g ) ] , group( key , iterable ) ) ), expected );

	};

	x( identity, "", [] );

	x(
		identity,
		"AAAAAABBBBCCCCAABBCC",
		[
			["A", ["A","A","A","A","A","A"] ],
			["B", ["B","B","B","B"] ],
			["C", ["C","C","C","C"] ],
			["A", ["A","A"] ],
			["B", ["B","B"] ],
			["C", ["C","C"] ]
		]
	);

	x(
		function ( item ) {
			return item.charCodeAt(0) - 65;
		},
		"AAAAAABBBBCCCCAABBCC",
		[
			[0, ["A","A","A","A","A","A"] ],
			[1, ["B","B","B","B"] ],
			[2, ["C","C","C","C"] ],
			[0, ["A","A"] ],
			[1, ["B","B"] ],
			[2, ["C","C"] ]
		]
	);

	x(
		function ( item ) {
			return Math.floor( ( item.charCodeAt(0) - 65 ) / 2 );
		},
		"AAAAAABBBBCCCCAABBCC",
		[
			[0, ["A","A","A","A","A","A","B","B","B","B"] ],
			[1, ["C","C","C","C"] ],
			[0, ["A","A","B","B"] ],
			[1, ["C","C"] ]
		]
	);

});

//test( 'group for infinite sequence of 0' , t => {

//} );<commit_msg>introduce infinite loop test for group<commit_after>import test from 'ava' ;

import { list , map , group , repeat , next , range } from '../../..' ;
import { identity } from 'aureooms-js-operator' ;

test( "group", t => {

	const x = ( key, iterable, expected ) => {

		t.deepEqual( list( map( ( [ k , g ] ) => [ k , list( g ) ] , group( key , iterable ) ) ), expected );

	};

	x( identity, "", [] );

	x(
		identity,
		"AAAAAABBBBCCCCAABBCC",
		[
			["A", ["A","A","A","A","A","A"] ],
			["B", ["B","B","B","B"] ],
			["C", ["C","C","C","C"] ],
			["A", ["A","A"] ],
			["B", ["B","B"] ],
			["C", ["C","C"] ]
		]
	);

	x(
		function ( item ) {
			return item.charCodeAt(0) - 65;
		},
		"AAAAAABBBBCCCCAABBCC",
		[
			[0, ["A","A","A","A","A","A"] ],
			[1, ["B","B","B","B"] ],
			[2, ["C","C","C","C"] ],
			[0, ["A","A"] ],
			[1, ["B","B"] ],
			[2, ["C","C"] ]
		]
	);

	x(
		function ( item ) {
			return Math.floor( ( item.charCodeAt(0) - 65 ) / 2 );
		},
		"AAAAAABBBBCCCCAABBCC",
		[
			[0, ["A","A","A","A","A","A","B","B","B","B"] ],
			[1, ["C","C","C","C"] ],
			[0, ["A","A","B","B"] ],
			[1, ["C","C"] ]
		]
	);

});

test( 'group for infinite sequence of something' , t => {

	const v = Math.random( ) ;

	[ k , g ] = next( group( identity , repeat( v ) ) ) ;

	t.deepEqual( k , v ) ;

	for ( let i of range( 1000 ) ) t.deepEqual( next( g ) , v ) ;

} );
{'fraction_non_alphanumeric': 0.342721142403808, 'fraction_numerical': 0.015470051566838556, 'mean_word_length': 2.7867867867867866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2933785', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1111, 'n_words': 219}