1 // Test of `/*' behavior of StreamTokenizer. |
|
2 |
|
3 /************************************************************************* |
|
4 /* This program is free software; you can redistribute it and/or modify |
|
5 /* it under the terms of the GNU General Public License as published |
|
6 /* by the Free Software Foundation, either version 2 of the License, or |
|
7 /* (at your option) any later version. |
|
8 /* |
|
9 /* This program is distributed in the hope that it will be useful, but |
|
10 /* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 /* GNU General Public License for more details. |
|
13 /* |
|
14 /* You should have received a copy of the GNU General Public License |
|
15 /* along with this program; if not, write to the Free Software Foundation |
|
16 /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA |
|
17 /*************************************************************************/ |
|
18 |
|
19 // Tags: JDK1.1 |
|
20 |
|
21 package gnu.testlet.java.io.StreamTokenizer; |
|
22 |
|
23 import java.io.*; |
|
24 import gnu.testlet.Testlet; |
|
25 import gnu.testlet.TestHarness; |
|
26 |
|
27 public class Test implements Testlet |
|
28 { |
|
29 public static void tokenize (TestHarness harness, |
|
30 String input, |
|
31 int[] expected) |
|
32 { |
|
33 harness.checkPoint (input); |
|
34 StringReader sr = new StringReader (input); |
|
35 StreamTokenizer st = new StreamTokenizer (sr); |
|
36 st.slashStarComments (true); |
|
37 |
|
38 try |
|
39 { |
|
40 int tt; |
|
41 int i = 0; |
|
42 while ((tt = st.nextToken ()) != StreamTokenizer.TT_EOF) |
|
43 { |
|
44 if (i >= expected.length) |
|
45 harness.fail ("not enough tokens"); |
|
46 else |
|
47 harness.check (tt, expected[i]); |
|
48 ++i; |
|
49 } |
|
50 harness.check (i, expected.length); |
|
51 } |
|
52 catch (Throwable _) |
|
53 { |
|
54 harness.debug (_); |
|
55 harness.fail ("Exception caught"); |
|
56 } |
|
57 } |
|
58 |
|
59 public void test (TestHarness harness) |
|
60 { |
|
61 int[] x1 = new int[7]; |
|
62 x1[0] = '('; |
|
63 x1[1] = StreamTokenizer.TT_WORD; |
|
64 x1[2] = ')'; |
|
65 x1[3] = StreamTokenizer.TT_NUMBER; |
|
66 x1[4] = '('; |
|
67 x1[5] = StreamTokenizer.TT_WORD; |
|
68 x1[6] = ')'; |
|
69 tokenize (harness, "(a).(b)", x1); |
|
70 } |
|
71 } |
|