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

use Test;
use Perl6::Parser;

use lib 't/lib/';
use Utils;

plan 25;

# Please note for the record that these tests aren't meant to cover the
# admittedly bewildering array (hee) of inputs these operators can take, they're
# just meant to cover the fact that the basic operators format correctly.
#
# The code being tested will never be executed, so I'm not concerned about
# whether a sample produces warnings or not. It'd be nice if it didn't, but
# not at the cost of extraneous terms.
#
# There are probably ways to bum down some of these tests as well, but as long
# as the operators remain operators I don't mind.
#
# For those operators that can generate or exist in list context, we're also not
# concerned about the context they generate in these tests. The text is meant to
# be very simple.
#
# There are also +=, R= and /= variants, those will be in separate files.
# As will the [+] hyperoperator, as it'll probably get a test suite of its own.

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

subtest {
  plan 4;
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{<a>};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::String ), Q{found string};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      < a >
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::String ), Q{found string};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{<>};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{(1)};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      ( 1 )
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{()};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q[{1}];
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Block ), Q{found block};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      { 1 }
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Block ), Q{found block};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q[{}];
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{[1]};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      [ 1 ]
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{[]}
}, Q{Term Precedence};

subtest {
  plan 15;
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my@a;@a[2]};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my @a; @a[ 2 ]
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{[]};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '{' '}'
      my $source = Q{my%a;%a{"foo"}};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '{' '}'
      my $source = Q:to[_END_];
      my %a; %a{ "foo" }
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{%a{}};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '<' '>'
      my $source = Q{my%a;%a<foo>};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '<' '>'
      my $source = Q:to[_END_];
      my %a; %a< foo >
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{%a{}};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '«' '»'
      my $source = Q{my%a;%a«foo»};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'a' and '«' '»'
      my $source = Q:to[_END_];
      my %a; %a« foo »
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{%a«»};
  
  subtest {
    plan 3;
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'chomp' and '(' ')'
      my $source = Q{chomp()};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no arguments, no ws};
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'chomp' and '(' ')'
      my $source = Q:to[_END_];
      chomp( )
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no arguments, ws};
    
    subtest {
      plan 2;

      # Whitespace sensitive between 'chomp' and '(' ')'
      my $source = Q:to[_END_];
      chomp( 1 )
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{with arguments};
  }, Q{func()};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.round
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.&round
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.&};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    Int.=round
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.=};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.^name
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.^};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.?name
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.?};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.+name
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.+};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42.*name
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{.*};
  
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    42>>.say
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};
    
    done-testing;
  }, Q{>>.};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my$a;$a.:<++>};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; $a.:< ++ >
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{.:};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my $a; $a.Foo::Bar};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; $a.Foo::Bar
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{.::};
}, Q{Method Postfix Precedence};

subtest {
  plan 4;
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my$a;++$a};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; ++$a
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{++$a};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my$a;--$a};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; --$a
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{--$a};
  
  subtest {
    plan 2;
    
    subtest {
      plan 2;

      my $source = Q{my$a;$a++};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{no ws};
    
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; $a++
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
      
      done-testing;
    }, Q{ws};
  }, Q{$a++};
  
  subtest {
    plan 2;
  
    subtest {
      plan 2;

      my $source = Q{my$a;$a--};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
  
      done-testing;
    }, Q{no ws};
  
    subtest {
      plan 2;

      my $source = Q:to[_END_];
      my $a; $a--
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};
  
      done-testing;
    }, Q{ws};
  }, Q{$a--};
}, Q{Autoincrement Precedence};

subtest {
  plan 2;

  subtest {
    plan 2;

    my $source = Q{1**2};
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

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

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 ** 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{ws};
}, Q{Exponentiation Precedence};

subtest {
  plan 9;

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{?2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      ? 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{?};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{!2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      ! 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{!};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    + 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{+};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    - 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{-};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    ~ 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{~};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    | 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{|};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    +^ 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{+^};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    ?^ 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{?^};

  subtest {
    plan 2;

    my $source = Q:to[_END_];
    ^ 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{^};
}, Q{Symbolic Unary Precedence};

subtest {
  plan 11;

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1*2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 * 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{*};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1/2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 / 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{/};

  # XXX '1div2' is illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 div 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{div};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1%2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 % 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{%};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1%%2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 %% 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{%%};

  # XXX '1mod2' is illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 mod 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{mod};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+&2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 +& 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+&};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+<2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 +< 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+<};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+>2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 +> 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+>};

  # XXX '1gcd2' is illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 gcd 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{gcd};

  # XXX '1lcm2' is illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 lcm 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{lcm};
}, Q{Multipicative Precedence};

subtest {
  plan 5;

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 + 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1=2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 - 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+|2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 +| 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+|};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1+^2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 +^ 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{+^};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{1?|2};
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

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

    subtest {
      plan 2;

      my $source = Q:to[_END_];
      1 ?| 2
      _END_
      my $tree = $pp.to-tree( $source );
      ok has-a( $tree, Perl6::Operator ), Q{found operator};
      is $pp.to-string( $tree ), $source, Q{formatted};

      done-testing;
    }, Q{ws};
  }, Q{?|};
}, Q{Additive Precedence};

subtest {
  plan 2;

  # XXX '1x2' is illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    1 x 2
    _END_
    my $tree = $pp.to-tree( $source );
    ok has-a( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

   