# basic OO tests
my $ooimg = Imager->new(xsize=>200, ysize=>201, bits=>'double');
ok($ooimg, "couldn't make double image");
-ok($ooimg->bits eq 'double', "oo didn't give double image");
+is($ooimg->bits, 'double', "oo didn't give double image");
# check that the image is copied correctly
my $oocopy = $ooimg->copy;
ok($img, "paletted image created");
-ok($img->type eq 'paletted', "got a paletted image");
+is($img->type, 'paletted', "got a paletted image");
my $black = Imager::Color->new(0,0,0);
my $red = Imager::Color->new(255,0,0);
# draw on the image, make sure it stays paletted when it should
ok($img->box(color=>$red, filled=>1), "fill with red");
-ok($img->type eq 'paletted', "paletted after fill");
+is($img->type, 'paletted', "paletted after fill");
ok($img->box(color=>$green, filled=>1, xmin=>10, ymin=>10,
xmax=>40, ymax=>40), "green box");
-ok($img->type eq 'paletted', 'still paletted after box');
+is($img->type, 'paletted', 'still paletted after box');
# an AA line will almost certainly convert the image to RGB, don't use
# an AA line here
ok($img->line(color=>$blue, x1=>10, y1=>10, x2=>40, y2=>40),
"draw a line");
-ok($img->type eq 'paletted', 'still paletted after line');
+is($img->type, 'paletted', 'still paletted after line');
# draw with white - should convert to direct
ok($img->box(color=>$white, filled=>1, xmin=>20, ymin=>20,
xmax=>30, ymax=>30), "white box");
-ok($img->type eq 'direct', "now it should be direct");
+is($img->type, 'direct', "now it should be direct");
# various attempted to make a paletted image from our now direct image
my $palimg = $img->to_paletted;
ok(Imager::i_writeppm_wiol($im, $IO8), "write to cb");
# I originally compared this to $data, but that doesn't include the
# Imager header
-ok($work eq $data2, "write image match");
+is($work, $data2, "write image match");
ok($did_close, "did close");
# with a short buffer, no closer
$pos = 0;
$work = '';
ok(Imager::i_writeppm_wiol($im, $IO9), "write to short cb");
-ok($work eq $data2, "short write image match");
+is($work, $data2, "short write image match");
{
my $buf_data = "Test data";
# paletted reads
my $img4 = Imager->new;
ok($img4->read(file=>'testimg/comp4.tif'), "reading 4-bit paletted");
- ok($img4->type eq 'paletted', "image isn't paletted");
+ is($img4->type, 'paletted', "image isn't paletted");
print "# colors: ", $img4->colorcount,"\n";
- ok($img4->colorcount <= 16, "more than 16 colors!");
+ cmp_ok($img4->colorcount, '<=', 16, "more than 16 colors!");
#ok($img4->write(file=>'testout/t106_was4.ppm'),
# "Cannot write img4");
# I know I'm using BMP before it's test, but comp4.tif started life
ok($diff == 0, "image mismatch");
my $img8 = Imager->new;
ok($img8->read(file=>'testimg/comp8.tif'), "reading 8-bit paletted");
- ok($img8->type eq 'paletted', "image isn't paletted");
+ is($img8->type, 'paletted', "image isn't paletted");
print "# colors: ", $img8->colorcount,"\n";
#ok($img8->write(file=>'testout/t106_was8.ppm'),
# "Cannot write img8");
ok($cmp8->read(file=>'testout/t106_pal8.tif'),
"reading 8-bit paletted");
#print "# ",$cmp8->errstr,"\n";
- ok($cmp8->type eq 'paletted', "pal8 isn't paletted");
- ok($cmp8->colorcount == 256, "pal8 bad colorcount");
+ is($cmp8->type, 'paletted', "pal8 isn't paletted");
+ is($cmp8->colorcount, 256, "pal8 bad colorcount");
$diff = i_img_diff($img8->{IMG}, $cmp8->{IMG});
print "# diff $diff\n";
ok($diff == 0, "written image doesn't match read");
ok($img4->write(file=>'testout/t106_pal4.tif'), "writing 4-bit paletted");
ok(my $cmp4 = Imager->new->read(file=>'testout/t106_pal4.tif'),
"reading 4-bit paletted");
- ok($cmp4->type eq 'paletted', "pal4 isn't paletted");
- ok($cmp4->colorcount == 16, "pal4 bad colorcount");
+ is($cmp4->type, 'paletted', "pal4 isn't paletted");
+ is($cmp4->colorcount, 16, "pal4 bad colorcount");
$diff = i_img_diff($img4->{IMG}, $cmp4->{IMG});
print "# diff $diff\n";
ok($diff == 0, "written image doesn't match read");
\&io_closer);
ok($IO4, "new writecb obj");
ok(i_writetiff_wiol($img, $IO4), "write to cb");
- ok($work eq $odata, "write cb match");
+ is($work, $odata, "write cb match");
ok($did_close, "write cb did close");
open D1, ">testout/d1.tiff" or die;
print D1 $work;
\&io_closer, 1);
ok($IO5, "new writecb obj 2");
ok(i_writetiff_wiol($img, $IO5), "write to cb2");
- ok($work eq $odata, "write cb2 match");
+ is($work, $odata, "write cb2 match");
ok($did_close, "write cb2 did close");
open D3, ">testout/d3.tiff" or die;
ok(i_img_diff($imgs[$i]{IMG}, $out[$i]{IMG}) == 0,
"comparing image $i");
my ($tag) = $out[$i]->tags(name=>'tiff_pagename');
- ok($tag eq "Page ".($i+1),
+ is($tag, "Page ".($i+1),
"tag doesn't match original image");
}
"compare second fax image");
my ($format) = $imgs[0]->tags(name=>'i_format');
- ok(defined $format && $format eq 'tiff', "check i_format tag");
+ is($format, 'tiff', "check i_format tag");
my $unit = $imgs[0]->tags(name=>'tiff_resolutionunit');
ok(defined $unit && $unit == 2, "check tiff_resolutionunit tag");
my $unitname = $imgs[0]->tags(name=>'tiff_resolutionunit_name');
- ok(defined $unitname && $unitname eq 'inch',
- "check tiff_resolutionunit_name tag");
+ is($unitname, 'inch', "check tiff_resolutionunit_name tag");
my $warned = Imager->new;
ok($warned->read(file=>"testimg/tiffwarn.tif"), "read tiffwarn.tif");
# names
my $face_name = Imager::i_t1_face_name($font->{id});
print "# face $face_name\n";
- ok($face_name eq 'ExistenceTest', "face name");
+ is($face_name, 'ExistenceTest', "face name");
$face_name = $font->face_name;
- ok($face_name eq 'ExistenceTest', "face name");
+ is($face_name, 'ExistenceTest', "face name");
my @glyph_names = $font->glyph_names(string=>"!J/");
is($glyph_names[0], 'exclam', "check exclam name OO");
my $face_name = Imager::i_tt_face_name($hcfont->{id});
print "# face $face_name\n";
- ok($face_name eq 'ExistenceTest', "face name");
+ is($face_name, 'ExistenceTest', "face name (function)");
$face_name = $hcfont->face_name;
- ok($face_name eq 'ExistenceTest', "face name");
+ is($face_name, 'ExistenceTest', "face name (OO)");
# FT 1.x cheats and gives names even if the font doesn't have them
my @glyph_names = $hcfont->glyph_names(string=>"!J/");
- ok($glyph_names[0] eq 'exclam', "check exclam name OO");
+ is($glyph_names[0], 'exclam', "check exclam name OO");
ok(!defined($glyph_names[1]), "check for no J name OO");
- ok($glyph_names[2] eq 'slash', "check slash name OO");
+ is($glyph_names[2], 'slash', "check slash name OO");
print "# ** name table of the test font **\n";
Imager::i_tt_dump_names($hcfont->{id});
ok($font->utf8, "make sure utf8 method returns true");
my $has_chars = $font->has_chars(string=>"\x01A");
- ok($has_chars eq "\x00\x01", "has_chars scalar");
+ is($has_chars, "\x00\x01", "has_chars scalar");
my @has_chars = $font->has_chars(string=>"\x01A");
ok(!$has_chars[0], "has_chars list 0");
ok($has_chars[1], "has_chars list 1");
ok(@got == 2, "has_chars returned 2 items");
ok(!$got[0], "have no chr(1)");
ok($got[1], "have 'H'");
- ok($oof->has_chars(string=>"H\x01") eq "\x01\x00",
+ is($oof->has_chars(string=>"H\x01"), "\x01\x00",
"scalar has_chars()");
print "# OO bounding boxes\n";
if (Imager::Font::FreeType2::i_ft2_can_face_name()) {
my $facename = Imager::Font::FreeType2::i_ft2_face_name($exfont->{id});
print "# face name '$facename'\n";
- ok($facename eq 'ExistenceTest', "test face name");
+ is($facename, 'ExistenceTest', "test face name");
$facename = $exfont->face_name;
- ok($facename eq 'ExistenceTest', "test face name OO");
+ is($facename, 'ExistenceTest', "test face name OO");
}
else {
# make sure we get the error we expect