<commit_before>
use strict;
use warnings;

use lib 't/lib/';
use Test::More;
use Data::Dumper;

BEGIN {
    use_ok( 'Bio::EnsEMBL::Hive::Utils', 'stringify', 'destringify' );
}
#########################


my $structure = {
    'foo' => 'bar',
    'bar' => 'foobar'
};

my $struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');


$struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');

$structure = {
    foo => 'bar',
    latin => {
	lorem => {
	    ipsum => 'dolor',
	},
	atrium => 'foo bar',
    }
};

$Data::Dumper::Maxdepth = 1;
$struct_string = stringify $structure;
ok($structure, 'value returned');
is($struct_string, 
   q!{"foo" => "bar","latin" => {"atrium" => "foo bar","lorem" => {"ipsum" => "dolor"}}}!,
   'correct depth');

done_testing();<commit_msg>more tests for roundtrip<commit_after>
use strict;
use warnings;

use lib 't/lib/';
use Test::More;
use Data::Dumper;

BEGIN {
    use_ok( 'Bio::EnsEMBL::Hive::Utils', 'stringify', 'destringify' );
}
#########################


my $structure = {
    'foo' => 'bar',
    'bar' => 'foobar'
};

my $struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');


$struct_string = stringify $structure;
ok($struct_string, 'returned a value');
is($struct_string, q!{"bar" => "foobar","foo" => "bar"}!, 'correct representation');

$structure = {
    foo => 'bar',
    latin => {
	lorem => {
	    ipsum => 'dolor',
	},
	atrium => 'foo bar',
    }
};

$Data::Dumper::Maxdepth = 1;
$struct_string = stringify $structure;
ok($structure, 'value returned');
is($struct_string, 
   q!{"foo" => "bar","latin" => {"atrium" => "foo bar","lorem" => {"ipsum" => "dolor"}}}!,
   'correct depth');

my $destructure = destringify $structure;
ok($destructure, 'recreated a hash');
isa_ok($destructure, 'HASH'); ## really is a hash
is($destructure->{'foo'}, 'bar', 'foo value correct');
is($destructure->{'latin'}{'lorem'}{'ipsum'}, 'dolor', 'latin test');

$destructure = destringify "[{ 'alpha' => 'beta' }, { 'gamma' => 'delta'}, {'omega' => undef}]";
isa_ok($destructure, 'ARRAY'); ## got an array
is($destructure->[0]{'alpha'}, 'beta', 'hash entry');
is($destructure->[2]{'omega'}, undef, 'undef values');

done_testing();
{'fraction_non_alphanumeric': 0.24989955805544395, 'fraction_numerical': 0.0016070711128967456, 'mean_word_length': 5.384615384615385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, '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': '5804537', 'n_tokens_mistral': 932, 'n_tokens_neox': 886, 'n_words': 204}