view release on metacpan or search on metacpan
lib/Test/Spec.pm view on Meta::CPAN
view all matches for this distribution
220221222223224225226227228229230
label
=>
$name
,
});
}
# around CODE
sub
around
(&) {
my
$package
=
caller
;
my
$code
=
pop
;
if
(
ref
(
$code
) ne
'CODE'
) {
Carp::croak
"expected subroutine reference as last argument"
;
}
view release on metacpan or search on metacpan
lib/Test/Stream/Plugin/Capture.pm view on Meta::CPAN
view all matches for this distribution
7891011121314151617default_exports
qw/capture/
;
no
Test::Stream::Exporter;
sub
capture(&) {
my
$code
=
shift
;
my
(
$err
,
$out
) = (
""
,
""
);
my
(
$ok
,
$e
);
view release on metacpan or search on metacpan
lib/Test/StructuredObject.pm view on Meta::CPAN
view all matches for this distribution
26272829303132333435363738394041};
## no critic ( ProhibitSubroutinePrototypes, RequireArgUnpacking )
sub
test(&;@) {
my
$code
=
shift
;
return
Test::StructuredObject::Test->new(
code
=>
$code
),
@_
;
}
sub
step(&;@) {
my
$code
=
shift
;
return
Test::StructuredObject::NonTest->new(
code
=>
$code
),
@_
;
}
sub
testsuite(@) {
view release on metacpan or search on metacpan
lib/Test/Tail/Multi.pm view on Meta::CPAN
view all matches for this distribution
59606162636465666768697071727374
my
(
$file
,
$comment
) =
@_
;
push
@monitored
, File::Tail->new(
$file
);
$Test
->diag(
$comment
)
if
defined
$comment
;
}
sub
contents_like(&$;$) {
my
(
$coderef
,
$pattern
,
$comment
) =
@_
;
_execute(
$coderef
,
$pattern
,
sub
{
$Test
->like(
@_
) },
$comment
);
}
sub
contents_unlike(&$;$) {
my
(
$coderef
,
$pattern
,
$comment
) =
@_
;
_execute(
$coderef
,
$pattern
,
sub
{
$Test
->unlike(
@_
) },
$comment
);
}
sub
_execute {
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
260261262263264265266267268269270
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
lib/Test/TinyMocker.pm view on Meta::CPAN
view all matches for this distribution
13141516171819202122@EXPORT
=
qw(mock unmock should method methods)
;
sub
method($) {
@_
}
sub
methods($) {
@_
}
sub
should(&) {
@_
}
sub
mock {
croak
'useless use of mock with one or less parameter'
if
scalar
@_
< 2;
view release on metacpan or search on metacpan
t/03-files.pl view on Meta::CPAN
view all matches for this distribution
5051525354555657585960
diag
$msg
;
die
$msg
;
}
my
(
$noise
,
$noisecounter
) = (
''
, 0);
sub
runtests(&@) {
# runs the trap and performs 6 tests
my
(
$code
,
$return
,
$warn
,
$stdout
,
$stderr
,
$desc
) =
@_
;
my
$n
= ++
$noisecounter
. $/;
warn
$n
or diagdie
"Cannot warn()!"
;
STDERR->flush or diagdie
"Cannot flush STDERR!"
;
STDERR
$n
or diagdie
"Cannot print on STDERR!"
;
view release on metacpan or search on metacpan
lib/Test/Warnings.pm view on Meta::CPAN
view all matches for this distribution
104105106107108109110111112113114
};
$code
->();
@warnings
;
}
sub
warning(&) {
my
@warnings
=
&warnings
(
@_
);
return
@warnings
== 1 ?
$warnings
[0] : \
@warnings
;
}
# check for any forbidden warnings, and record that we have done so
view release on metacpan or search on metacpan
t/HashBase.t view on Meta::CPAN
view all matches for this distribution
234567891011121314151617181920use
warnings;
use
Test::More;
sub
warnings(&) {
my
$code
=
shift
;
my
@warnings
;
local
$SIG
{__WARN__} =
sub
{
push
@warnings
=>
@_
};
$code
->();
return
\
@warnings
;
}
sub
exception(&) {
my
$code
=
shift
;
local
($@, $!,
$SIG
{__DIE__});
my
$ok
=
eval
{
$code
->(); 1 };
my
$error
= $@ ||
'SQUASHED ERROR'
;
return
$ok
?
undef
:
$error
;
view release on metacpan or search on metacpan
t/HashBase.t view on Meta::CPAN
view all matches for this distribution
234567891011121314151617181920use
warnings;
use
Test::More;
sub
warnings(&) {
my
$code
=
shift
;
my
@warnings
;
local
$SIG
{__WARN__} =
sub
{
push
@warnings
=>
@_
};
$code
->();
return
\
@warnings
;
}
sub
exception(&) {
my
$code
=
shift
;
local
($@, $!,
$SIG
{__DIE__});
my
$ok
=
eval
{
$code
->(); 1 };
my
$error
= $@ ||
'SQUASHED ERROR'
;
return
$ok
?
undef
:
$error
;
view release on metacpan or search on metacpan
lib/Test2/Tools/Compare.pm view on Meta::CPAN
200201202203204205206207208209210211212213214215216
$ctx
->release;
return
$delta
? 1 : 0;
}
sub
meta(&) { build(
'Test2::Compare::Meta'
,
@_
) }
sub
meta_check(&) { build(
'Test2::Compare::Meta'
,
@_
) }
sub
hash(&) { build(
'Test2::Compare::Hash'
,
@_
) }
sub
array(&) { build(
'Test2::Compare::Array'
,
@_
) }
sub
bag(&) { build(
'Test2::Compare::Bag'
,
@_
) }
sub
object(&) { build(
'Test2::Compare::Object'
,
@_
) }
sub
subset(&) { build(
'Test2::Compare::OrderedSubset'
,
@_
) }
sub
U() {
my
@caller
=
caller
;
Test2::Compare::Custom->new(
code
=>
sub
{
defined
$_
? 0 : 1 },
name
=>
'UNDEFINED'
,
operator
=>
'!DEFINED()'
,
lib/Test2/Tools/Compare.pm view on Meta::CPAN
view all matches for this distribution
467468469470471472473474475476
input
=>
$class_name
,
@args
,
);
}
sub
filter_items(&) {
defined
(
my
$build
= get_build() ) or croak
"No current build!"
;
croak
"'$build' does not support filters"
unless
$build
->can(
'add_filter'
);
view release on metacpan or search on metacpan
lib/Test/Exec.pm view on Meta::CPAN
view all matches for this distribution
15161718192021222324our
@EXPORT
=
qw( exec_arrayref never_exec_ok )
;
my
$last
;
sub
exec_arrayref(&)
{
my
(
$code
) =
@_
;
undef
$last
;
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
262263264265266267268269270271272
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
lib/Text/CSV/Flatten.pm view on Meta::CPAN
view all matches for this distribution
135136137138139140141142143144145
return
join
"\n"
,
@result
;
}
# utility function to iterate over key => value pairs with the added
# bonus that it also works for arrays
sub
_foreach(&$) {
my
(
$codeblock
,
$it
)=
@_
;
if
(!
defined
$it
|| !
ref
$it
) {
return
;
}
elsif
(
'ARRAY'
eq
ref
$it
) {
view release on metacpan or search on metacpan
t/unicode.t view on Meta::CPAN
view all matches for this distribution
6970717273747576777879ok(
$csv
->version(),
'inheritted version() works'
);
ok(
$csv
->isa(
'Text::CSV::Unicode'
),
'creates a Text::CSV::Unicode object'
);
my
$warn
;
sub
_warning(&) {
my
$sub
=
shift
;
local
$SIG
{__WARN__} =
sub
{
$warn
.=
$_
[0]; };
$warn
=
q{}
;
return
$sub
->();
}
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
261262263264265266267268269270271
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
lib/Text/Glob/DWIW.pm view on Meta::CPAN
view all matches for this distribution
267268269270271272273274275276277278279280281282283#~ forester
sub
_flatten (@) {
map
{ _reft(
$_
) ?
&_flatten
(_deref
$_
) :
$_
}
@_
}
sub
_markflt (@) {
join
''
,
map
{ _reft(
$_
) ?
'('
.
&_markflt
(_deref
$_
).
')'
:
$_
}
@_
}
#4capture
sub
_treejoin($) {
join
''
,
&_flatten
}
# fixed ''
sub
_forestjoin {
map
{
join
''
,_flatten
$_
}
@_
}
sub
_treemap(&@) {
my
$f
=
shift
;
map
{ _reft(
$_
)?_doref
&_treemap
(
$f
,_deref
$_
):
$f
->(
$_
) }
@_
}
sub
_forestmap(&@) {
my
$f
=
shift
;
map
[
&_treemap
(
$f
,
@$_
)],
@_
}
sub
_treefor1(&@){
my
$f
=
shift
;
for
(
@_
) {
my
$t
=_reft
$_
; !
$t
?
$f
->(
$_
) :
&_treefor1
(
$f
,
'ARRAY'
eq
$t
?
@$_
:
$t
=~/SCAL|REF/?
$$_
:
$_
) } }
# ^- was: ...&_treefor1($f,_deref $_).. with _deref :lvalue but this bail out under 5.10
# with "Bizarre copy of ARRAY in sassign at line 25 or in overload::Method ...."
sub
_treefirst(&@) {
my
$f
=
shift
;
my
$t
=_reft
$_
[0]; !
$t
?
do
{
$f
->(
$_
[0])
for
$_
[0]} :
&_treefirst
(
$f
,
'ARRAY'
eq
$t
?
$_
[0][0] : ${
$_
[0]}) }
sub
_drop_anchor ($;$$)
# rm outside anchors
{
my
(
$v
,
$xaa
,
$xae
)=
@_
;
return
unless
$xaa
||
$xae
;
my
(
$A
,
$a
,
$e
,
$pos
)=(0,0,0,0);
while
(
$pos
<
@$v
)
{
if
(_reft
$v
->[
$pos
]) { (
$a
,
$e
)=
&_drop_anchor
(
$v
->[
$pos
],
$xaa
,
$xae
);
$A
||=
$a
}
view release on metacpan or search on metacpan
t/expand_file.t view on Meta::CPAN
view all matches for this distribution
1314151617181920212223use_ok
'Text::MacroScript'
;
push
@INC
, path($0)->dirname;
require_ok
'mytests.pl'
;
sub
void(&) {
$_
[0]->(); () }
my
$ms
;
my
$fh
;
my
(
$out
,
$err
,
@res
);
my
$file
=
"test~"
;
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
255256257258259260261262263264265
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
260261262263264265266267268269270
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
view all matches for this distribution
1213141516171819202122BEGIN {
use_ok(
'Text::Reform'
,
qw{ form tag break_at break_wrap break_with }
);
}
#my $testnum = 1;
#use Data::Dumper 'Dumper';
sub
teststr(&$;$)
# (&sub, $retval)
{
do
{
#$testnum++;
my
$res
= &{
$_
[0]};
my
$exp
=
$_
[1];
my
$message
=
$_
[2];
view release on metacpan or search on metacpan
t/t_TestCommon.pm view on Meta::CPAN
391392393394395396397398399400401
open
(
$orig_stdERR
,
">&"
, \
*STDERR
) or
die
"dup STDERR: $!"
;
close
STDERR;
open
(STDERR,
">"
, \
$inmem_stdERR
) or
die
"redir STDERR: $!"
;
binmode
(STDERR);
binmode
(STDERR,
":utf8"
);
}
sub
silent(&) {
my
$wantarray
=
wantarray
;
my
$code
=
shift
;
_start_silent();
my
@result
=
do
{
if
(
defined
$wantarray
) {
t/t_TestCommon.pm view on Meta::CPAN
772773774775776777778779780781782
my
(
$fn
,
$lno
) = (
caller
(0))[1,2];
#use Data::Dumper::Interp; say dvis '###insert_loc_in_evalstr $fn $lno';
"# line $lno \"$fn\"\n"
.
$orig
}
sub
timed_run(&$@) {
my
(
$code
,
$maxcpusecs
,
@codeargs
) =
@_
;
my
$getcpu
=
eval
{
do
{
() = (
&Time::HiRes::clock
());
t/t_TestCommon.pm view on Meta::CPAN
view all matches for this distribution
818819820821822823824825826827828829830831832833834835836
# to the cwd!
$str
=~ s/The media is
write
protected\S*\R//gs;
$str
}
sub
my_capture(&) {
my
(
$out
,
$err
,
@results
) =
&capture
(
$_
[0]);
return
( clean_capture_output(
$out
), clean_capture_output(
$err
),
@results
);
}
sub
my_capture_merged(&) {
my
(
$merged
,
@results
) =
&capture_merged
(
$_
[0]);
return
( clean_capture_output(
$merged
),
@results
);
}
sub
my_tee_merged(&) {
my
(
$merged
,
@results
) =
&tee_merged
(
$_
[0]);
return
( clean_capture_output(
$merged
),
@results
);
}
1;
view release on metacpan or search on metacpan
t/03-errorcases.t view on Meta::CPAN
67891011121314151617sub
err_like(&$);
sub
no_err(&);
{
note(
"Constructor args"
);
err_like {RELATION_ON->new(1)}
qr/^Odd number of arguments/
;
err_like {RELATION_ON->new(
foo
=> 1)}
qr/^foo\b.*unexpected argument/
;
t/03-errorcases.t view on Meta::CPAN
361362363364365366367368369370371#
# err_like CODEREF, MSGREGEX
#
# Check if CODEREF fails with error message matching MSGREGEX.
#
sub
err_like(&$) {
my
(
$sub
,
$re
) =
@_
;
local
$Test::Builder::Level
=
$Test::Builder::Level
+ 1;
eval
{
$sub
->()};
if
($@) {
(
my
$err
= $@) =~ s/\n.*//s;
## Important: cut off stacktrace
t/03-errorcases.t view on Meta::CPAN
view all matches for this distribution
374375376377378379380381382383384
fail(
"Code did not produce error"
);
return
""
;
}
}
sub
no_err(&) {
my
(
$sub
) =
@_
;
local
$Test::Builder::Level
=
$Test::Builder::Level
+ 1;
eval
{
$sub
->()};
ok(!$@,
"Code did not produce an error $@"
);
}
view release on metacpan or search on metacpan
lib/Test/Base/Less.pm view on Meta::CPAN
view all matches for this distribution
7980818283848586878889
}
}
return
@retval
;
}
sub
run(&) {
my
$code
=
shift
;
for
my
$block
(_get_blocks(
scalar
(
caller
(0)))) {
__PACKAGE__->builder->subtest(
$block
->name ||
'L: '
.
$block
->get_lineno,
sub
{
$code
->(
$block
);
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
260261262263264265266267268269270
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
t/030_kolon/033_ov_forloop.t view on Meta::CPAN
view all matches for this distribution
view release on metacpan or search on metacpan
t/01_types.t view on Meta::CPAN
view all matches for this distribution
5678910111213141516171819use
ThaiSchema;
use
JSON ();
BEGIN {
*describe
=
*context
=
*it
=
*Test::More::subtest
}
sub
strict_context(&) {
local
$ThaiSchema::STRICT
= 1;
$_
[0]->();
}
sub
normal_context(&) {
local
$ThaiSchema::STRICT
= 0;
$_
[0]->();
}
describe
'int'
=>
sub
{
view release on metacpan or search on metacpan
inc/Test/Base.pm view on Meta::CPAN
view all matches for this distribution
261262263264265266267268269270271
ok
$actual
eq
$expected
,
$name
.
"\n"
. Text::Diff::diff(\
$expected
, \
$actual
);
}
}
sub
run(&;$) {
(
my
(
$self
),
@_
) = find_my_self(
@_
);
my
$callback
=
shift
;
for
my
$block
(@{
$self
->block_list}) {
$block
->run_filters
unless
$block
->is_filtered;
&{
$callback
}(
$block
);
view release on metacpan or search on metacpan
lib/Tickit/DSL.pm view on Meta::CPAN
250251252253254255256257258259260Will run the code
after
the
next
round of I/O events.
=cut
sub later(&) {
my $code = shift;
tickit->later($code)
}
=head2 timer
lib/Tickit/DSL.pm view on Meta::CPAN
272273274275276277278279280281282Takes a codeblock and either C<at> or C<
after
> definitions. Passing
anything other than a single definition will cause an exception.
=cut
sub timer(&@) {
my $code = shift;
my %args = @_;
die 'when did you want to run the code?' unless 1 == grep exists $args{$_}, qw(at after);
tickit->timer(%args, $code);
}
lib/Tickit/DSL.pm view on Meta::CPAN
293294295296297298299300301302303Returns the widget we added the new widgets under (i.e. the C< under > parameter).
=cut
sub add_widgets(&@) {
my $code = shift;
my %args = @_;
local $PARENT = delete $args{under} or die 'expected add_widgets { ... } under => $some_widget;';
local @WIDGET_ARGS = (@WIDGET_ARGS, %args);
$code->($PARENT);
lib/Tickit/DSL.pm view on Meta::CPAN
324325326327328329330331332333334
...
}
classes
=> [
qw(other vbox)
],
style
=> {
fg
=>
'green'
};
=cut
sub vbox(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::VBox->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
354355356357358359360361362363364
...
}
classes
=> [
qw(other vsplit)
],
style
=> {
fg
=>
'green'
};
=cut
sub vsplit(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = do {
local $PARENT = 'Tickit::Widget::VSplit';
local @PENDING_CHILD;
lib/Tickit/DSL.pm view on Meta::CPAN
385386387388389390391392393394395
...
}
title
=>
'some frame'
,
title_align
=> 0.5;
=cut
sub frame(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Frame->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
416417418419420421422423424425426
gridrow { static
'BL'
; static
'BR'
};
}
style
=> {
col_spacing
=> 1,
row_spacing
=> 1 };
=cut
sub gridbox(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::GridBox->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
437438439440441442443444445446447Marks a separate row in an existing L<Tickit::Widget::GridBox>. This behaves
something like a container, see L</gridbox>
for
details.
=cut
sub gridrow(&@) {
my ($code) = @_;
die "Grid rows must be in a gridbox" unless $PARENT->isa('Tickit::Widget::GridBox');
$code->($PARENT);
$GRID_COL = 0;
++$GRID_ROW;
lib/Tickit/DSL.pm view on Meta::CPAN
463464465466467468469470471472473
...
}
classes
=> [
qw(other hbox)
],
style
=> {
fg
=>
'green'
};
=cut
sub hbox(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::HBox->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
493494495496497498499500501502503
...
}
classes
=> [
qw(other hsplit)
],
style
=> {
fg
=>
'green'
};
=cut
sub hsplit(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = do {
local $PARENT = 'Tickit::Widget::HSplit';
local @PENDING_CHILD;
lib/Tickit/DSL.pm view on Meta::CPAN
527528529530531532533534535536537
'parent:top'
=> 1;
};
=cut
sub desktop(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Layout::Desktop->new(%args);
{
tickit->later(sub {
lib/Tickit/DSL.pm view on Meta::CPAN
550551552553554555556557558559560See L</pane>
for
the details.
=cut
sub relative(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Layout::Relative->new(%args);
{
local @WIDGET_ARGS;
lib/Tickit/DSL.pm view on Meta::CPAN
571572573574575576577578579580581A pane in a L</relative> layout.
=cut
sub pane(&@) {
my ($code, %args) = @_;
die "pane should be used within a relative { ... } item" unless $PARENT->isa('Tickit::Widget::Layout::Relative');
{
local @WIDGET_ARGS = (@WIDGET_ARGS, %args);
$code->($PARENT);
lib/Tickit/DSL.pm view on Meta::CPAN
600601602603604605606607608609610
...
}
class
=>
'some_hsplit'
;
=cut
sub scrollbox(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = do {
local $PARENT = 'Tickit::Widget::ScrollBox';
local @PENDING_CHILD;
lib/Tickit/DSL.pm view on Meta::CPAN
634635636637638639640641642643644
scroller_text
'line '
.
$_
for
1..100;
}
gravity
=>
'bottom'
;
=cut
sub scroller(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Scroller->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
697698699700701702703704705706707at runtime, so it may throw an exception
if
it is not
already installed.
=cut
sub console(&@) {
require "Tickit" . "/Console.pm";
my %args = (on_line => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Console->new(
%args
lib/Tickit/DSL.pm view on Meta::CPAN
773774775776777778779780781782783The C<ribbon_class> parameter may be undocumented.
=cut
sub tabbed(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Tabbed->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
803804805806807808809810811812813
}
}
=cut
sub floatbox(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::FloatBox->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
832833834835836837838839840841842
}
}
=cut
sub float(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
# Work out which container to use - either the least-distant ancestor,
# or a specific floatbox if one was provided
lib/Tickit/DSL.pm view on Meta::CPAN
863864865866867868869870871872873A L<Tickit::Widget::Statusbar>. Not very exciting.
=cut
sub statusbar(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Statusbar->new(%args);
{
local $PARENT = $w;
lib/Tickit/DSL.pm view on Meta::CPAN
933934935936937938939940941942943my
$rslt
= static
'result here'
;
entry {
shift
;
$rslt
->set_text(
eval
shift
) }
text
=>
'1 + 3'
;
=cut
sub entry(&@) {
my %args = (on_enter => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Entry->new(
%args
);
lib/Tickit/DSL.pm view on Meta::CPAN
949950951952953954955956957958959Checkbox (or checkbutton).
=cut
sub checkbox(&@) {
my %args = (on_toggle => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::CheckButton->new(
%args
);
lib/Tickit/DSL.pm view on Meta::CPAN
969970971972973974975976977978979
radiobutton { }
'three'
;
};
=cut
sub radiobutton(&@) {
my $code = shift;
die "need a radiogroup" unless $RADIOGROUP;
my %args = (
group => $RADIOGROUP,
label => @_
lib/Tickit/DSL.pm view on Meta::CPAN
99199299399499599699799899910001001See L</radiobutton>.
=cut
sub radiogroup(&@) {
my $code = shift;
my %args = @_;
# my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $group = Tickit::Widget::RadioButton::Group->new;
$group->set_on_changed(delete $args{on_changed}) if exists $args{on_changed};
lib/Tickit/DSL.pm view on Meta::CPAN
10121013101410151016101710181019102010211022
button {
warn
"Activated"
}
'OK'
;
=cut
sub button(&@) {
my $code = shift;
my %args = (
label => @_
);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
lib/Tickit/DSL.pm view on Meta::CPAN
10511052105310541055105610571058105910601061
],
];
=cut
sub tree(&@) {
my %args = (on_activate => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Tree->new(
%args
lib/Tickit/DSL.pm view on Meta::CPAN
10791080108110821083108410851086108710881089
{
label
=>
'Description'
},
];
=cut
sub table(&@) {
my %args = (on_activate => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Table->new(
%args
);
lib/Tickit/DSL.pm view on Meta::CPAN
11011102110311041105110611071108110911101111};
$bc
->adapter->
push
([
qw(some path here)
]);
=cut
sub breadcrumb(&@) {
my %args = (on_activate => @_);
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::Breadcrumb->new(
%args
);
lib/Tickit/DSL.pm view on Meta::CPAN
11701171117211731174117511761177117811791180
fileviewer { }
'somefile.txt'
;
=cut
sub fileviewer(&;@) {
my ($code, $file) = splice @_, 0, 2;
my %args = (
@_,
file => $file
);
lib/Tickit/DSL.pm view on Meta::CPAN
12271228122912301231123212331234123512361237=cut
# haxx. A menubar has no link back to the container.
our $MENU_PARENT;
sub menubar(&@) {
my ($code, %args) = @_;
my %parent_args = map {; $_ => delete $args{'parent:' . $_} } map /^parent:(.*)/ ? $1 : (), keys %args;
my $w = Tickit::Widget::MenuBar->new(%args);
local $MENU_PARENT = $PARENT;
{
lib/Tickit/DSL.pm view on Meta::CPAN
13141315131613171318131913201321132213231324
$tbl
;
}
expand
=> 1;
=cut
sub customwidget(&@) {
my ($code, @args) = @_;
my %args = @args;
local $PARENT = delete($args{parent}) || $PARENT;
my $w = $code->($PARENT);
{
lib/Tickit/DSL.pm view on Meta::CPAN
view all matches for this distribution
13551356135713581359136013611362136313641365
static
=>
'66%'
'parent:expand'
=> 2;
};
=cut
sub widget(&@) {
my ($code, %args) = @_;
local $PARENT = delete($args{parent}) || $PARENT;
{
local @WIDGET_ARGS = (@WIDGET_ARGS, %args);
$code->($PARENT);
view release on metacpan or search on metacpan
examples/adapter-deferred-array-styled.pl view on Meta::CPAN
view all matches for this distribution
4567891011121314{
package
DeferredArray;
use
parent
qw(https://metacpan.org/pod/Adapter::Async::OrderedList::Array">Adapter::Async::OrderedList::Array)
;
sub
defer_by(&$) {
my
(
$code
,
$delay
) =
@_
;
my
$f
= loop->new_future;
tickit->timer(
after
=>
$delay
,
sub
{
$f
->done(
$code
->()) }