File: 02-FF-Value-Default.t

package info (click to toggle)
libwww-mechanize-formfiller-perl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 292 kB
  • ctags: 46
  • sloc: perl: 1,504; sh: 6; makefile: 2
file content (50 lines) | stat: -rwxr-xr-x 1,134 bytes parent folder | download | duplicates (6)
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
40
41
42
43
44
45
46
47
48
49
50
use strict;

my @values;
BEGIN {
  @values = (
    ["foo","","foo"],
    [1,"",1],
    ["","",""],
    [0,"",0],
    [undef,"",undef],

    ["foo","foo","foo"],
    [1,"foo","foo"],
    ["","foo","foo"],
    [0,"foo","foo"],
    [undef,"foo","foo"],

    ["foo",1,1],
    [1,1,1],
    ["",1,1],
    [0,1,1],
    [undef,1,1],

    ["foo",0,0],
    [1,0,0],
    ["",0,0],
    [0,0,0],
    [undef,0,0],
  );
};

use Test::More tests => 1 + scalar @values * 3;

use_ok("WWW::Mechanize::FormFiller::Value::Default");
SKIP: {
  eval { require Test::MockObject };
  skip "Need Test::MockObject to do tests on values", scalar @values *3 if $@;

  for my $row (@values) {
    my ($value,$form_value,$expected) = @$row;

    my $input = Test::MockObject->new()->set_always('value',$form_value);

    my $v = WWW::Mechanize::FormFiller::Value::Default->new("foo",$value);
    isa_ok($v,"WWW::Mechanize::FormFiller::Value::Default");
    can_ok($v,"value");
    my $pvalue = $value || "";
    is($v->value($input),$expected,"Fixed returns the correct value for ('$pvalue'/'$form_value')");
  };
};