KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ticket20 > MergeBug


1 /* This file is part of SableCC ( http://sablecc.org ).
2  *
3  * Copyright 2007 Raymond Audet <raymond.audet@gmail.com>
4  * Copyright 2007 Etienne M. Gagnon <egagnon@j-meg.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package ticket20;
20
21 import java.util.Collection JavaDoc;
22 import java.util.LinkedList JavaDoc;
23
24 import org.junit.Test;
25 import org.sablecc.sablecc.alphabet.Alphabet;
26 import org.sablecc.sablecc.alphabet.Interval;
27 import org.sablecc.sablecc.alphabet.Realms;
28 import org.sablecc.sablecc.alphabet.Symbol;
29
30 public class MergeBug {
31
32     @Test
33     public void bug() {
34
35         Collection JavaDoc<Interval<Integer JavaDoc>> intervalsInt = new LinkedList JavaDoc<Interval<Integer JavaDoc>>();
36
37         Alphabet<Integer JavaDoc> firstPartAlphabet;
38         Alphabet<Integer JavaDoc> secondPartAlphabet;
39
40         intervalsInt.add(Realms.getInteger().createInterval(0, 5));
41         intervalsInt.add(Realms.getInteger().createInterval(10, 15));
42         intervalsInt.add(Realms.getInteger().createInterval(20, 25));
43         firstPartAlphabet = new Alphabet<Integer JavaDoc>(new Symbol<Integer JavaDoc>(
44                 intervalsInt));
45
46         intervalsInt.clear();
47         intervalsInt.add(Realms.getInteger().createInterval(30, 35));
48         intervalsInt.add(Realms.getInteger().createInterval(40, 45));
49         intervalsInt.add(Realms.getInteger().createInterval(50, 55));
50         secondPartAlphabet = new Alphabet<Integer JavaDoc>(new Symbol<Integer JavaDoc>(
51                 intervalsInt));
52
53         // Line that cause the bug.
54
firstPartAlphabet.mergeWith(secondPartAlphabet);
55     }
56 }
57
Popular Tags