### ----------------------------------------------------
### -- Perl6::Parser
### -- Licenses: Artistic-2.0
### -- Authors: Jeffrey Goff <drforr@pobox.com>
### -- File: t/16-quote.t
### ----------------------------------------------------
### -- Chunk 1 of 4
use v6;

use Test;
use Perl6::Parser;

use lib 't/lib';
use Utils;

plan 16;

my $pp                 = Perl6::Parser.new;
my $*CONSISTENCY-CHECK = True;
my $*FALL-THROUGH      = True;

#
# String and qw() delimiters should be balanced.
# The code uses symmetric RE's to parse, and the temptation to reuse the first
# term is strong.
#
# Also, < > for delimiters instead of something closer to the braces of the
# surrounding text, just for visual clarity.
#

#
# It's also worth pointing out that I'm not testing the language itself, so
# variants like Q |foo| and Q $foo$, while entertaining, really aren't in
# the scope of what I'm testing.
#
# All I want to know is whether Q<foo> catches the '<' and '>' individually,
# not whether the parser catches all the variations.
#

# (thankfully :q, even though it's logical as an adverb is illegal)

#
# Longest and loudest (most capitals) prefixes first.
#
# Also, only worry about whitespace *inside* adverb selection.
#

# Qqww is illegal

subtest {
  # qqww:q is illegal
  subtest {
    subtest {
      my $source = Q{qqww :to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};

      done-testing;
    }, Q{all intervening ws};

    subtest {
      my $source = Q{qqww :to<END>
pi
END};
      
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};

    subtest {
      my $source = Q{qqww:to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};

    subtest {
      my $source = Q{qqww:to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};

    done-testing;
  }, Q{Qx:to<pi>};

  subtest {
    subtest {
      my $source = Q{qqww :w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqww :w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqww:w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqww:w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{qqww:w<pi>};
  
  subtest {
    subtest {
      my $source = Q{qqww :x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqww :x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqww:x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqww:x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qqww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{qqww:x<pi>};
  
  subtest {
    my $source = Q{qqww <pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
           Q{correct type};
    is $node.quote, Q{qqww}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{ws, no adverbs};
  
  subtest {
    my $source = Q{qqww<pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::WordQuoting::QuoteProtection,
           Q{correct type};
    is $node.quote, Q{qqww}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{no ws, no adverbs};
  
  done-testing;
}, Q{qqww<>};

# Qqw is illegal

# Qqx is illegal

subtest {
  # qqw:q is illegal
  
  subtest {
    subtest {
      my $source = Q{qqw :to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};

    subtest {
      my $source = Q{qqw :to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};

    subtest {
      my $source = Q{qqw:to <END>
p   
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};

    subtest {
      my $source = Q{qqw:to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};

    done-testing;
  }, Q{adverb :to};

  subtest {
    subtest {
      my $source = Q{qqw :w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqw :w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqw:w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqw:w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{adverb :w};

  subtest {
    subtest {
      my $source = Q{qqw :x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqw :x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqw:x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqw:x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
      is $node.quote, Q{qqw}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{adverb :x};
  
  subtest {
    my $source = Q{qqw <pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
    is $node.quote, Q{qqw}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{ws, no adverbs};
  
  subtest {
    my $source = Q{qqw<pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::WordQuoting,
             Q{correct type};
    is $node.quote, Q{qqw}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{no ws, no adverbs};
  
  done-testing;
}, Q{qqw<>};

subtest {
  # qqx:q is illegal
  
  subtest {
    subtest {
      my $source = Q{qqx :to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};

    subtest {
      my $source = Q{qqx :to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};;
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};

    subtest {
      my $source = Q{qqx:to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};

    subtest {
      my $source = Q{qqx:to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];

      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};

      done-testing;
    }, Q{no intervening ws};

    done-testing;
  }, Q{adverb :to};

  subtest {
    subtest {
      my $source = Q{qqx :w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqx :w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqx:w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqx:w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{adverb :w};
  
  subtest {
    subtest {
      my $source = Q{qqx :x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qqx :x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qqx:x <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qqx:x<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
      is $node.quote, Q{qqx}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};
    
    done-testing;
  }, Q{adverb :x};
  
  subtest {
    my $source = Q{qqx <pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
    is $node.quote, Q{qqx}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{ws, no adverbs};
  
  subtest {
    my $source = Q{qqx<pi>};
    my $tree = $pp.to-tree( $source );
    my $node = $tree.child.[0].child.[0];
    
    is $pp.to-string( $tree ), $source, Q{formatted};
    isa-ok $node, Perl6::String::Interpolation::Shell,
             Q{correct type};
    is $node.quote, Q{qqx}, Q{quote name};
    is $node.delimiter-start, Q{<}, Q{start delimiter};
    is $node.delimiter-end, Q{>}, Q{end delimiter};
    
    done-testing;
  }, Q{no ws, no adverbs};
  
  done-testing;
}, Q{qqx<>};

subtest {
  # qww:q is illegal
  
  subtest {
    subtest {
      my $source = Q{qww :to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};

    subtest {
      my $source = Q{qww :to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};

    subtest {
      my $source = Q{qww:to <END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
      
    subtest {
      my $source = Q{qww:to<END>
pi
END};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{no intervening ws};

    done-testing;
  }, Q{adverb :to};

  subtest {
    subtest {
      my $source = Q{qww :w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{all intervening ws};
    
    subtest {
      my $source = Q{qww :w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{leading intervening ws};
    
    subtest {
      my $source = Q{qww:w <pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
      is $pp.to-string( $tree ), $source, Q{formatted};
      isa-ok $node, Perl6::String::WordQuoting::QuoteProtection,
             Q{correct type};
      is $node.quote, Q{qww}, Q{quote name};
      is $node.delimiter-start, Q{<}, Q{start delimiter};
      is $node.delimiter-end, Q{>}, Q{end delimiter};
      
      done-testing;
    }, Q{trailing intervening ws};
    
    subtest {
      my $source = Q{qww:w<pi>};
      my $tree = $pp.to-tree( $source );
      my $node = $tree.child.[0].child.[0];
      
