/* This file is part of SableCC ( http://sablecc.org ).
 * 
 * See the NOTICE file distributed with this work for copyright information.
 *
 * 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 ticket39;

import org.junit.Test;
import org.sablecc.sablecc.alphabet.AdjacencyRealm;
import org.sablecc.sablecc.automaton.Dfa;
import org.sablecc.sablecc.automaton.MinimalDfa;
import org.sablecc.sablecc.automaton.Nfa;

public class PartitioningBug {

    @Test
    public void bug() {

        AdjacencyRealm<Character> charRealm = new AdjacencyRealm<Character>() {

            @Override
            public boolean isAdjacent(
                    Character bound1,
                    Character bound2) {

                return bound1 + 1 == bound2;
            }

            @Override
            public Character next(
                    Character bound) {

                return (char) (bound + 1);
            }

            @Override
            public Character previous(
                    Character bound) {

                return (char) (bound - 1);
            }

        };

        Nfa<Character> any = new Nfa<Character>(charRealm.createInterval('A',
                'Z'));
        Nfa<Character> e = new Nfa<Character>(charRealm.createInterval('E'));
        Nfa<Character> t = new Nfa<Character>(charRealm.createInterval('T'));
        Nfa<Character> i = new Nfa<Character>(charRealm.createInterval('I'));
        Nfa<Character> n = new Nfa<Character>(charRealm.createInterval('N'));

        Dfa<Character> allButEtienne = any.zeroOrMore().subtract(
                e.concatenateWith(t).concatenateWith(i).concatenateWith(e)
                        .concatenateWith(n).concatenateWith(n).concatenateWith(
                                e));

        System.out.println(allButEtienne);

        System.out.println(new MinimalDfa<Character>(allButEtienne));
    }
}

@@ -963,16 +963,84 @@
   @Test%0A
+    public void dummy() %7B%0A%0A        // until the bug is fixed%0A    %7D%0A%0A
     publ
@@ -2348,71 +2348,44 @@
     
-System.out.println(allButEtienne);%0A%0A        System.out.println(
+// Line that causes the bug%0A        
 new 
@@ -2420,17 +2420,16 @@
 Etienne)
-)
 ;%0A    %7D%0A

Clean up and deactivate regression test.