BEGIN { $| = 1; print "1..25\n"; }

# Test that we can load the module
END {print "not ok 1\n" unless $loaded;}
use Want;
$loaded = 1;
print "ok 1\n";

# Check the low-level want_boolean() routine

sub wb {
  my ($t, $w, $r) = @_;
  my $a = Want::want_boolean(0);
  print ($w == $a ? "ok $t\n" : "not ok $t\t# $a\n");
  return $r;
}

# Notice that the low-level want_boolean() routine returns true even
# in void context. want('BOOLEAN') is equivalent to (want_boolean && want('!VOID'))
wb(2, 1);

$x = (wb(3, 1, 1) && wb(4, 0));
if (wb(5, 1)) {}

$x = (wb(6, 1) ? 17 : 23);
$x = ($x ? wb(7, 0, 1) : die);

if ($x ? wb(8, 1, 1) : die) {
  print "ok 9\n";
}
else {
  print "not ok 9\n";
}

die unless wb(10, 1, 1);

if ((wb(11,1,1) && wb(12,1,0)) || wb(13, 1)) {
  ()= $x
}

wb((wb(14,1,1) && wb(15,0,0)) || wb(16, 0, 17), 1);


# Now check that want('BOOLEAN') is okay

sub wantt {
    my $t = shift();
    my $r = shift();
    print (Want::want(@_) ? "ok $t\n" : "not ok $t\n");
    $r
}

 wantt(18, 0, 'SCALAR', 'BOOLEAN', '!REF') ||
!wantt(19, 0, 'SCALAR', 'BOOLEAN', '!REF') || 1;

wantt(20, 0, '!BOOLEAN');
$x = wantt(21, 0, '!BOOLEAN');
@x = wantt(22, 0, qw'LIST !BOOLEAN');

$x = (wantt(23, 0, 'BOOLEAN') xor wantt(24, 0, 'BOOLEAN'));
$x = !(0 + wantt(25, 1, '!BOOLEAN'));
