Changeset 9676


Ignore:
Timestamp:
12/14/09 00:53:50 (2 years ago)
Author:
szabgab
Message:

[Debug::Client] add some documentation and TODO tests

Location:
trunk/Debug-Client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Debug-Client/lib/Debug/Client.pm

    r9675 r9676  
    3939  $debugger->run( 'foo' );  # tun till beginning of sub 
    4040 
    41   $debugger->execute_code 
    42  
     41  $debugger->execute_code( '$answer = 42' ); 
     42 
     43  $debugger->execute_code( '@name = qw(foo bar)' ); 
     44 
     45  my ($value, $prompt) = $debugger->get_value('@name');  $value is the dumped data? 
     46 
     47  $debugger->execute_code( '%phone_book = (foo => 123, bar => 456)' ); 
     48 
     49  my ($value, $prompt) = $debugger->get_value('%phone_book');  $value is the dumped data? 
     50   
     51   
    4352  $debugger->set_breakpoint( "file", 23 ); #    set breakpoint on file, line 
    4453 
     
    7887                   Reuse     => 1); 
    7988    $sock or die "Could not connect to '$args{host}' '$args{port}' no socket :$!"; 
    80     logger("listening on '$args{host}:$args{port}'"); 
     89    _logger("listening on '$args{host}:$args{port}'"); 
    8190    $self->{sock} = $sock; 
    8291 
     
    105114} 
    106115 
     116=head2 quit 
     117 
     118=cut 
     119 
     120sub quit      { $_[0]->_send('q')    } 
     121 
     122=head2 show_line 
     123 
     124=cut 
     125 
     126sub show_line { $_[0]->send_get('.') } 
     127 
     128 
     129=head2 step_in 
     130 
     131=cut 
     132 
    107133sub step_in   { $_[0]->send_get('s') } 
     134 
     135=head2 step_over 
     136 
     137=cut 
     138 
    108139sub step_over { $_[0]->send_get('n') } 
    109 sub quit      { $_[0]->_send('q')    } 
    110 sub show_line { $_[0]->send_get('.') } 
    111  
    112 sub get_stack_trace { 
    113     my ($self) = @_; 
    114     $self->_send('T'); 
    115     my $buf = $self->_get; 
    116  
    117     if (wantarray) { 
    118         my $prompt = _prompt(\$buf); 
    119         return($buf, $prompt); 
    120     } else { 
    121         return $buf; 
    122     } 
    123 } 
    124  
    125  
    126  
    127 sub run       {  
    128     my ($self, $param) = @_; 
    129     if (not defined $param) { 
    130         $self->send_get('c'); 
    131     } else { 
    132         $self->send_get("c $param"); 
    133     } 
    134 } 
     140 
     141=head2 step_out 
     142 
     143=cut 
    135144 
    136145sub step_out  {  
     
    167176} 
    168177 
     178 
     179=head2 get_stack_trace 
     180 
     181=cut 
     182 
     183sub get_stack_trace { 
     184    my ($self) = @_; 
     185    $self->_send('T'); 
     186    my $buf = $self->_get; 
     187 
     188    if (wantarray) { 
     189        my $prompt = _prompt(\$buf); 
     190        return($buf, $prompt); 
     191    } else { 
     192        return $buf; 
     193    } 
     194} 
     195 
     196=head2 run 
     197 
     198=cut 
     199sub run       {  
     200    my ($self, $param) = @_; 
     201    if (not defined $param) { 
     202        $self->send_get('c'); 
     203    } else { 
     204        $self->send_get("c $param"); 
     205    } 
     206} 
     207 
     208 
     209=head2 set_breakpoint 
     210 
     211=cut 
     212 
    169213#  TODO: Line 15 not breakable. 
    170214sub set_breakpoint { 
     
    185229} 
    186230 
     231=head2 execute_code 
     232 
     233=cut 
    187234 
    188235sub execute_code { 
     
    199246} 
    200247 
     248=head2 get_value 
     249 
     250=cut 
     251 
     252# TODO if the given $x is a reference then something (either this module 
     253# or its user) should actually call   x $var  
    201254sub get_value { 
    202255    my ($self, $var) = @_; 
     
    227280 
    228281sub _parse_dumper { 
    229     my ($str) = @_;     
     282    my ($str) = @_; 
     283    return $str; 
    230284} 
    231285 
     
    242296            die $!; # TODO better error handling? 
    243297        } 
    244         logger("---- ret '$ret'\n$buf\n---"); 
     298        _logger("---- ret '$ret'\n$buf\n---"); 
    245299        if (not $ret) { 
    246300            last; 
    247301        } 
    248302    } 
    249     logger("_get done"); 
     303    _logger("_get done"); 
    250304 
    251305    $self->{buffer} = $buf; 
     
    307361} 
    308362 
    309 sub logger { 
     363sub _logger { 
    310364    print "$_[0]\n" if $ENV{DEBUG_LOGGER}; 
    311365} 
  • trunk/Debug-Client/t/05-execute.t

    r9659 r9676  
    1212my $D = re('\d+'); 
    1313 
    14 plan(tests => 10); 
     14our $TODO; # needed becasue Test::More is required and not used 
     15 
     16plan(tests => 13); 
    1517 
    1618my $debugger = start_debugger(); 
     
    5860} 
    5961 
    60 # TODO check the get_value on hash and array 
    61 #{ 
    62 #    my @out = $debugger->get_value('@qwe'); 
    63 #    cmp_deeply(\@out, [23, 42, $D], 'execute 1') 
    64 #        or diag($debugger->buffer); 
    65 #} 
     62TODO: { 
     63    local $TODO = 'get_value of array'; 
     64    my @out = $debugger->get_value('@qwe'); 
     65    cmp_deeply(\@out, [23, 42, $D], 'get_value of array') 
     66        or diag($debugger->buffer); 
     67} 
     68 
     69{ 
     70    my @out = $debugger->execute_code('%h = (fname => "foo", lname => "bar")'); 
     71    cmp_deeply(\@out, ['', $D], 'execute 3') 
     72        or diag($debugger->buffer); 
     73} 
     74 
     75TODO: { 
     76    local $TODO = 'get_value of hash'; 
     77    my @out = $debugger->get_value('%h'); 
     78    cmp_deeply(\@out, [$D], 'get_value of hash') 
     79        or diag($debugger->buffer); 
     80} 
     81 
    6682 
    6783{ 
Note: See TracChangeset for help on using the changeset viewer.