summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/00use.t10
-rw-r--r--t/01item-text.t78
-rw-r--r--t/02item-richtext.t31
-rw-r--r--t/03item-richtext-formatting.t4
-rw-r--r--t/04item-margins.t138
-rw-r--r--t/10initial.t30
-rw-r--r--t/11scroll.t16
-rw-r--r--t/12resize-bottom.t4
-rw-r--r--t/12resize-top.t4
-rw-r--r--t/20push-bottom.t8
-rw-r--r--t/20push-top.t8
-rw-r--r--t/21shift-bottom.t8
-rw-r--r--t/21shift-top.t8
-rw-r--r--t/22unshift-bottom.t4
-rw-r--r--t/22unshift-top.t4
-rw-r--r--t/23pop-bottom.t4
-rw-r--r--t/23pop-top.t4
-rw-r--r--t/30indicator.t134
-rw-r--r--t/99pod.t4
19 files changed, 348 insertions, 153 deletions
diff --git a/t/00use.t b/t/00use.t
index cce1829..f1b8df7 100644
--- a/t/00use.t
+++ b/t/00use.t
@@ -1,10 +1,14 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
-use_ok( 'Tickit::Widget::Scroller' );
+require Tickit::Widget::Scroller;
+require Tickit::Widget::Scroller::Item::Text;
+require Tickit::Widget::Scroller::Item::RichText;
+
+pass( 'Modules loaded' );
done_testing;
diff --git a/t/01item-text.t b/t/01item-text.t
index ca5a5fe..900c8db 100644
--- a/t/01item-text.t
+++ b/t/01item-text.t
@@ -1,11 +1,12 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
+use Tickit::Pen;
use Tickit::RenderBuffer;
use Tickit::Widget::Scroller::Item::Text;
@@ -14,11 +15,11 @@ my $term = mk_term;
my $item = Tickit::Widget::Scroller::Item::Text->new( "My message here" );
-isa_ok( $item, "Tickit::Widget::Scroller::Item::Text", '$item' );
+isa_ok( $item, [ "Tickit::Widget::Scroller::Item::Text" ], '$item' );
-is_deeply( [ $item->chunks ],
- [ [ "My message here", 15 ] ],
- '$item->chunks' );
+is( [ $item->chunks ],
+ [ [ "My message here", 15 ] ],
+ '$item->chunks' );
is( $item->height_for_width( 80 ), 1, 'height_for_width 80' );
@@ -142,10 +143,10 @@ drain_termlog;
my $item = Tickit::Widget::Scroller::Item::Text->new( "Some more text\nwith linefeeds" );
- is_deeply( [ $item->chunks ],
- [ [ "Some more text", 14, linebreak => 1 ],
- [ "with linefeeds", 14 ] ],
- '$item->chunks with linefeeds' );
+ is( [ $item->chunks ],
+ [ [ "Some more text", 14, linebreak => 1 ],
+ [ "with linefeeds", 14 ] ],
+ '$item->chunks with linefeeds' );
is( $item->height_for_width( 80 ), 2, 'height_for_width 2 with linefeeds' );
@@ -180,9 +181,9 @@ drain_termlog;
my $item = Tickit::Widget::Scroller::Item::Text->new( "(ノಠ益ಠ)ノ彡┻━┻" );
- is_deeply( [ $item->chunks ],
- [ [ "(ノಠ益ಠ)ノ彡┻━┻", 15 ] ],
- '$item->chunks with Unicode' );
+ is( [ $item->chunks ],
+ [ [ "(ノಠ益ಠ)ノ彡┻━┻", 15 ] ],
+ '$item->chunks with Unicode' );
is( $item->height_for_width( 80 ), 1, 'height_for_width 2 with Unicode' );
@@ -202,4 +203,55 @@ drain_termlog;
'Display for render with Unicode' );
}
+# Empty
+{
+ $term->clear;
+ drain_termlog;
+
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "" );
+
+ is( [ $item->chunks ],
+ [ [ "", 0 ] ],
+ '$item->chunks for empty string' );
+
+ is( $item->height_for_width( 80 ), 1, 'height_for_width 1 for empty string' );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 0, width => 80, height => 1 );
+ $rb->flush_to_term( $term );
+
+ flush_tickit;
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN,
+ ERASECH(80) ],
+ 'Termlog for render for empty string' );
+
+ is_display( [ ],
+ 'Display for render for empty string' );
+}
+
+# With pen
+{
+ $term->clear;
+ drain_termlog;
+
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "Red with green BG",
+ pen => Tickit::Pen->new( fg => "red", bg => "green" )
+ );
+
+ $item->height_for_width( 80 );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 0, width => 80, height => 1 );
+ $rb->flush_to_term( $term );
+
+ flush_tickit;
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN(fg=>1,bg=>2),
+ PRINT("Red with green BG"),
+ SETPEN(fg=>1,bg=>2),
+ ERASECH(63) ],
+ 'Termlog for render with pen' );
+}
+
done_testing;
diff --git a/t/02item-richtext.t b/t/02item-richtext.t
index a081465..a1a8ffd 100644
--- a/t/02item-richtext.t
+++ b/t/02item-richtext.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test;
use Tickit::RenderBuffer;
@@ -21,14 +21,15 @@ $str->apply_tag( 11, 4, u => 1 );
my $item = Tickit::Widget::Scroller::Item::RichText->new( $str );
-isa_ok( $item, "Tickit::Widget::Scroller::Item::Text", '$item' );
+isa_ok( $item, [ "Tickit::Widget::Scroller::Item::Text" ], '$item' );
-is_deeply( [ $item->chunks ],
- [ [ "My ", 3, pen => Tickit::Pen->new() ],
- [ "message", 7, pen => Tickit::Pen->new( b => 1 ) ],
- [ " ", 1, pen => Tickit::Pen->new() ],
- [ "here", 4, pen => Tickit::Pen->new( u => 1 ) ] ],
- '$item->chunks' );
+is( [ $item->chunks ],
+ # Stringify the pens so Test2 will compare the stringified versions
+ [ [ "My ", 3, pen => "".Tickit::Pen->new() ],
+ [ "message", 7, pen => "".Tickit::Pen->new( b => 1 ) ],
+ [ " ", 1, pen => "".Tickit::Pen->new() ],
+ [ "here", 4, pen => "".Tickit::Pen->new( u => 1 ) ] ],
+ '$item->chunks' );
is( $item->height_for_width( 80 ), 1, 'height_for_width 80' );
@@ -63,12 +64,12 @@ is_display( [ [TEXT("My "), TEXT("message",b=>1), BLANK(1), TEXT("here",u=>1)] ]
my $item = Tickit::Widget::Scroller::Item::RichText->new( $str );
- is_deeply( [ $item->chunks ],
- [ [ "Another ", 8, pen => Tickit::Pen->new() ],
- [ "message", 7, pen => Tickit::Pen->new( b => 1 ), linebreak => 1 ],
- [ "with", 4, pen => Tickit::Pen->new( b => 1 ) ],
- [ " linefeeds", 10, pen => Tickit::Pen->new() ] ],
- '$item->chunks with linefeeds' );
+ is( [ $item->chunks ],
+ [ [ "Another ", 8, pen => "".Tickit::Pen->new() ],
+ [ "message", 7, pen => "".Tickit::Pen->new( b => 1 ), linebreak => 1 ],
+ [ "with", 4, pen => "".Tickit::Pen->new( b => 1 ) ],
+ [ " linefeeds", 10, pen => "".Tickit::Pen->new() ] ],
+ '$item->chunks with linefeeds' );
}
# Word wrapping on pen changes
diff --git a/t/03item-richtext-formatting.t b/t/03item-richtext-formatting.t
index 192ceec..b749dc6 100644
--- a/t/03item-richtext-formatting.t
+++ b/t/03item-richtext-formatting.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
plan skip_all => "Convert::Color::XTerm is not available"
unless eval { require Convert::Color::XTerm };
diff --git a/t/04item-margins.t b/t/04item-margins.t
new file mode 100644
index 0000000..9e80d65
--- /dev/null
+++ b/t/04item-margins.t
@@ -0,0 +1,138 @@
+#!/usr/bin/perl
+
+use v5.26;
+use warnings;
+
+use Test2::V0;
+
+use Tickit::Test 0.12;
+use Tickit::RenderBuffer;
+
+use Tickit::Widget::Scroller::Item::Text;
+
+my $term = mk_term;
+
+my $item = Tickit::Widget::Scroller::Item::Text->new( "My message here" );
+
+# margin_left
+{
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "ABCDE " x 10, margin_left => 5 );
+
+ is( $item->height_for_width( 40 ), 2, 'height_for_width 40' );
+
+ my $rb = Tickit::RenderBuffer->new( lines => $term->lines, cols => $term->cols );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 1, width => 40, height => 25 );
+ $rb->flush_to_term( $term );
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN,
+ ERASECH(5,1),
+ SETPEN,
+ PRINT("ABCDE "x5 . "ABCDE"),
+ GOTO(1,0),
+ SETPEN,
+ ERASECH(5,1),
+ SETPEN,
+ PRINT("ABCDE "x4),
+ SETPEN,
+ ERASECH(11) ],
+ 'Termlog for render margin_left' );
+
+ is_display( [ [TEXT(" ABCDE ABCDE ABCDE ABCDE ABCDE ABCDE")],
+ [TEXT(" ABCDE ABCDE ABCDE ABCDE")]],
+ 'Display for render margin_left' );
+}
+
+# margin_right
+{
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "ABCDE " x 10, margin_right => 5 );
+
+ is( $item->height_for_width( 40 ), 2, 'height_for_width 40' );
+
+ my $rb = Tickit::RenderBuffer->new( lines => $term->lines, cols => $term->cols );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 1, width => 40, height => 25 );
+ $rb->flush_to_term( $term );
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN,
+ PRINT("ABCDE "x5 . "ABCDE"),
+ SETPEN,
+ ERASECH(5),
+ GOTO(1,0),
+ SETPEN,
+ PRINT("ABCDE "x4),
+ SETPEN,
+ ERASECH(16) ],
+ 'Termlog for render margin_right' );
+
+ is_display( [ [TEXT("ABCDE ABCDE ABCDE ABCDE ABCDE ABCDE")],
+ [TEXT("ABCDE ABCDE ABCDE ABCDE")]],
+ 'Display for render margin_right' );
+}
+
+# margin sets both
+{
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "ABCDE " x 10, margin => 5 );
+
+ is( $item->height_for_width( 40 ), 2, 'height_for_width 40' );
+
+ my $rb = Tickit::RenderBuffer->new( lines => $term->lines, cols => $term->cols );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 1, width => 40, height => 25 );
+ $rb->flush_to_term( $term );
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN,
+ ERASECH(5,1),
+ SETPEN,
+ PRINT("ABCDE "x5),
+ SETPEN,
+ ERASECH(5),
+ GOTO(1,0),
+ SETPEN,
+ ERASECH(5,1),
+ SETPEN,
+ PRINT("ABCDE "x5),
+ SETPEN,
+ ERASECH(5) ],
+ 'Termlog for render margin' );
+
+ is_display( [ [TEXT(" ABCDE ABCDE ABCDE ABCDE ABCDE")],
+ [TEXT(" ABCDE ABCDE ABCDE ABCDE ABCDE")]],
+ 'Display for render margin' );
+}
+
+# margin excludes pen
+{
+ $term->clear;
+ drain_termlog;
+
+ my $item = Tickit::Widget::Scroller::Item::Text->new( "Red with green BG",
+ margin => 10,
+ pen => Tickit::Pen->new( fg => "red", bg => "green" )
+ );
+
+ $item->height_for_width( 80 );
+
+ my $rb = Tickit::RenderBuffer->new( lines => $term->lines, cols => $term->cols );
+
+ $item->render( $rb, top => 0, firstline => 0, lastline => 0, width => 80, height => 1 );
+ $rb->flush_to_term( $term );
+
+ flush_tickit;
+
+ is_termlog( [ GOTO(0,0),
+ SETPEN,
+ ERASECH(10,1),
+ SETPEN(fg=>1,bg=>2),
+ PRINT("Red with green BG"),
+ SETPEN(fg=>1,bg=>2),
+ ERASECH(43,1),
+ SETPEN,
+ ERASECH(10) ],
+ 'Termlog for render with pen and margin' );
+}
+
+done_testing;
diff --git a/t/10initial.t b/t/10initial.t
index e42d82f..be1d567 100644
--- a/t/10initial.t
+++ b/t/10initial.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test;
@@ -51,13 +51,13 @@ is_display( [ "The first line",
'Display initially' );
is( scalar $scroller->line2item( 0 ), 0, 'scalar line2item 0' );
-is_deeply( [ $scroller->line2item( 0 ) ], [ 0, 0 ], 'line2item 0' );
-is_deeply( [ $scroller->line2item( 1 ) ], [ 1, 0 ], 'line2item 1' );
-is_deeply( [ $scroller->line2item( 2 ) ], [ 2, 0 ], 'line2item 2' );
-is_deeply( [ $scroller->line2item( 3 ) ], [ ], 'line2item 3' );
+is( [ $scroller->line2item( 0 ) ], [ 0, 0 ], 'line2item 0' );
+is( [ $scroller->line2item( 1 ) ], [ 1, 0 ], 'line2item 1' );
+is( [ $scroller->line2item( 2 ) ], [ 2, 0 ], 'line2item 2' );
+is( [ $scroller->line2item( 3 ) ], [ ], 'line2item 3' );
-is_deeply( [ $scroller->line2item( -1 ) ], [ ], 'line2item -1' );
-is_deeply( [ $scroller->line2item( -23 ) ], [ 2, 0 ], 'line2item -23' );
+is( [ $scroller->line2item( -1 ) ], [ ], 'line2item -1' );
+is( [ $scroller->line2item( -23 ) ], [ 2, 0 ], 'line2item -23' );
is( $scroller->item2line( 0 ), 0, 'item2line 0' );
is( $scroller->item2line( 0, -1 ), 0, 'item2line 0, -1' );
@@ -97,14 +97,14 @@ is_display( [ "The first line",
"The third line" ],
'Display after narrowing' );
-is_deeply( [ $scroller->line2item( 0 ) ], [ 0, 0 ], 'line2item 0' );
-is_deeply( [ $scroller->line2item( 1 ) ], [ 1, 0 ], 'line2item 1' );
-is_deeply( [ $scroller->line2item( 2 ) ], [ 1, 1 ], 'line2item 2' );
-is_deeply( [ $scroller->line2item( 3 ) ], [ 2, 0 ], 'line2item 3' );
-is_deeply( [ $scroller->line2item( 4 ) ], [ ], 'line2item 4' );
+is( [ $scroller->line2item( 0 ) ], [ 0, 0 ], 'line2item 0' );
+is( [ $scroller->line2item( 1 ) ], [ 1, 0 ], 'line2item 1' );
+is( [ $scroller->line2item( 2 ) ], [ 1, 1 ], 'line2item 2' );
+is( [ $scroller->line2item( 3 ) ], [ 2, 0 ], 'line2item 3' );
+is( [ $scroller->line2item( 4 ) ], [ ], 'line2item 4' );
-is_deeply( [ $scroller->line2item( -1 ) ], [ ], 'line2item -1' );
-is_deeply( [ $scroller->line2item( -22 ) ], [ 2, 0 ], 'line2item -22' );
+is( [ $scroller->line2item( -1 ) ], [ ], 'line2item -1' );
+is( [ $scroller->line2item( -22 ) ], [ 2, 0 ], 'line2item -22' );
is( $scroller->item2line( 0 ), 0, 'item2line 0' );
is( $scroller->item2line( 0, -1 ), 0, 'item2line 0, -1' );
diff --git a/t/11scroll.t b/t/11scroll.t
index 0d97fb2..00ee609 100644
--- a/t/11scroll.t
+++ b/t/11scroll.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
@@ -62,8 +62,8 @@ is( $scroller->item2line( 1, -1 ), 3, 'item2line 1, -1 initially' );
is( $scroller->item2line( 2, 0 ), 4, 'item2line 2, 0 initially' );
is( $scroller->item2line( 2, -1 ), undef, 'item2line 2, -1 initially offscreen' );
-is_deeply( [ $scroller->item2line( 2, -1 ) ], [ undef, "below" ], 'list item2line 2, -1 initially below screen' );
-is_deeply( [ $scroller->item2line( 2, -1, 1 ) ], [ 5, "below" ], 'list item2line 2, -1 initially below screen with count_offscreen' );
+is( [ $scroller->item2line( 2, -1 ) ], [ undef, "below" ], 'list item2line 2, -1 initially below screen' );
+is( [ $scroller->item2line( 2, -1, 1 ) ], [ 5, "below" ], 'list item2line 2, -1 initially below screen with count_offscreen' );
is( $scroller->lines_above, 0, 'lines_above initially' );
is( $scroller->lines_below, 13, 'lines_below initially' );
@@ -108,10 +108,10 @@ is( $scroller->item2line( 5, 0 ), 0, 'item2line 5, 0 after scroll +10' );
is( $scroller->item2line( 5, -1 ), 1, 'item2line 5, -1 after scroll +10' );
is( $scroller->item2line( 8, 0 ), undef, 'item2line 8, 0 offscreen after scroll +10' );
-is_deeply( [ $scroller->item2line( 0, 0 ) ], [ undef, "above" ], 'list item2line 0, 0 above screen after scroll +10' );
-is_deeply( [ $scroller->item2line( 0, 0, 1 ) ], [ -10, "above" ], 'list item2line 0, 0 above screen after scroll +10 with count_offscreen' );
-is_deeply( [ $scroller->item2line( 8, 0 ) ], [ undef, "below" ], 'list item2line 8, 0 below screen after scroll +10' );
-is_deeply( [ $scroller->item2line( 8, 0, 1 ) ], [ 6, "below" ], 'list item2line 8, 0 below screen after scroll +10 with count_offscreen' );
+is( [ $scroller->item2line( 0, 0 ) ], [ undef, "above" ], 'list item2line 0, 0 above screen after scroll +10' );
+is( [ $scroller->item2line( 0, 0, 1 ) ], [ -10, "above" ], 'list item2line 0, 0 above screen after scroll +10 with count_offscreen' );
+is( [ $scroller->item2line( 8, 0 ) ], [ undef, "below" ], 'list item2line 8, 0 below screen after scroll +10' );
+is( [ $scroller->item2line( 8, 0, 1 ) ], [ 6, "below" ], 'list item2line 8, 0 below screen after scroll +10 with count_offscreen' );
is( $scroller->lines_above, 10, 'lines_above after scroll +10' );
is( $scroller->lines_below, 3, 'lines_below after scroll +10' );
diff --git a/t/12resize-bottom.t b/t/12resize-bottom.t
index 28b2634..52c5ee9 100644
--- a/t/12resize-bottom.t
+++ b/t/12resize-bottom.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test;
diff --git a/t/12resize-top.t b/t/12resize-top.t
index 2f32438..4f5438a 100644
--- a/t/12resize-top.t
+++ b/t/12resize-top.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test;
diff --git a/t/20push-bottom.t b/t/20push-bottom.t
index 4185ac3..27415aa 100644
--- a/t/20push-bottom.t
+++ b/t/20push-bottom.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
@@ -33,10 +33,14 @@ is_display( [ ],
is_cursorpos( 7, 0, 'Cursor position intially' );
+is( scalar $scroller->items, 0, '$scroller->items is 0 before ->push' );
+
$scroller->push(
Tickit::Widget::Scroller::Item::Text->new( "A line of text" ),
);
+is( scalar $scroller->items, 1, '$scroller->items is 1 after ->push' );
+
flush_tickit;
is_termlog( [ GOTO(0,0),
diff --git a/t/20push-top.t b/t/20push-top.t
index b900c6a..ffe8d6a 100644
--- a/t/20push-top.t
+++ b/t/20push-top.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
@@ -33,10 +33,14 @@ is_display( [ ],
is_cursorpos( 7, 0, 'Cursor position intially' );
+is( scalar $scroller->items, 0, '$scroller->items is 0 before ->push' );
+
$scroller->push(
Tickit::Widget::Scroller::Item::Text->new( "A line of text" ),
);
+is( scalar $scroller->items, 1, '$scroller->items is 1 after ->push' );
+
flush_tickit;
is_termlog( [ GOTO(0,0),
diff --git a/t/21shift-bottom.t b/t/21shift-bottom.t
index 22ef5a7..a51c18f 100644
--- a/t/21shift-bottom.t
+++ b/t/21shift-bottom.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
@@ -46,8 +46,12 @@ is_display( [ [TEXT("Existing line 1")],
is_cursorpos( 7, 0, 'Cursor position intially' );
+is( scalar $scroller->items, 20, '$scroller->items is 20 before ->shift' );
+
$scroller->shift;
+is( scalar $scroller->items, 19, '$scroller->items is 19 after ->shift' );
+
flush_tickit;
is_termlog( [ SETBG(undef),
diff --git a/t/21shift-top.t b/t/21shift-top.t
index f40ebe6..5c57476 100644
--- a/t/21shift-top.t
+++ b/t/21shift-top.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
@@ -46,10 +46,14 @@ is_display( [ [TEXT("Existing line 1")],
is_cursorpos( 7, 0, 'Cursor position intially' );
+is( scalar $scroller->items, 20, '$scroller->items is 20 before ->shift' );
+
my ( $item ) = $scroller->shift;
isa_ok( $item, "Tickit::Widget::Scroller::Item::Text" );
+is( scalar $scroller->items, 19, '$scroller->items is 19 after ->shift' );
+
flush_tickit;
is_termlog( [ SETBG(undef),
diff --git a/t/22unshift-bottom.t b/t/22unshift-bottom.t
index 4e56a46..7c11fb3 100644
--- a/t/22unshift-bottom.t
+++ b/t/22unshift-bottom.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
diff --git a/t/22unshift-top.t b/t/22unshift-top.t
index 9fe302f..5cb8483 100644
--- a/t/22unshift-top.t
+++ b/t/22unshift-top.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
diff --git a/t/23pop-bottom.t b/t/23pop-bottom.t
index f9da224..82d3cdc 100644
--- a/t/23pop-bottom.t
+++ b/t/23pop-bottom.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
diff --git a/t/23pop-top.t b/t/23pop-top.t
index 9e1e2e9..4f86041 100644
--- a/t/23pop-top.t
+++ b/t/23pop-top.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test 0.12;
diff --git a/t/30indicator.t b/t/30indicator.t
index cec9424..c1ac8e6 100644
--- a/t/30indicator.t
+++ b/t/30indicator.t
@@ -1,18 +1,16 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
use Tickit::Test;
use Tickit::Widget::Scroller;
use Tickit::Widget::Scroller::Item::Text;
-# These tests depend on the new Window rendering behaviour added in Tickit 0.43
-# but the actual functionallity will work fine before that
-eval { require Tickit::Window; Tickit::Window->VERSION( '0.43' ) }
- or plan skip_all => "Tickit::Window older than 0.43; these tests won't work";
+# At Tickit::Window 0.44, rendering is done in one go.
+use Tickit::Window 0.44;
my $win = mk_window;
@@ -21,7 +19,7 @@ my $scroller = Tickit::Widget::Scroller->new(
my $self = shift;
# TODO: This is a fragile API, needs fixing
return sprintf "-- Start{%d/%d} items{%d} --",
- $self->_start_item, $self->_start_partial, scalar $self->_items;
+ $self->_start_item, $self->_start_partial, scalar $self->items;
},
);
@@ -32,39 +30,20 @@ $scroller->push(
$scroller->set_window( $win );
flush_tickit;
-# At Tickit::Window 0.44, rendering is done in one go.
-if( $Tickit::Window::VERSION >= '0.44' ) {
- is_termlog( [ GOTO(0,0),
- SETPEN,
- PRINT("Line 1 of content"),
- SETBG(undef),
- ERASECH(37,1),
- SETPEN(rv=>1),
- PRINT("-- Start{0/0} items{50} --"),
-
- ( map { GOTO($_-1,0),
- SETPEN,
- PRINT("Line $_ of content"),
- SETBG(undef),
- ERASECH(64-length $_), } 2 .. 25 ) ],
- 'Termlog initially' );
-}
-else {
- is_termlog( [ GOTO(0,0),
- SETPEN,
- PRINT("Line 1 of content"),
- SETBG(undef),
- ERASECH(37),
- ( map { GOTO($_-1,0),
- SETPEN,
- PRINT("Line $_ of content"),
- SETBG(undef),
- ERASECH(64-length $_), } 2 .. 25 ),
- GOTO(0,54),
- SETPEN(rv=>1),
- PRINT("-- Start{0/0} items{50} --") ],
- 'Termlog initially' );
-}
+is_termlog( [ GOTO(0,0),
+ SETPEN,
+ PRINT("Line 1 of content"),
+ SETBG(undef),
+ ERASECH(37,1),
+ SETPEN(rv=>1),
+ PRINT("-- Start{0/0} items{50} --"),
+
+ ( map { GOTO($_-1,0),
+ SETPEN,
+ PRINT("Line $_ of content"),
+ SETBG(undef),
+ ERASECH(64-length $_), } 2 .. 25 ) ],
+ 'Termlog initially' );
is_display( [ [TEXT("Line 1 of content" . (" "x37)), TEXT("-- Start{0/0} items{50} --",rv=>1) ],
map { "Line $_ of content" } 2 .. 25 ],
@@ -73,41 +52,21 @@ is_display( [ [TEXT("Line 1 of content" . (" "x37)), TEXT("-- Start{0/0} items{5
$scroller->scroll( 2 );
flush_tickit;
-if( $Tickit::Window::VERSION >= '0.44' ) {
- is_termlog( [ SETPEN,
- SCROLLRECT(1,0,24,80,2,0),
- GOTO(0,0),
- SETPEN,
- PRINT("Line 3 of content"),
- SETBG(undef),
- ERASECH(37,1),
- SETPEN(rv=>1),
- PRINT("-- Start{2/0} items{50} --"),
- ( map { GOTO($_-3,0),
- SETPEN,
- PRINT("Line $_ of content"),
- SETBG(undef),
- ERASECH(64-length $_), } 26 .. 27 ) ],
- 'Termlog after ->scroll' );
-}
-else {
- is_termlog( [ SETPEN,
- SCROLLRECT(1,0,24,80,2,0),
- GOTO(0,0),
- SETPEN,
- PRINT("Line 3 of content"),
- SETBG(undef),
- ERASECH(37),
- GOTO(0,54),
- SETPEN(rv=>1),
- PRINT("-- Start{2/0} items{50} --"),
- ( map { GOTO($_-3,0),
- SETPEN,
- PRINT("Line $_ of content"),
- SETBG(undef),
- ERASECH(64-length $_), } 26 .. 27 ) ],
- 'Termlog after ->scroll' );
-}
+is_termlog( [ SETPEN,
+ SCROLLRECT(1,0,24,80,2,0),
+ GOTO(0,0),
+ SETPEN,
+ PRINT("Line 3 of content"),
+ SETBG(undef),
+ ERASECH(37,1),
+ SETPEN(rv=>1),
+ PRINT("-- Start{2/0} items{50} --"),
+ ( map { GOTO($_-3,0),
+ SETPEN,
+ PRINT("Line $_ of content"),
+ SETBG(undef),
+ ERASECH(64-length $_), } 26 .. 27 ) ],
+ 'Termlog after ->scroll' );
is_display( [ [TEXT("Line 3 of content" . (" "x37)), TEXT("-- Start{2/0} items{50} --",rv=>1) ],
map { "Line $_ of content" } 4 .. 27 ],
@@ -140,4 +99,29 @@ is_display( [ ( map { "Line $_ of content" } 3 .. 26 ),
[TEXT("Line 27 of content" . (" "x52)), TEXT("-- more --",rv=>1) ] ],
'Display after setting bottom indicator' );
+clear_term;
+drain_termlog;
+
+$win->resize( 15, 80 );
+
+flush_tickit;
+
+is_termlog( [ ( map { GOTO($_-3,0),
+ SETPEN,
+ PRINT("Line $_ of content"),
+ SETBG(undef),
+ ERASECH(64-length $_) } 3 .. 16 ),
+ GOTO(14,0),
+ SETPEN,
+ PRINT("Line 17 of content"),
+ SETBG(undef),
+ ERASECH(52,1),
+ SETPEN(rv=>1),
+ PRINT("-- more --") ],
+ 'Termlog after window resize' );
+
+is_display( [ ( map { "Line $_ of content" } 3 .. 16 ),
+ [TEXT("Line 17 of content" . (" "x52)), TEXT("-- more --",rv=>1) ] ],
+ 'Display after window resize' );
+
done_testing;
diff --git a/t/99pod.t b/t/99pod.t
index eb319fb..dd3c3b5 100644
--- a/t/99pod.t
+++ b/t/99pod.t
@@ -1,9 +1,9 @@
#!/usr/bin/perl
-use strict;
+use v5.26;
use warnings;
-use Test::More;
+use Test2::V0;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;