### ----------------------------------------------------
### -- Graphviz::DOT::Grammar
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/01-basic-parsing.rakutest
### ----------------------------------------------------
use v6.d;

use lib <. lib>;
use Graphviz::DOT::Grammar;

use Test;

plan *;

#====================================================================
## 1
#====================================================================
my $graph = q:to/END/;
digraph { a -> b }
END

ok dot-parse($graph), "One liner";

#====================================================================
## 2
#====================================================================
my $graph2 = q:to/END/;
digraph {
    label = "First"
    a -> b
    b -> c
    c -> a
}
END

ok dot-parse($graph2), "Labeled triangle";

#====================================================================
## 3
#====================================================================
my $graph3 = q:to/END/;
digraph {
    // Simple graph
    label = "First";
    a -> b;
    b -> c;
    c -> a;
}
END

ok dot-parse($graph3), "Labeled triangle, sep => <;>";

#====================================================================
## 4
#====================================================================

my $graph4 = q:to/END/;
graph {
  label="Vincent van Gogh Paintings"

  subgraph cluster_self_portraits {
    label="Self-portraits"

    spwgfh [label="Self-Portrait with Grey Felt Hat"]
    spaap [label="Self-Portrait as a Painter"]
  }

  subgraph cluster_flowers {
    label="Flowers"

    sf [label="Sunflowers"]
    ab [label="Almond Blossom"]
  }
}
END

ok dot-parse($graph4), "van Gogh example";

#====================================================================
## 5
#====================================================================
my $graph5 = q:to/END/;
graph {
"0" [pos="-5.196152422707,-3!"];
"1" [pos="-5.196152422707,-1!"];
"4" [pos="-1.732050807569,-3!"];
"5" [pos="-1.732050807569,-1!"];
"2" [pos="-3.464101615138,-4!"];
"3" [pos="-3.464101615138,0!"]
"4" -- "5"
"3" -- "5"
"0" -- "1"
"0" -- "2"
"2" -- "4"
"1" -- "3"
}
END

ok dot-subparse($graph5), "Hexagon graph";

#====================================================================
## 6
#====================================================================

my $graph6 = q:to/END/;
digraph chesboard {
    node [shape=box, width=0.5, height=0.5, style=filled];

    // Hide edges for clear visualization
    edge [style=invis];

    // Connect nodes horizontally
    a1 -> b1 -> c1 -> d1 -> e1 -> f1 -> g1 -> h1;
    a2 -> b2 -> c2 -> d2 -> e2 -> f2 -> g2 -> h2;
    a3 -> b3 -> c3 -> d3 -> e3 -> f3 -> g3 -> h3;
    a4 -> b4 -> c4 -> d4 -> e4 -> f4 -> g4 -> h4;
    a5 -> b5 -> c5 -> d5 -> e5 -> f5 -> g5 -> h5;
    a6 -> b6 -> c6 -> d6 -> e6 -> f6 -> g6 -> h6;
    a7 -> b7 -> c7 -> d7 -> e7 -> f7 -> g7 -> h7;
    a8 -> b8 -> c8 -> d8 -> e8 -> f8 -> g8 -> h8;

    // Connect nodes vertically
    a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8;
    b1 -> b2 -> b3 -> b4 -> b5 -> b6 -> b7 -> b8;
    c1 -> c2 -> c3 -> c4 -> c5 -> c6 -> c7 -> c8;
    d1 -> d2 -> d3 -> d4 -> d5 -> d6 -> d7 -> d8;
    e1 -> e2 -> e3 -> e4 -> e5 -> e6 -> e7 -> e8;
    f1 -> f2 -> f3 -> f4 -> f5 -> f6 -> f7 -> f8;
    g1 -> g2 -> g3 -> g4 -> g5 -> g6 -> g7 -> g8;
    h1 -> h2 -> h3 -> h4 -> h5 -> h6 -> h7 -> h8;
}
END

ok dot-parse($graph6), "Chessboard edges";

done-testing;


