/[Redis.pre-github]/t/01-Redis.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /t/01-Redis.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 51 by dpavlin, Mon Mar 23 11:44:25 2009 UTC revision 57 by dpavlin, Wed Jun 17 16:19:17 2009 UTC
# Line 21  diag "Commands operating on string value Line 21  diag "Commands operating on string value
21    
22  ok( $o->set( foo => 'bar' ), 'set foo => bar' );  ok( $o->set( foo => 'bar' ), 'set foo => bar' );
23    
24  eval { $o->set( foo => 'bar', 1 ) };  ok( ! $o->setnx( foo => 'bar' ), 'setnx foo => bar fails' );
 ok( $@, 'set foo => bar new again failed' );  
25    
26  cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );  cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );
27    
# Line 50  is_deeply( [ $o->mget( 'foo', 'key-next' Line 49  is_deeply( [ $o->mget( 'foo', 'key-next'
49    
50  my @keys;  my @keys;
51    
52  foreach ( 0 .. $key_next ) {  foreach my $id ( 0 .. $key_next ) {
53          my $key = 'key-' . $_;          my $key = 'key-' . $id;
54          push @keys, $key;          push @keys, $key;
55          ok(     $o->set( $key => $_ ),           "set $key" );          ok(     $o->set( $key => $id ),           "set $key" );
56          ok(  $o->exists( $key       ),           "exists $key" );          ok(  $o->exists( $key       ),           "exists $key" );
57          cmp_ok( $o->get( $key       ), 'eq', $_, "get $key" );          cmp_ok( $o->get( $key       ), 'eq', $id, "get $key" );
58          cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );          cmp_ok( $o->incr( 'key-next' ), '==', $id + 1, 'incr' );
59          cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );          cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $id - 1, 'decr' );
60  }  }
61    
62  cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );  cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
# Line 65  cmp_ok( $o->get( 'key-next' ), '==', $ke Line 64  cmp_ok( $o->get( 'key-next' ), '==', $ke
64  ok( $o->set('test-incrby', 0), 'test-incrby' );  ok( $o->set('test-incrby', 0), 'test-incrby' );
65  ok( $o->set('test-decrby', 0), 'test-decry' );  ok( $o->set('test-decrby', 0), 'test-decry' );
66  foreach ( 1 .. 3 ) {  foreach ( 1 .. 3 ) {
67          cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );          cmp_ok( $o->incrby('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
68          cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );          cmp_ok( $o->decrby('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
69  }  }
70    
71  ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' );  ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' );
# Line 139  cmp_ok( $o->scard( $set ), '==', 0, 'sca Line 138  cmp_ok( $o->scard( $set ), '==', 0, 'sca
138  $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );  $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );
139  $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );  $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );
140    
141  my $inter = [ 'baz', 'foo' ];  my $inter = [ 'foo', 'baz' ];
142    
143  is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );  is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );
144    

Legend:
Removed from v.51  
changed lines
  Added in v.57

  ViewVC Help
Powered by ViewVC 1.1.26