### ----------------------------------------------------
### -- Perl6::Parser
### -- Licenses: Artistic-2.0
### -- Authors: Jeffrey Goff <drforr@pobox.com>
### -- File: t/19-operators.t
### ----------------------------------------------------
### -- Chunk 3 of 3
( $tree, Perl6::Operator ), Q{found operator};
    is $pp.to-string( $tree ), $source, Q{formatted};

    done-testing;
  }, Q{ws};
}, Q{Comma Operator Precedence};

# XXX 'X' and 'Z' have a lot of variants, test separately?
#
subtest {
  plan 3;

  # XXX '3Z2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 Z 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{Z};

  # XXX '3X2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 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};

    done-testing;
  }, Q{X};

  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{List Infix Precedence};

subtest {
  plan 5;

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{my$a=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_];
      my $a = 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{my$a:=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_];
      my $a := 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{:=};

  # XXX "::= NIY";

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{...};
      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_];
      ...
      _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 $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_];
      !!!
      _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 $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_];
      ???
      _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 Undecided on [+] implementation
}, Q{List Prefix Precedence};

subtest {
  plan 2;

  # XXX '3and2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 and 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{and};

  # XXX '3andthen2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 andthen 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{andthen};
}, Q{Loose AND Precedence};

subtest {
  plan 2;

  # XXX '3or2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 or 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{or};

  # XXX '3orelse2' illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    3 orelse 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{orelse};
}, Q{Loose OR Precedence};

subtest {
  plan 2;

  # XXX "@a<=='a'" illegal
  subtest {
    plan 2;

    my $source = Q:to[_END_];
    my @a; @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{<==};

  subtest {
    plan 2;

    subtest {
      plan 2;

      my $source = Q{my@a;'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' ==> @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{==>};
}, Q{Sequencer Precedence};

# vim: ft=perl6


