File: rt-54167.t

package info (click to toggle)
libyaml-syck-perl 1.20-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 932 kB
  • sloc: ansic: 3,987; perl: 3,387; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env perl

use warnings;
use strict;

use Test::More tests => 2;

use YAML::Syck;

my $some_hashref = { a => 1, b => 2 };
my $expected_iterations = scalar keys %$some_hashref;

is(
  count_each_iterations($some_hashref),
  $expected_iterations,
  "each() iterates properly before YAML::Syck::Dump",
);

# Perform the Dump.
my $some_yaml_dump = YAML::Syck::Dump($some_hashref);

is(
  count_each_iterations($some_hashref),
  $expected_iterations,
  "each() iterates properly after YAML::Syck::Dump",
);

exit;

sub count_each_iterations {
  my $hashref = shift;

  my $iterations = 0;
  while (my ($k, $v) = each %$hashref) {
    $iterations++;
  }

  return $iterations;
}