Changeset 5d8c9a7


Ignore:
Timestamp:
Jun 14, 2013, 7:39:23 PM (4 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master
Children:
f20daff
Parents:
2497f99
git-author:
David Benjamin <davidben@mit.edu> (06/04/13 19:50:15)
git-committer:
David Benjamin <davidben@mit.edu> (06/14/13 19:39:23)
Message:
Make the fullvar variable test more reasonable

Calling set on the output of get really should a no-op. Also test that
the new version of the setters were installed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • t/variable.t

    r2497f99 r5d8c9a7  
    6868BarnOwl::new_variable_full("fullvar", {
    6969    validsettings => '<short-words>',
    70     get_tostring => sub { "value is " . $value },
     70    get_tostring => sub { $value },
    7171    set_fromstring => sub {
    7272        die "Too long" unless $_[0] =~ /^...?$/;
    73         $value = $_[0];
     73        $value = lc($_[0]);
    7474    },
    7575    takes_on_off => 1
    7676});
    77 is(BarnOwl::getvar("fullvar"), "value is foo", "fullvar get");
    78 BarnOwl::set("-q", "fullvar", "bar");
    79 is(BarnOwl::getvar("fullvar"), "value is bar", "fullvar set");
     77is(BarnOwl::getvar("fullvar"), "foo", "fullvar get");
     78BarnOwl::set("-q", "fullvar", "Bar");
     79is(BarnOwl::getvar("fullvar"), "bar", "fullvar set");
    8080BarnOwl::set("-q", "fullvar");
    81 is(BarnOwl::getvar("fullvar"), "value is on", "fullvar set2");
     81is(BarnOwl::getvar("fullvar"), "on", "fullvar set2");
    8282BarnOwl::unset("-q", "fullvar");
    83 is(BarnOwl::getvar("fullvar"), "value is off", "fullvar unset");
     83is(BarnOwl::getvar("fullvar"), "off", "fullvar unset");
    8484BarnOwl::set("-q", "fullvar", "bogus");
    85 is(BarnOwl::getvar("fullvar"), "value is off", "fullvar set bogus");
    86 $value = "something really long";
    87 is(BarnOwl::getvar("fullvar"), "value is something really long", "fullvar set out-of-band");
     85is(BarnOwl::getvar("fullvar"), "off", "fullvar set bogus");
     86$value = "xyz";
     87is(BarnOwl::getvar("fullvar"), "xyz", "fullvar set out-of-band");
    8888# Kinda verbose, but better to test all forms
    89 my $value = "foo";
     89my $newvalue = "foo";
    9090BarnOwl::new_variable_full("fullvar", {
    9191    validsettings => '<short-words>',
    92     get_tostring => sub { "value is " . $value },
     92    get_tostring => sub { $newvalue },
    9393    set_fromstring => sub {
    9494        die "Too long" unless $_[0] =~ /^...?$/;
    95         $value = $_[0];
     95        $newvalue = lc($_[0]);
    9696    },
    9797    takes_on_off => 1
    9898});
    99 isnt(BarnOwl::getvar("fullvar"), "value is foo", "fullvar reinit doesn't override value");
     99is(BarnOwl::getvar("fullvar"), "xyz", "fullvar reinit doesn't override value");
     100$newvalue = "abc";
     101is(BarnOwl::getvar("fullvar"), "abc", "fullvar reinit changed setters");
    100102
    1011031;
Note: See TracChangeset for help on using the changeset viewer.