Changeset 590466b


Ignore:
Timestamp:
Jun 4, 2013, 7:19:44 PM (9 years ago)
Author:
Robert Jacobs <rnjacobs@mit.edu>
Children:
3247e21
Parents:
d555aa1
Message:
Add tests to detect new_variable_* overriding previously set values
File:
1 edited

Legend:

Unmodified
Added
Removed
  • t/variable.t

    r4953c44 r590466b  
    1717BarnOwl::unset("-q", "intvar");
    1818is(BarnOwl::getvar("intvar"), "24", "intvar unset bogus");
     19BarnOwl::new_variable_int("intvar", { default => 7 });
     20isnt(BarnOwl::getvar("intvar"), "7", "intvar reinit shouldn't override preexisting value");
    1921
    2022BarnOwl::new_variable_bool("boolvar", { default => 1 });
     
    2830BarnOwl::unset("-q", "boolvar");
    2931is(BarnOwl::getvar("boolvar"), "off", "boolvar unset");
     32BarnOwl::new_variable_bool("boolvar", { default => 1 });
     33isnt(BarnOwl::getvar("boolvar"), "on", "boolvar reinit shouldn't override preexisting value");
    3034
    3135BarnOwl::new_variable_string("strvar", { default => "monkey" });
     
    3741BarnOwl::unset("-q", "strvar");
    3842is(BarnOwl::getvar("strvar"), "cuttlefish", "strvar unset bogus");
     43BarnOwl::new_variable_string("strvar", { default => "monkey" });
     44isnt(BarnOwl::getvar("strvar"), "monkey", "strvar reinit overrode set value");
    3945
    4046BarnOwl::new_variable_enum("enumvar", { validsettings => [qw/foo bar baz/], default => "bar" });
     
    4652BarnOwl::unset("-q", "enumvar");
    4753is(BarnOwl::getvar("enumvar"), "baz", "enumvar unset bogus");
     54BarnOwl::new_variable_enum("enumvar", { validsettings => [qw/foo bar baz/], default => "bar" });
     55isnt(BarnOwl::getvar("enumvar"), "bar", "enumvar reinit overrode set value");
    4856
    4957BarnOwl::new_variable_int("intvar2");
     
    7886$value = "something really long";
    7987is(BarnOwl::getvar("fullvar"), "value is something really long", "fullvar set out-of-band");
     88# Kinda verbose, but better to test all forms
     89my $value = "foo";
     90BarnOwl::new_variable_full("fullvar", {
     91    validsettings => '<short-words>',
     92    get_tostring => sub { "value is " . $value },
     93    set_fromstring => sub {
     94        die "Too long" unless $_[0] =~ /^...?$/;
     95        $value = $_[0];
     96    },
     97    takes_on_off => 1
     98});
     99isnt(BarnOwl::getvar("fullvar"), "value is foo", "fullvar reinit overrode set value");
    80100
    811011;
Note: See TracChangeset for help on using the changeset viewer.