--- t/01-Redis.t 2009/03/23 11:44:25 51 +++ t/01-Redis.t 2009/06/17 16:19:17 57 @@ -21,8 +21,7 @@ ok( $o->set( foo => 'bar' ), 'set foo => bar' ); -eval { $o->set( foo => 'bar', 1 ) }; -ok( $@, 'set foo => bar new again failed' ); +ok( ! $o->setnx( foo => 'bar' ), 'setnx foo => bar fails' ); cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' ); @@ -50,14 +49,14 @@ my @keys; -foreach ( 0 .. $key_next ) { - my $key = 'key-' . $_; +foreach my $id ( 0 .. $key_next ) { + my $key = 'key-' . $id; push @keys, $key; - ok( $o->set( $key => $_ ), "set $key" ); + ok( $o->set( $key => $id ), "set $key" ); ok( $o->exists( $key ), "exists $key" ); - cmp_ok( $o->get( $key ), 'eq', $_, "get $key" ); - cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' ); - cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' ); + cmp_ok( $o->get( $key ), 'eq', $id, "get $key" ); + cmp_ok( $o->incr( 'key-next' ), '==', $id + 1, 'incr' ); + cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $id - 1, 'decr' ); } cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' ); @@ -65,8 +64,8 @@ ok( $o->set('test-incrby', 0), 'test-incrby' ); ok( $o->set('test-decrby', 0), 'test-decry' ); foreach ( 1 .. 3 ) { - cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' ); - cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' ); + cmp_ok( $o->incrby('test-incrby', 3), '==', $_ * 3, 'incrby 3' ); + cmp_ok( $o->decrby('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' ); } ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' ); @@ -139,7 +138,7 @@ $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' ); $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' ); -my $inter = [ 'baz', 'foo' ]; +my $inter = [ 'foo', 'baz' ]; is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );