Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (44 sloc) 1.849 kb
de174b3b »
2008-06-26 [spec] test for $_ being treated as formal parameter of a block
1 use v6;
2 use Test;
734bc95b »
2009-03-29 [t/spec]
3 plan 18;
de174b3b »
2008-06-26 [spec] test for $_ being treated as formal parameter of a block
4
7101b98a »
2009-07-24 [t/spec] fix several smartlinks
5 # L<S04/The Relationship of Blocks and Declarations/A bare closure
6 # (except the block associated with a conditional statement)>
de174b3b »
2008-06-26 [spec] test for $_ being treated as formal parameter of a block
7
8 {
9 # test with explicit $_
10 my $f1 = { 2*$_ };
1e2c1f07 »
2009-10-09 [t/spec] 11 typos in 6 files.
11 is $f1(2), 4, 'Block with explicit $_ has one formal parameter';
de174b3b »
2008-06-26 [spec] test for $_ being treated as formal parameter of a block
12 }
13
14 {
15 # test with implicit $_
16 my $f2 = { .sqrt };
13cc9c44 »
2009-10-09 [t/spec] 71 typos in 32 files.
17 is_approx $f2(4), 2, 'Block with implicit $_ has one formal parameter';
de174b3b »
2008-06-26 [spec] test for $_ being treated as formal parameter of a block
18 }
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
19
20 {
21 # { } has implicit signature ($_ is rw = $OUTER::_)
22
23 $_ = 'Hello';
436c2ff5 »
2008-09-26 [t/spec] re-fudged implicit-parameter.t for rakudo
24 #?pugs todo 'feature'
25 is(try { { $_ }.() }, 'Hello', '$_ in bare block defaults to outer');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
26 is({ $_ }.('Goodbye'), 'Goodbye', 'but it is only a default');
27 is({ 42 }.(), 42, 'no implicit $_ usage checking');
1e2c1f07 »
2009-10-09 [t/spec] 11 typos in 6 files.
28 is({ 42 }.('Goodbye'), 42, '$_ gets assigned but is not used');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
29
734bc95b »
2009-03-29 [t/spec]
30 is(({ $_ }.arity), 0, '{$_} is arity 0, of course');
31 is(({ .say }.arity), 0, 'Blocks that uses $_ implicitly have arity 0');
32 is(({ $_ }.count), 1, '{$_} is count 1');
33 is(({ .say }.count), 1, 'Blocks that uses $_ implicitly have count 1');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
34 }
35
36 {
734bc95b »
2009-03-29 [t/spec]
37 #?pugs 4 todo 'pointy blocks'
38 $_ = 'Ack';
39 dies_ok({ (-> { "Boo!" }).(42) }, '-> {} is arity 0');
40 dies_ok({ (-> { $_ }).(42) }, 'Even when we use $_>');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
41
48fe727a »
2009-10-20 [t/spec] more unfudges
42 #?rakudo 2 todo 'pointy blocks and $_'
734bc95b »
2009-03-29 [t/spec]
43 is((-> { $_ }).(), 'Ack!', '$_ is lexical here');
44 is(-> $a { $_ }.(42), 'Ack!', 'Even with parameters (?)');
45 is(-> $_ { $_ }.(42), 42, 'But not when the parameter is $_');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
46
2136dcbf »
2009-03-08 [implicit-parameter.t] placeholder conflict requires eval_die_ok
47 eval_dies_ok( 'sub () { -> { $^a }.() }', 'Placeholders not allowed in ->');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
48
49 is(-> { }.arity, 0, '->{} is arity 0, again');
50 }
51
52 {
d269ab06 »
2008-09-26 [t/spec] s/dies_ok/eval_dies_ok/ on a test that will fail at compile …
53 eval_dies_ok('sub { $^foo }.(42)', 'Placeholders not allowed in sub()');
4ced1fcf »
2008-09-26 [t] merge blocks/implicit_parameters.t into spec/
54 }
7f29bc53 »
2009-08-08 [t/spec] Add vim: lines everywhere.
55
56 # vim: ft=perl6
Something went wrong with that request. Please try again.