Revision 27961

Date:
2009/08/11 17:51:18
Author:
moritz
Revision Log:
[t/spec] embedded comments and unspaces now have a backtick
Files:

Legend:

 
Added
 
Removed
 
Modified
  • t/spec/S02-whitespace_and_comments/comments.t

     
    10 10 # "#" plus any bracket>
    11 11 {
    12 12
    13 ok #[
    13 ok #`[
    14 14 Multiline
    15 15 comments
    16 16 is fine
    17 ] 1, 'multiline embedded comment with #[]';
    17 ] 1, 'multiline embedded comment with #`[]';
    18 18
    19 ok #(
    19 ok #`(
    20 20 Parens works also
    21 ) 1, 'multiline embedded comment with #()';
    21 ) 1, 'multiline embedded comment with #`()';
    22 22
    23 ok eval("2 * 3\n #<<<\n comment>>>"), "multiline comment with <<<";
    23 ok eval("2 * 3\n #`<<<\n comment>>>"), "multiline comment with <<<";
    24 24
    25 my $var = #{ foo bar } 32;
    26 is $var, 32, 'embedded comment with #{}';
    25 my $var = #`{ foo bar } 32;
    26 is $var, 32, 'embedded comment with #`{}';
    27 27
    28 $var = 3 + #「 this is a comment 」 56;
    28 $var = 3 + #`「 this is a comment 」 56;
    29 29 is $var, 59, 'embedded comment with LEFT/RIGHT CORNER BRACKET';
    30 30
    31 is 2 #『 blah blah blah 』 * 3, 6, 'embedded comment with LEFT/RIGHT WHITE CORNER BRACKET';
    31 is 2 #`『 blah blah blah 』 * 3, 6, 'embedded comment with LEFT/RIGHT WHITE CORNER BRACKET';
    32 32
    33 33 my @list = 'a'..'c';
    34 34
    35 is @list[ #(注释)2 ], 'c', 'embedded comment with FULLWIDTH LEFT/RIGHT PARENTHESIS';
    35 is @list[ #`(注释)2 ], 'c', 'embedded comment with FULLWIDTH LEFT/RIGHT PARENTHESIS';
    36 36
    37 is @list[ 0 #《注释》], 'a', 'embedded comment with LEFT/RIGHT DOUBLE ANGLE BRACKET';
    37 is @list[ 0 #`《注释》], 'a', 'embedded comment with LEFT/RIGHT DOUBLE ANGLE BRACKET';
    38 38
    39 is @list[#〈注释〉1], 'b', 'embedded comment with LEFT/RIGHT ANGLE BRACKET';
    39 is @list[#`〈注释〉1], 'b', 'embedded comment with LEFT/RIGHT ANGLE BRACKET';
    40 40
    41 41 # Note that 'LEFT/RIGHT SINGLE QUOTATION MARK' (i.e. ‘’) and
    42 42 # LEFT/RIGHT DOUBLE QUOTATION MARK (i.e. “”) are not valid delimiter
    43 43 # characters.
    44 44
    45 45 #test some 13 more lucky unicode bracketing pairs
    46 is(1 #᚛ pa ᚜ +1, 2, 'embedded comment with #᚛᚜');
    47 is(1 #⁅ re ⁆ +2, 3, 'embedded comment with #⁅⁆');
    48 is(2 #⁽ ci ⁾ +3, 5, 'embedded comment with #⁽⁾');
    49 is(3 #❨ vo ❩ +5, 8, 'embedded comment with #❨ vo ❩');
    50 is(5 #❮ mu ❯ +8, 13, 'embedded comment with #❮❯');
    51 is(8 #❰ xa ❱ +13, 21, 'embedded comment with #❰❱');
    52 is(13 #❲ ze ❳ +21, 34, 'embedded comment with #❲❳');
    53 is(21 #⟦ bi ⟧ +34, 55, 'embedded comment with #⟦⟧');
    54 is(34 #⦅ so ⦆ +55, 89, 'embedded comment with #⦅⦆');
    55 is(55 #⦓ pano ⦔ +89, 144, 'embedded comment with #⦓⦔');
    56 is(144 #⦕ papa ⦖ +233, 377, 'embedded comment with #⦕⦖');
    57 is(377 #『 pare 』 +610, 987, 'embedded comment with #『』');
    58 is(610 #﴾ paci ﴿ +987, 1597, 'embedded comment with #﴾﴿');
    46 is(1 #`᚛ pa ᚜ +1, 2, 'embedded comment with #`᚛᚜');
    47 is(1 #`⁅ re ⁆ +2, 3, 'embedded comment with #`⁅⁆');
    48 is(2 #`⁽ ci ⁾ +3, 5, 'embedded comment with #`⁽⁾');
    49 is(3 #`❨ vo ❩ +5, 8, 'embedded comment with #`❨ vo ❩');
    50 is(5 #`❮ mu ❯ +8, 13, 'embedded comment with #`❮❯');
    51 is(8 #`❰ xa ❱ +13, 21, 'embedded comment with #`❰❱');
    52 is(13 #`❲ ze ❳ +21, 34, 'embedded comment with #`❲❳');
    53 is(21 #`⟦ bi ⟧ +34, 55, 'embedded comment with #`⟦⟧');
    54 is(34 #`⦅ so ⦆ +55, 89, 'embedded comment with #`⦅⦆');
    55 is(55 #`⦓ pano ⦔ +89, 144, 'embedded comment with #⦓`⦔');
    56 is(144 #`⦕ papa ⦖ +233, 377, 'embedded comment with #`⦕⦖');
    57 is(377 #`『 pare 』 +610, 987, 'embedded comment with #`『』');
    58 is(610 #`﴾ paci ﴿ +987, 1597, 'embedded comment with #`﴾﴿');
    59 59 }
    60 60
    61 61 # L<S02/"Whitespace and Comments"/"no space" between "#" and bracket>
    62 62 {
    63 63
    64 ok !eval("3 * # (invalid comment) 2"), "no space allowed between '#' and '('";
    65 ok !eval("3 * #\t[invalid comment] 2"), "no tab allowed between '#' and '['";
    66 ok !eval("3 * # \{invalid comment\} 2"), "no spaces allowed between '#' and '\{'";
    67 ok !eval("3 * #\n<invalid comment> 2"), "no spaces allowed between '#' and '<'";
    64 ok !eval("3 * #` (invalid comment) 2"), "no space allowed between '#`' and '('";
    65 ok !eval("3 * #`\t[invalid comment] 2"), "no tab allowed between '#`' and '['";
    66 ok !eval("3 * #` \{invalid comment\} 2"), "no spaces allowed between '#`' and '\{'";
    67 ok !eval("3 * #`\n<invalid comment> 2"), "no spaces allowed between '#`' and '<'";
    68 68
    69 69 }
    70 70
     
    72 72 # "closing brackets">
    73 73 {
    74 74
    75 ok #<<<
    75 ok #`<<<
    76 76 Or this <also> works...
    77 >>> 1, '#<<<...>>>';
    77 >>> 1, '#`<<<...>>>';
    78 78
    79 my $var = \#((( comment ))) 12;
    80 is $var, 12, '#(((...)))';
    79 my $var = \#`((( comment ))) 12;
    80 is $var, 12, '#`(((...)))';
    81 81
    82 is(5 * #<< < >> 5, 25, '#<< < >>');
    82 is(5 * #`<< < >> 5, 25, '#`<< < >>');
    83 83
    84 is(6 * #<< > >> 6, 36, '#<< > >>');
    84 is(6 * #`<< > >> 6, 36, '#`<< > >>');
    85 85 }
    86 86
    87 87 # L<S02/"Whitespace and Comments"/"Brackets may be nested">
    88 88 #?rakudo skip 'nested brackets'
    89 89 {
    90 is 3, #(
    90 is 3, #`(
    91 91 (Nested parens) works also
    92 ) 3, 'nested parens #(...(...)...)';
    92 ) 3, 'nested parens #`(...(...)...)';
    93 93
    94 is 3, #{
    94 is 3, #`{
    95 95 {Nested braces} works also {}
    96 } 3, 'nested braces #{...{...}...}';
    96 } 3, 'nested braces #`{...{...}...}';
    97 97 }
    98 98
    99 99 # I am not sure if this is speced somewhere:
    100 100 # comments can be nested
    101 101 #?rakudo skip 'nested brackets'
    102 102 {
    103 is 3, #(
    103 is 3, #`(
    104 104 comment
    105 #{
    105 #`{
    106 106 internal comment
    107 107 }
    108 108 more comment
    109 109 ) 3, 'comments can be nested with different brackets';
    110 is 3, #(
    110 is 3, #`(
    111 111 comment
    112 #(
    112 #`(
    113 113 internal comment
    114 114 )
    115 115 more
    116 116 ) 3, 'comments can be nested with same brackets';
    117 117
    118 118 # TODO:
    119 # ok eval(" #{ comment }") failes with an error as it tries to execute
    120 # comment() before seeing that I meant #{ comment within this string.
    119 # ok eval(" #`{ comment }") failes with an error as it tries to execute
    120 # comment() before seeing that I meant #`{ comment within this string.
    121 121
    122 122 #?pugs todo 'bug'
    123 ok eval(" #<<\n comment\n # >>\n >> 3"),
    123 ok eval(" #`<<\n comment\n # >>\n >> 3"),
    124 124 'single line comment cannot correctly nested within multiline';
    125 125 }
    126 126
     
    128 128 # "applies only to" "pairs of brackets of the same length">
    129 129 #?rakudo skip 'nested parens and braces'
    130 130 {
    131 is -1 #<<<
    131 is -1 #`<<<
    132 132 Even <this> <<< also >>> works...
    133 133 >>>, -1, 'nested brackets in embedded comment';
    134 134
    135 is 'cat', #{{
    135 is 'cat', #`{{
    136 136 This comment contains unmatched } and { { { { (ignored)
    137 137 Plus a nested {{ ... }} pair (counted)
    138 138 }} 'cat', 'embedded comments with nested/unmatched bracket chars';
     
    150 150 # L<S02/Whitespace and Comments/"comment may not contain an unspace">
    151 151 {
    152 152 my $a;
    153 ok !eval '$a = #\ (comment) 32', "comments can't contain unspace";
    153 ok !eval '$a = #`\ (comment) 32', "comments can't contain unspace";
    154 154 ok !$a.defined, '$a remains undef';
    155 155 }
    156 156
  • t/spec/S02-whitespace_and_comments/unspace.t

     
    8 8
    9 9
    10 10 ok(4\ .sqrt == 2, 'unspace with numbers');
    11 is(4\#(quux).sqrt, 2, 'unspace with comments');
    11 is(4\#`(quux).sqrt, 2, 'unspace with comments');
    12 12 is("x"\ .chars, 1, 'unspace with strings');
    13 13 is("x"\ .chars(), 1, 'unspace with strings + parens');
    14 14
     
    67 67 is((foo \ .lc), 'b', 'not a unspace');
    68 68 eval_dies_ok('fo\ o.lc', 'unspace not allowed in identifier');
    69 69 is((foo\ .lc), 'a', 'longer dot');
    70 is((foo\#( comment ).lc), 'a', 'unspace with embedded comment');
    70 is((foo\#`( comment ).lc), 'a', 'unspace with embedded comment');
    71 71 #?rakudo skip 'unimplemented'
    72 72 eval_dies_ok('foo\#\ ( comment ).lc', 'unspace can\'t hide space between # and opening bracket');
    73 73 is((foo\ # comment
     
    266 266 is($n, 2, 'check $n');
    267 267
    268 268 # L<S02/"Lexical Conventions"/"U+301D codepoint has two closing alternatives">
    269 is((foo\#〝 comment 〞.id), 'a', 'unspace with U+301D/U+301E comment');
    270 eval_dies_ok('foo\#〝 comment 〟.id', 'unspace with U+301D/U+301F is invalid');
    269 is((foo\#`〝 comment 〞.id), 'a', 'unspace with U+301D/U+301E comment');
    270 eval_dies_ok('foo\#`〝 comment 〟.id', 'unspace with U+301D/U+301F is invalid');
    271 271
    272 272 # L<S02/"Whitespace and Comments"/".123">
    273 273 # .123 is equal to 0.123
  • t/spec/S04-blocks-and-statements/temp.t

     
    130 130 # too, but then it dies complaining about not finding a matching temp()
    131 131 # function. So, for now, we just comment the following block and add
    132 132 # unconditional flunk()s.
    133 #{
    133 # {
    134 134 # #?pugs 4 todo 'feature'
    135 135 # is temp(advance()), 3, "TEMP{} block (5)";
    136 136 # is $next, 4, "TEMP{} block (6)";
    137 137 # is temp(advance()), 4, "TEMP{} block (7)";
    138 138 # is temp(advance()), 5, "TEMP{} block (8)";
    139 #} # $next = 3
    139 # } # $next = 3
    140 140
    141 141 is $next, 3, "TEMP{} block (9)";
    142 142 is advance(), 3, "TEMP{} block (10)";
  • t/spec/S05-metasyntax/charset.t

     
    51 51
    52 52 # RT #67124
    53 53 #?rakudo todo 'comment in charset (RT #67124)'
    54 eval_lives_ok( '"foo" ~~ /<[f] #[comment] + [o]>/',
    54 eval_lives_ok( '"foo" ~~ /<[f] #`[comment] + [o]>/',
    55 55 'comment embedded in charset can be parsed' );
    56 56 #?rakudo skip 'comment in charset (RT #67124)'
    57 ok( "foo" ~~ /<[f] #[comment] + [o]>/, 'comment embedded in charset works' );
    57 ok( "foo" ~~ /<[f] #`[comment] + [o]>/, 'comment embedded in charset works' );
    58 58
    59 59 # RT #67122
    60 60 #?rakudo skip 'large \\x char spec in regex (RT #67122) (noauto)'