### ----------------------------------------------------
### -- Config::TOML
### -- Licenses: Unlicense
### -- Authors: 
### -- File: t/grammar-actions/02-arrays.rakutest
### ----------------------------------------------------
### -- Chunk 3 of 3
━━━━━━━━━┛
        EOF
    );
    is(
        $match-array-of-empty-arrays.made,
        [[[[[]]]]],
        q:to/EOF/
        ♪ [Is expected array value?] - 102 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-array-of-empty-arrays.made ~~ [ ... ]
        ┃   Success   ┃
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
});

# end array of arrays grammar-actions tests }}}
# array of inline tables grammar-actions tests {{{

subtest({
    my Str $array-of-inline-tables = Q:to/EOF/.trim;
    [ { x = 1, y = 2, z = 3 },
      { x = 7, y = 8, z = 9 },
      { x = 2, y = 4, z = 8 } ]
    EOF

    my Config::TOML::Parser::Actions $actions .= new;
    my $match-array-of-inline-tables =
        Config::TOML::Parser::Grammar.parse(
            $array-of-inline-tables,
            :$actions,
            :rule<array>
        );

    is(
        $match-array-of-inline-tables.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse($array-of-inline-tables, :rule<array>)] - 103 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal array of inline tables
        ┃   Success   ┃    successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );

    is(
        $match-array-of-inline-tables.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 104 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-array-of-inline-tables.made.WHAT ~~ Array
        ┃   Success   ┃
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );

    is(
        $match-array-of-inline-tables.made,
        [
            %( x => 1, y => 2, z => 3 ),
            %( x => 7, y => 8, z => 9 ),
            %( x => 2, y => 4, z => 8 )
        ],
        q:to/EOF/
        ♪ [Is expected array value?] - 105 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-array-of-inline-tables.made ~~ [ ... ]
        ┃   Success   ┃
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
});

# end array of inline tables grammar-actions tests }}}
# commented array grammar-actions tests {{{

