OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [test/] [java.io/] [StreamTokenizerTest.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/*************************************************************************
2
/* StreamTokenizerTest.java -- Test the StreamTokenizer class
3
/*
4
/* Copyright (c) 1998 Free Software Foundation, Inc.
5
/* Written by Aaron M. Renn (arenn@urbanophile.com)
6
/*
7
/* This program is free software; you can redistribute it and/or modify
8
/* it under the terms of the GNU General Public License as published
9
/* by the Free Software Foundation, either version 2 of the License, or
10
/* (at your option) any later version.
11
/*
12
/* This program is distributed in the hope that it will be useful, but
13
/* WITHOUT ANY WARRANTY; without even the implied warranty of
14
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
/* GNU General Public License for more details.
16
/*
17
/* You should have received a copy of the GNU General Public License
18
/* along with this program; if not, write to the Free Software Foundation
19
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
20
/*************************************************************************/
21
 
22
import java.io.*;
23
 
24
public class StreamTokenizerTest
25
{
26
 
27
public static void
28
main(String[] argv)
29
{
30
  System.out.println("Started test of StreamTokenizer");
31
 
32
  try
33
    {
34
      System.out.println("Test 1: Basic Parsing Test");
35
 
36
      StreamTokenizer st = new StreamTokenizer(new
37
                               FileInputStream("./stream-tokenizer.data"));
38
 
39
      System.out.println("No tokens read: " + st.toString());
40
      int j = 0;
41
      for (;;)
42
        {
43
          int ttype = st.nextToken();
44
          switch(ttype)
45
            {
46
              case StreamTokenizer.TT_NUMBER:
47
                System.out.println("Read a number: " + st.toString());
48
                break;
49
 
50
              case StreamTokenizer.TT_WORD:
51
                System.out.println("Read a word: " + st.toString());
52
                ++j;
53
                if (j == 2)
54
                  {
55
                    st.ordinaryChar('/');
56
                    st.eolIsSignificant(true);
57
                    st.lowerCaseMode(true);
58
                    st.slashStarComments(true);
59
                    st.slashSlashComments(true);
60
                  }
61
                break;
62
 
63
              case StreamTokenizer.TT_EOL:
64
                System.out.println("Read an EOL: " + st.toString());
65
                break;
66
 
67
              case StreamTokenizer.TT_EOF:
68
                System.out.println("Read an EOF: " + st.toString());
69
 
70
              case '\'':
71
              case '"':
72
                System.out.println("Got a quote:" + st.toString());
73
                break;
74
 
75
              default:
76
                System.out.println("Got an ordinary:" + st.toString());
77
                break;
78
           }
79
         if (ttype == StreamTokenizer.TT_EOF)
80
           break;
81
        }
82
 
83
      System.out.println("PASSED: Basic Parsing Test");
84
    }
85
  catch(IOException e)
86
    {
87
      System.out.println("FAILED: Basic Parsing Test: " + e);
88
    }
89
 
90
  System.out.println("Finished test of StreamTokenizer");
91
}
92
 
93
} // class StreamTokenizerTest
94
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.