Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 49 lines (39 sloc) 1.035 kB
dcee930 [t] move macro tests to spec/ and unspecced/
moritz authored
1 use v6;
2
3 use Test;
4
820912f [t/spec] more smartlinks; less than 100 remain without smartlinks
moritz authored
5 # L<S06/Macros>
dcee930 [t] move macro tests to spec/ and unspecced/
moritz authored
6
7 plan 8;
8
9 {
10 my $was_in_macro;
11 macro dollar_foo { $was_in_macro = 1; '$COMPILING::foo' }
12 is $was_in_macro, 1, "string returning macro was called at compile time";
13 my $foo = 42;
14 is dollar_foo, $foo, "simple string returning macro (1)";
15 dollar_foo() = 23;
16 is $foo, 23, "simple string returning macro (2)";
17 }
18
19 {
20 my $ret = eval '
21 macro plus_3 { "+ 3" }
22 42 plus_3;
23 ';
ba8e84a [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
24 #?pugs todo 'feature'
25 is $ret, 45, "simple string returning macro (3)";
dcee930 [t] move macro tests to spec/ and unspecced/
moritz authored
26 };
27
28 {
29 macro four { '4' }
30 my $foo = 100 + four;
31 is $foo, 104, "simple string returning macro (4)";
32 }
33
34 {
35 macro prefix_1000 (Int $x) { "1000$x" }
36 is prefix_1000(42), 100042, "simple string returning macro (5)";
37 }
38
39 {
40 my $was_in_macro;
41 macro prefix_2000 (Int $x) { $was_in_macro = 1; "2000$x" }
42 is $was_in_macro, 1,
43 "simple string returning macro without argparens is parsed correctly (1)";
44 is (prefix_2000 42), 200042,
45 "simple string returning macro without argparens is parsed correctly (2)";
46 }
820912f [t/spec] more smartlinks; less than 100 remain without smartlinks
moritz authored
47
48 # vim: ft=perl6
Something went wrong with that request. Please try again.