subtest({
    my Str $commented-array-of-mixed-strings = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        'a', # this is ok
        "b",# this is ok
        '''c'''# this is ok
        , """d"""# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    my Str $commented-array-of-integers = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        1, # this is ok
        2,# this is ok
        3# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    my Str $commented-array-of-floats = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        +1.1, # this is ok
        -2e1_000,# this is ok
        0.0000001# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    my Str $commented-array-of-booleans = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        true, # this is ok
        false,# this is ok
        true# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    my Str $commented-array-of-date-times = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        1979-05-27T07:32:00Z, # this is ok
        1979-05-27T00:32:00-07:00,# this is ok
        1979-05-27T00:32:00.999999-07:00,# this is ok
        1979-05-27T07:32:00,# this is ok
        1979-05-27T00:32:00.999999,# this is ok
        1979-05-27# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    my Str $commented-array-of-arrays = Q:to/EOF/.trim;
    [# this is ok
        # this is ok
        [ [ 1, 2 ], [3, 4, 5] ], # this is ok
        [ [ 1, 2 ], ["a", "b", "c"] ],# this is ok
        [# this is ok
            # this is ok
            [ # this is ok
                # this is ok
                [#this is ok
                    # this is ok
                    # this is ok
                    '''#this is not a comment
                    line one # this is not a comment
                    line two # this is not a comment
                    line three # this is not a comment
                    ''',# this is ok
                    # this is ok
                    # this is ok
                    """
                    line four
                    line five
                    line six
                    """ # this is ok
                    # this is ok
                    # this is ok
                ], # this is ok
                [# this is ok
                    # this is ok
                    # this is ok
                    '''
                    line seven
                    line eight
                    line nine
                    ''', # this is ok
                    # this is ok
                    """
                    line ten
                    line eleven
                    line twelve
                    """#this is ok
                    # this is ok
                    # this is ok
                    # this is ok
                ],# this is ok
            # this is ok
            # this is ok
            # this is ok
            ], # this is ok
            # this is ok
            # this is ok
            [# this is ok
                3,# this is ok
                6,# this is ok
                9# this is ok
            ]# this is ok
        ]# this is ok
        # this is ok
        # this is ok
        # this is ok
    ]
    EOF

    # assume UTC when local offset unspecified in TOML dates
    my Config::TOML::Parser::Actions $actions .= new(:date-local-offset(0));
    my $match-commented-array-of-mixed-strings =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-mixed-strings,
            :$actions,
            :rule<array>
        );
    my $match-commented-array-of-integers =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-integers,
            :$actions,
            :rule<array>
        );
    my $match-commented-array-of-floats =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-floats,
            :$actions,
            :rule<array>
        );
    my $match-commented-array-of-booleans =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-booleans,
            :$actions,
            :rule<array>
        );
    my $match-commented-array-of-date-times =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-date-times,
            :$actions,
            :rule<array>
        );
    my $match-commented-array-of-arrays =
        Config::TOML::Parser::Grammar.parse(
            $commented-array-of-arrays,
            :$actions,
            :rule<array>
        );

    is(
        $match-commented-array-of-mixed-strings.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse(
              $commented-array-of-mixed-strings,
              :rule<array>
           )] - 106 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of mixed-strings successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-integers.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse($commented-array-of-integers, :rule<array>)] - 107 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of integers successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-floats.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse($commented-array-of-floats, :rule<array>)] - 108 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of floats successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-booleans.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse($commented-array-of-booleans, :rule<array>)] - 109 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of booleans successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-date-times.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse(
              $commented-array-of-date-times,
              :rule<array>
           )] - 110 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of datetimes successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-arrays.WHAT,
        Config::TOML::Parser::Grammar,
        q:to/EOF/
        ♪ [Grammar.parse($commented-array-of-arrays, :rule<array>)] - 111 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ Parses string literal commented array
        ┃   Success   ┃    of arrays successfully
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );

    is(
        $match-commented-array-of-mixed-strings.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 112 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-mixed-strings.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-integers.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 113 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-integers.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-floats.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 114 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-floats.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-booleans.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 115 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-booleans.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-date-times.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 116 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-date-times.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-arrays.made.WHAT,
        Array,
        q:to/EOF/
        ♪ [Is array?] - 117 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-arrays.made.WHAT
        ┃   Success   ┃        ~~ Array
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );

    is(
        $match-commented-array-of-mixed-strings.made,
        ["a", "b", "c", "d"],
        q:to/EOF/
        ♪ [Is expected array value?] - 118 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-mixed-strings.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-integers.made,
        [1, 2, 3],
        q:to/EOF/
        ♪ [Is expected array value?] - 119 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-integers.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-floats.made,
        [1.1, -2e1000, 0.0000001],
        q:to/EOF/
        ♪ [Is expected array value?] - 120 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-floats.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-booleans.made,
        [True, False, True],
        q:to/EOF/
        ♪ [Is expected array value?] - 121 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-booleans.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-date-times.made,
        [
            '1979-05-27T07:32:00Z',
            '1979-05-27T00:32:00-07:00',
            '1979-05-27T00:32:00.999999-07:00',
            '1979-05-27T07:32:00Z',
            '1979-05-27T00:32:00.999999Z',
            '1979-05-27'
        ],
        q:to/EOF/
        ♪ [Is expected array value?] - 122 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-date-times.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
    is(
        $match-commented-array-of-arrays.made,
        [
            [
                [1, 2],
                [3, 4, 5]
            ],
            [
                [1, 2],
                ["a", "b", "c"]
            ],
            [
                [
                    ["#this is not a comment\n                line one # this is not a comment\n                line two # this is not a comment\n                line three # this is not a comment\n                ", "                line four\n                line five\n                line six\n                "],
                    ["                line seven\n                line eight\n                line nine\n                ", "                line ten\n                line eleven\n                line twelve\n                "]
                ],
                [3, 6, 9]
            ]
        ],
        q:to/EOF/
        ♪ [Is expected array value?] - 123 of 123
        ┏━━━━━━━━━━━━━┓
        ┃             ┃  ∙ $match-commented-array-of-arrays.made
        ┃   Success   ┃        ~~ [ ... ]
        ┃             ┃
        ┗━━━━━━━━━━━━━┛
        EOF
    );
});

# end commented array grammar-actions tests }}}

# vim: expandtab shiftwidth=4


