root/t/macros/string_returning_macros.t

Revision 21719, 1.1 kB (checked in by lwall, 5 months ago)

[STD] detect obsolete use of =cut
[t/*.t] delete obsolete uses of =cut

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5=begin pod
6=head1 DESCRIPTION
7
8This test tests for basic macro support. Note that much of macros isn't specced
9yet.
10
11See L<A06/"Macros">.
12
13=end pod
14
15plan 8;
16
17{
18  my $was_in_macro;
19  macro dollar_foo { $was_in_macro = 1; '$foo' }
20  is $was_in_macro, 1, "string returning macro was called at compile time";
21  my $foo = 42;
22  is dollar_foo, $foo, "simple string returning macro (1)";
23  dollar_foo() = 23;
24  is $foo, 23, "simple string returning macro (2)";
25}
26
27{
28  my $ret = eval '
29    macro plus_3 { "+ 3" }
30    42 plus_3;
31  ';
32  is $ret, 45, "simple string returning macro (3)", :todo<feature>;
33};
34
35{
36  macro four { '4' }
37  my $foo = 100 + four;
38  is $foo, 104, "simple string returning macro (4)";
39}
40
41{
42  macro prefix_1000 (Int $x) { "1000$x" }
43  is prefix_1000(42), 100042, "simple string returning macro (5)";
44}
45
46{
47  my $was_in_macro;
48  macro prefix_2000 (Int $x) { $was_in_macro = 1; "2000$x" }
49  is $was_in_macro, 1,
50    "simple string returning macro without argparens is parsed correctly (1)";
51  is (prefix_2000 42), 200042,
52    "simple string returning macro without argparens is parsed correctly (2)";
53}
Note: See TracBrowser for help on using the browser.