Skip to content

Commit

Permalink
Boost bit ops test coverage to 46%
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Otto <christoph_git@mksig.org>
  • Loading branch information
nolanlum authored and cotto committed Jan 2, 2011
1 parent 8946a18 commit fa70a1a
Showing 1 changed file with 143 additions and 2 deletions.
145 changes: 143 additions & 2 deletions t/dynoplibs/bit.t
Expand Up @@ -21,17 +21,21 @@ number types.
.sub main :main
.include 'test_more.pir'

plan(56)
plan(98)

bnot_p_p_creates_destination()
band_1()
bands_null_string()
bands_2()
bands_3()
bands_4()
bands_cow()
bor_1()
bors_null_string()
bors_2()
bors_3()
bors_cow()
shl_1()
bxors_null_string()
bxors_2()
bxors_3()
Expand All @@ -46,7 +50,43 @@ number types.
.sub 'bnot_p_p_creates_destination'
$P0 = box 3
$P1 = bnot $P0
is( $P1, -4, 'bnot_p_p_creates_destination')
is( $P1, -4, 'bnot_p_p_creates_destination' )
.end

.sub band_1
$P0 = new['Integer']
$P0 = 3
$I0 = 8
band $P0, $I0
is( $P0, 0, 'band_p_i' )
is( $I0, 8, 'band_p_i' )

$P0 = 3
band $P0, 8
is( $P0, 0, 'band_p_ic' )

$P0 = 3
$P1 = new ['Integer']
$P1 = 1
band $P0, $P1
is( $P0, 1, 'band_p_p' )
is( $P1, 1, 'band_p_p' )

$I0 = 3
band $P0, $P0, $I0
is( $P0, 1, 'band_p_p_i' )
is( $I0, 3, 'band_p_p_i' )

band $P0, $P0, 3
is( $P0, 1, 'band_p_p_ic' )

$P0 = 4
$P1 = 3
$P2 = new ['Integer']
band $P2, $P0, $P1
is( $P0, 4, 'band_p_p_p' )
is( $P1, 3, 'band_p_p_p' )
is( $P2, 0, 'band_p_p_p' )
.end

.sub bands_null_string
Expand Down Expand Up @@ -77,6 +117,12 @@ number types.
$S1 = bands $S1, $S2
is( $S1, "A@", 'bands 2' )
is( $S2, "EE", 'bands 2' )

$S1 = bands "abc", $S2
is( $S1, "A@", 'bands 2' )

$S2 = bands "abc", "EE"
is( $S2, "A@", 'bands 2' )
.end

.sub bands_3
Expand All @@ -88,13 +134,70 @@ number types.
is( $S2, "EE", 'bands 3' )
.end

.sub bands_4
$P0 = box "abc"
$P1 = new ['String']
$S0 = "EE"
bands $P1, $P0, $S0
is( $P1, "A@", 'bands 4' )
is( $P0, "abc", 'bands 4' )
is( $S0, "EE", 'bands 4' )

$P1 = bands $P0, "EE"
is( $P1, "A@", 'bands 4' )
is( $P0, "abc", 'bands 4' )

$P0 = box "abc"
$S0 = "EE"
bands $P0, $S0
is( $P0, "A@", 'bands 4' )
is( $S0, "EE", 'bands 4' )

$P0 = box "abc"
bands $P0, "EE"
is( $P0, "A@", 'bands 4' )
.end

.sub bands_cow
set $S1, "foo"
substr $S2, $S1, 0, 3
$S1 = bands $S1, "bar"
is( $S2, "foo", 'bands COW' )
.end

.sub bor_1
$P0 = new ['Integer']
$P1 = clone $P0
$P0 = 4
$P1 = 3
bor $P0, $P1
is( $P0, 7, 'bor_p_p' )
is( $P1, 3, 'bor_p_p' )

$P0 = 1
$I0 = 3
$P1 = new ['Integer']
bor $P1, $P0, $I0
is( $P0, 1, 'bor_p_p_i' )
is( $I0, 3, 'bor_p_p_i' )
is( $P1, 3, 'bor_p_p_i' )

$P0 = 1
$P1 = new ['Integer']
bor $P1, $P0, 2
is( $P0, 1, 'bor_p_p_ic' )
is( $P1, 3, 'bor_p_p_ic' )

$P0 = 1
$P1 = new ['Integer']
$P1 = 2
$P2 = new ['Integer']
bor $P2, $P0, $P1
is( $P0, 1, 'bor_p_p_p' )
is( $P1, 2, 'bor_p_p_p' )
is( $P2, 3, 'bor_p_p_p' )
.end

.sub bors_null_string
null $S1
null $S2
Expand Down Expand Up @@ -147,6 +250,15 @@ number types.
$S1 = bors $S1, $S2
is( $S1, "egc", 'bors 2' )
is( $S2, "EE", 'bors 2' )

$P0 = box "abc"
bors $P0, $S2
is( $P0, "egc", 'bors_p_s' )
is( $S2, "EE", 'bors_p_s' )

$P0 = box "abc"
bors $P0, "EE"
is( $P0, "egc", 'bors_p_sc' )
.end

.sub bors_3
Expand All @@ -156,6 +268,27 @@ number types.
is( $S0, "egc", 'bors 3' )
is( $S1, "abc", 'bors 3' )
is( $S2, "EE", 'bors 3' )

set $S0, "abc"
bors $S0, "EE", $S0
is( $S0, "egc", 'bors_s_sc_s' )

bors $S0, "abc", "EE"
is( $S0, "egc", 'bors_s_sc_sc' )

new $P0, ['String']
box $P1, "abc"
set $S0, "EE"
bors $P0, $P1, $S0
is( $P0, "egc", 'bors_p_p_s' )
is( $P1, "abc", 'bors_p_p_s' )
is( $S0, "EE", 'bors_p_p_s' )

set $P0, ""
box $P1, "abc"
bors $P0, $P1, "EE"
is( $P0, "egc", 'bors_p_p_sc' )
is( $P1, "abc", 'bors_p_p_sc' )
.end

.sub bors_cow
Expand All @@ -165,6 +298,14 @@ number types.
is( $S2, "foo", 'bors COW' )
.end

.sub shl_1
$P0 = new ['Integer']
$P0 = 1
$I0 = 1
shl $P0, $I0
is( $P0, 2, 'shl_p_i' )
.end

.sub bxors_null_string
null $S1
null $S2
Expand Down

0 comments on commit fa70a1a

Please sign in to comment.