Initial commit
[tie-hash-sorted-xs.git] / t / Tie-Hash-Sorted-XS.t
CommitLineData
f0a05402
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Test::More tests => 5;
6BEGIN { use_ok('Tie::Hash::Sorted::XS') };
7
8tie my %hash, 'Tie::Hash::Sorted::XS';
9
10$hash{Jim} = 5;
11$hash{Bob} = 3;
12$hash{Anna} = 7;
13
14my $keys = join ' ', keys %hash;
15
16is $keys, 'Anna Bob Jim', 'keys are ordered';
17is $hash{Bob}, 3, 'retrieval works';
18
19
20tie my %refhash, 'Tie::Hash::Sorted::XS', Tree::SizeBalanced::any_int->new(sub { $$a <=> $$b });
21$refhash{\5} = 1;
22my $three = 3;
23$refhash{\$three} = 2;
24my $tworef = \2;
25$refhash{$tworef} = 3;
26
27my $values = '';
28for (keys %refhash) {
29 $values .= $refhash{$_} . ' ';
30}
31chop $values;
32
33my @keys = keys %refhash;
34is ref($keys[0]), 'SCALAR', 'non-string keys work';
35is $values, '3 2 1', 'values of refhash'
This page took 0.011463 seconds and 4 git commands to generate.