/*
 * Copyright (C) 2014 Francis Galiegue <fgaliegue@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.parboiled1.grappa.matchers.join;

public final class JoinMatcherTest
{
}

@@ -673,43 +673,1767 @@
 n;%0A%0A
-public final class JoinMatcherTest%0A%7B
+import com.github.parboiled1.grappa.parsers.JoinParser;%0Aimport org.assertj.core.api.SoftAssertions;%0Aimport org.parboiled.Parboiled;%0Aimport org.parboiled.Rule;%0Aimport org.parboiled.annotations.SuppressNode;%0Aimport org.parboiled.errors.GrammarException;%0Aimport org.parboiled.errors.ParserRuntimeException;%0Aimport org.parboiled.parserunners.BasicParseRunner;%0Aimport org.parboiled.parserunners.ParseRunner;%0Aimport org.testng.annotations.Test;%0A%0Aimport static org.assertj.core.api.Assertions.fail;%0A%0Apublic final class JoinMatcherTest%0A%7B%0A    static class MyParser%0A        extends JoinParser%3CObject%3E%0A    %7B%0A        @SuppressNode%0A        Rule rule()%0A        %7B%0A            return join(zeroOrMore('a'))%0A                .using(optional('b').label(%22foo%22))%0A                .min(0);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void joinMatcherYellsIfJoiningRuleMatchesEmpty()%0A    %7B%0A        final CharSequence input = %22aaaabaaaaxaaa%22;%0A        final MyParser parser = Parboiled.createParser(MyParser.class);%0A        final ParseRunner%3CObject%3E runner%0A            = new BasicParseRunner%3CObject%3E(parser.rule());%0A        final String expectedMessage = %22joining rule (foo) of a JoinMatcher%22 +%0A            %22 cannot match an empty character sequence!%22;%0A%0A        try %7B%0A            runner.run(input);%0A            fail(%22No exception thrown!!%22);%0A        %7D catch (ParserRuntimeException e) %7B%0A            final SoftAssertions soft = new SoftAssertions();%0A            final Throwable cause = e.getCause();%0A            soft.assertThat(cause).as(%22cause has correct class%22)%0A                .isExactlyInstanceOf(GrammarException.class);%0A            soft.assertThat(cause).as(%22exception has the correct message%22)%0A                .hasMessage(expectedMessage);%0A            soft.assertAll();%0A        %7D%0A    %7D%0A
 %0A%7D%0A

test the "no empty submatch for joining" case