Source Code Cross Referenced for TokenTest.java in  » Scripting » groovy-1.0 » org » codehaus » groovy » syntax » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » groovy 1.0 » org.codehaus.groovy.syntax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.codehaus.groovy.syntax;
002:
003:        import groovy.util.GroovyTestCase;
004:
005:        public class TokenTest extends GroovyTestCase {
006:
007:            public void testNothing() {
008:            }
009:
010:            /*
011:             private static final int LINE = 11;
012:             private static final int COLUMN = 33;
013:
014:             public void testConstruct()
015:             {
016:             Token token = new Token( 42,
017:             "forty-two",
018:             11,
019:             22 );
020:
021:             assertEquals( 42,
022:             token.getType() );
023:
024:             assertEquals( "forty-two",
025:             token.getText() );
026:
027:             assertEquals( 11,
028:             token.getStartLine() );
029:
030:             assertEquals( 22,
031:             token.getStartColumn() );
032:             }
033:
034:             public void testLeftCurlyBrace()
035:             {
036:             Token token = Token.leftCurlyBrace( LINE,
037:             COLUMN );
038:
039:             assertToken( token,
040:             Token.LEFT_CURLY_BRACE,
041:             "{" );
042:             }
043:
044:             public void testRightCurlyBrace()
045:             {
046:             Token token = Token.rightCurlyBrace( LINE,
047:             COLUMN );
048:
049:             assertToken( token,
050:             Token.RIGHT_CURLY_BRACE,
051:             "}" );
052:             }
053:
054:             public void testLeftSquareBracket()
055:             {
056:             Token token = Token.leftSquareBracket( LINE,
057:             COLUMN );
058:
059:             assertToken( token,
060:             Token.LEFT_SQUARE_BRACKET,
061:             "[" );
062:             }
063:
064:             public void testRightSquareBracket()
065:             {
066:             Token token = Token.rightSquareBracket( LINE,
067:             COLUMN );
068:
069:             assertToken( token,
070:             Token.RIGHT_SQUARE_BRACKET,
071:             "]" );
072:             }
073:
074:             public void testLeftParenthesis()
075:             {
076:             Token token = Token.leftParenthesis( LINE,
077:             COLUMN );
078:
079:             assertToken( token,
080:             Token.LEFT_PARENTHESIS,
081:             "(" );
082:             }
083:
084:             public void testRightParenthesis()
085:             {
086:             Token token = Token.rightParenthesis( LINE,
087:             COLUMN );
088:
089:             assertToken( token,
090:             Token.RIGHT_PARENTHESIS,
091:             ")" );
092:             }
093:
094:             public void testDot()
095:             {
096:             Token token = Token.dot( LINE,
097:             COLUMN );
098:
099:             assertToken( token,
100:             Token.DOT,
101:             "." );
102:             }
103:
104:             public void testDotDot()
105:             {
106:             Token token = Token.dotDot( LINE,
107:             COLUMN );
108:
109:             assertToken( token,
110:             Token.DOT_DOT,
111:             ".." );
112:             }
113:
114:             public void testNot()
115:             {
116:             Token token = Token.not( LINE,
117:             COLUMN );
118:
119:             assertToken( token,
120:             Token.NOT,
121:             "!" );
122:             }
123:
124:             public void testCompareNotEqual()
125:             {
126:             Token token = Token.compareNotEqual( LINE,
127:             COLUMN );
128:
129:             assertToken( token,
130:             Token.COMPARE_NOT_EQUAL,
131:             "!=" );
132:             }
133:
134:             public void testEqual()
135:             {
136:             Token token = Token.equal( LINE,
137:             COLUMN );
138:
139:             assertToken( token,
140:             Token.EQUAL,
141:             "=" );
142:             }
143:
144:             public void testCompareIdentical()
145:             {
146:             Token token = Token.compareIdentical( LINE,
147:             COLUMN );
148:
149:             assertToken( token,
150:             Token.COMPARE_IDENTICAL,
151:             "===" );
152:             }
153:
154:             public void testCompareEqual()
155:             {
156:             Token token = Token.compareEqual( LINE,
157:             COLUMN );
158:
159:             assertToken( token,
160:             Token.COMPARE_EQUAL,
161:             "==" );
162:             }
163:
164:             public void testCompareLessThan()
165:             {
166:             Token token = Token.compareLessThan( LINE,
167:             COLUMN );
168:
169:             assertToken( token,
170:             Token.COMPARE_LESS_THAN,
171:             "<" );
172:             }
173:
174:             public void testCompareLessThanEqual()
175:             {
176:             Token token = Token.compareLessThanEqual( LINE,
177:             COLUMN );
178:
179:             assertToken( token,
180:             Token.COMPARE_LESS_THAN_EQUAL,
181:             "<=" );
182:             }
183:
184:             public void testCompareGreaterThan()
185:             {
186:             Token token = Token.compareGreaterThan( LINE,
187:             COLUMN );
188:
189:             assertToken( token,
190:             Token.COMPARE_GREATER_THAN,
191:             ">" );
192:             }
193:
194:             public void testCompareGreaterThanEqual()
195:             {
196:             Token token = Token.compareGreaterThanEqual( LINE,
197:             COLUMN );
198:
199:             assertToken( token,
200:             Token.COMPARE_GREATER_THAN_EQUAL,
201:             ">=" );
202:             }
203:
204:             public void testLogicalOr()
205:             {
206:             Token token = Token.logicalOr( LINE,
207:             COLUMN );
208:
209:             assertToken( token,
210:             Token.LOGICAL_OR,
211:             "||" );
212:             }
213:
214:             public void testLogicalAnd()
215:             {
216:             Token token = Token.logicalAnd( LINE,
217:             COLUMN );
218:
219:             assertToken( token,
220:             Token.LOGICAL_AND,
221:             "&&" );
222:             }
223:
224:             public void testPlus()
225:             {
226:             Token token = Token.plus( LINE,
227:             COLUMN );
228:
229:             assertToken( token,
230:             Token.PLUS,
231:             "+" );
232:             }
233:
234:             public void testPlusPlus()
235:             {
236:             Token token = Token.plusPlus( LINE,
237:             COLUMN );
238:
239:             assertToken( token,
240:             Token.PLUS_PLUS,
241:             "++" );
242:             }
243:
244:             public void testPlusEqual()
245:             {
246:             Token token = Token.plusEqual( LINE,
247:             COLUMN );
248:
249:             assertToken( token,
250:             Token.PLUS_EQUAL,
251:             "+=" );
252:             }
253:
254:             public void testMinus()
255:             {
256:             Token token = Token.minus( LINE,
257:             COLUMN );
258:
259:             assertToken( token,
260:             Token.MINUS,
261:             "-" );
262:             }
263:
264:             public void testMinusMinus()
265:             {
266:             Token token = Token.minusMinus( LINE,
267:             COLUMN );
268:
269:             assertToken( token,
270:             Token.MINUS_MINUS,
271:             "--" );
272:             }
273:
274:             public void testMinusEqual()
275:             {
276:             Token token = Token.minusEqual( LINE,
277:             COLUMN );
278:
279:             assertToken( token,
280:             Token.MINUS_EQUAL,
281:             "-=" );
282:             }
283:
284:             public void testDivide()
285:             {
286:             Token token = Token.divide( LINE,
287:             COLUMN );
288:
289:             assertToken( token,
290:             Token.DIVIDE,
291:             "/" );
292:             }
293:
294:             public void testDivideEqual()
295:             {
296:             Token token = Token.divideEqual( LINE,
297:             COLUMN );
298:
299:             assertToken( token,
300:             Token.DIVIDE_EQUAL,
301:             "/=" );
302:             }
303:
304:             public void testMod()
305:             {
306:             Token token = Token.mod( LINE,
307:             COLUMN );
308:
309:             assertToken( token,
310:             Token.MOD,
311:             "%" );
312:             }
313:
314:             public void testModEqual()
315:             {
316:             Token token = Token.modEqual( LINE,
317:             COLUMN );
318:
319:             assertToken( token,
320:             Token.MOD_EQUAL,
321:             "%=" );
322:             }
323:
324:             public void testMultiply()
325:             {
326:             Token token = Token.multiply( LINE,
327:             COLUMN );
328:
329:             assertToken( token,
330:             Token.MULTIPLY,
331:             "*" );
332:             }
333:
334:             public void testMultiplyEqual()
335:             {
336:             Token token = Token.multiplyEqual( LINE,
337:             COLUMN );
338:
339:             assertToken( token,
340:             Token.MULTIPLY_EQUAL,
341:             "*=" );
342:             }
343:
344:             public void testComma()
345:             {
346:             Token token = Token.comma( LINE,
347:             COLUMN );
348:
349:             assertToken( token,
350:             Token.COMMA,
351:             "," );
352:             }
353:
354:             public void testColon()
355:             {
356:             Token token = Token.colon( LINE,
357:             COLUMN );
358:
359:             assertToken( token,
360:             Token.COLON,
361:             ":" );
362:             }
363:
364:             public void testSemicolon()
365:             {
366:             Token token = Token.semicolon( LINE,
367:             COLUMN );
368:
369:             assertToken( token,
370:             Token.SEMICOLON,
371:             ";" );
372:             }
373:
374:             public void testQuestion()
375:             {
376:             Token token = Token.question( LINE,
377:             COLUMN );
378:
379:             assertToken( token,
380:             Token.QUESTION,
381:             "?" );
382:             }
383:
384:             public void testPipe()
385:             {
386:             Token token = Token.pipe( LINE,
387:             COLUMN );
388:
389:             assertToken( token,
390:             Token.PIPE,
391:             "|" );
392:             }
393:
394:             public void testDoubleQuoteString()
395:             {
396:             Token token = Token.doubleQuoteString( LINE,
397:             COLUMN,
398:             "cheese" );
399:
400:             assertToken( token,
401:             Token.DOUBLE_QUOTE_STRING,
402:             "cheese",
403:             "<string literal>");
404:             }
405:
406:             public void testSingleQuoteString()
407:             {
408:             Token token = Token.singleQuoteString( LINE,
409:             COLUMN,
410:             "cheese" );
411:
412:             assertToken( token,
413:             Token.SINGLE_QUOTE_STRING,
414:             "cheese",
415:             "<string literal>" );
416:             }
417:
418:             public void testIdentifier()
419:             {
420:             Token token = Token.identifier( LINE,
421:             COLUMN,
422:             "cheese" );
423:
424:             assertToken( token,
425:             Token.IDENTIFIER,
426:             "cheese",
427:             "<identifier>" );
428:             }
429:
430:             public void testIntegerNumber()
431:             {
432:             Token token = Token.integerNumber( LINE,
433:             COLUMN,
434:             "42" );
435:
436:             assertToken( token,
437:             Token.INTEGER_NUMBER,
438:             "42",
439:             "<number>" );
440:             }
441:
442:             public void testFloatNumber()
443:             {
444:             Token token = Token.floatNumber( LINE,
445:             COLUMN,
446:             "42.84" );
447:
448:             assertToken( token,
449:             Token.FLOAT_NUMBER,
450:             "42.84",
451:             "<number>" );
452:             }
453:
454:             // ----------------------------------------------------------------------
455:             // ----------------------------------------------------------------------
456:
457:             public void testKeyword_As()
458:             {
459:             assertKeywordToken( "as",
460:             Token.KEYWORD_AS );
461:             }
462:
463:             public void testKeyword_Abstract()
464:             {
465:             assertKeywordToken( "abstract",
466:             Token.KEYWORD_ABSTRACT );
467:             }
468:
469:             public void testKeyword_Break()
470:             {
471:             assertKeywordToken( "break",
472:             Token.KEYWORD_BREAK );
473:             }
474:
475:             public void testKeyword_Case()
476:             {
477:             assertKeywordToken( "case",
478:             Token.KEYWORD_CASE );
479:             }
480:
481:             public void testKeyword_Catch()
482:             {
483:             assertKeywordToken( "catch",
484:             Token.KEYWORD_CATCH );
485:             }
486:
487:             public void testKeyword_Class()
488:             {
489:             assertKeywordToken( "class",
490:             Token.KEYWORD_CLASS );
491:             }
492:
493:             public void testKeyword_Const()
494:             {
495:             assertKeywordToken( "const",
496:             Token.KEYWORD_CONST );
497:             }
498:
499:             public void testKeyword_Continue()
500:             {
501:             assertKeywordToken( "continue",
502:             Token.KEYWORD_CONTINUE );
503:             }
504:
505:             public void testKeyword_Default()
506:             {
507:             assertKeywordToken( "default",
508:             Token.KEYWORD_DEFAULT );
509:             }
510:
511:             public void testKeyword_Do()
512:             {
513:             assertKeywordToken( "do",
514:             Token.KEYWORD_DO );
515:             }
516:
517:             public void testKeyword_Else()
518:             {
519:             assertKeywordToken( "else",
520:             Token.KEYWORD_ELSE );
521:             }
522:
523:             public void testKeyword_Extends()
524:             {
525:             assertKeywordToken( "extends",
526:             Token.KEYWORD_EXTENDS );
527:             }
528:
529:             public void testKeyword_Final()
530:             {
531:             assertKeywordToken( "final",
532:             Token.KEYWORD_FINAL );
533:             }
534:
535:             public void testKeyword_Finally()
536:             {
537:             assertKeywordToken( "finally",
538:             Token.KEYWORD_FINALLY );
539:             }
540:
541:             public void testKeyword_For()
542:             {
543:             assertKeywordToken( "for",
544:             Token.KEYWORD_FOR );
545:             }
546:
547:             public void testKeyword_Goto()
548:             {
549:             assertKeywordToken( "goto",
550:             Token.KEYWORD_GOTO );
551:             }
552:
553:             public void testKeyword_If()
554:             {
555:             assertKeywordToken( "if",
556:             Token.KEYWORD_IF );
557:             }
558:
559:             public void testKeyword_Implements()
560:             {
561:             assertKeywordToken( "implements",
562:             Token.KEYWORD_IMPLEMENTS );
563:             }
564:
565:             public void testKeyword_Import()
566:             {
567:             assertKeywordToken( "import",
568:             Token.KEYWORD_IMPORT );
569:             }
570:
571:             public void testKeyword_Instanceof()
572:             {
573:             assertKeywordToken( "instanceof",
574:             Token.KEYWORD_INSTANCEOF );
575:             }
576:
577:             public void testKeyword_Interface()
578:             {
579:             assertKeywordToken( "interface",
580:             Token.KEYWORD_INTERFACE );
581:             }
582:
583:             public void testKeyword_Native()
584:             {
585:             assertKeywordToken( "native",
586:             Token.KEYWORD_NATIVE );
587:             }
588:
589:             public void testKeyword_New()
590:             {
591:             assertKeywordToken( "new",
592:             Token.KEYWORD_NEW );
593:             }
594:
595:             public void testKeyword_Package()
596:             {
597:             assertKeywordToken( "package",
598:             Token.KEYWORD_PACKAGE );
599:             }
600:
601:             public void testKeyword_Private()
602:             {
603:             assertKeywordToken( "private",
604:             Token.KEYWORD_PRIVATE );
605:             }
606:
607:             public void testKeyword_Property()
608:             {
609:             assertKeywordToken( "property",
610:             Token.KEYWORD_PROPERTY );
611:             }
612:
613:             public void testKeyword_Protected()
614:             {
615:             assertKeywordToken( "protected",
616:             Token.KEYWORD_PROTECTED );
617:             }
618:
619:             public void testKeyword_Public()
620:             {
621:             assertKeywordToken( "public",
622:             Token.KEYWORD_PUBLIC );
623:             }
624:
625:             public void testKeyword_Return()
626:             {
627:             assertKeywordToken( "return",
628:             Token.KEYWORD_RETURN );
629:             }
630:
631:             public void testKeyword_Static()
632:             {
633:             assertKeywordToken( "static",
634:             Token.KEYWORD_STATIC );
635:             }
636:
637:             public void testKeyword_Super()
638:             {
639:             assertKeywordToken( "super",
640:             Token.KEYWORD_SUPER );
641:             }
642:
643:             public void testKeyword_Switch()
644:             {
645:             assertKeywordToken( "switch",
646:             Token.KEYWORD_SWITCH );
647:             }
648:
649:             public void testKeyword_Synchronized()
650:             {
651:             assertKeywordToken( "synchronized",
652:             Token.KEYWORD_SYNCHRONIZED );
653:             }
654:
655:             public void testKeyword_This()
656:             {
657:             assertKeywordToken( "this",
658:             Token.KEYWORD_THIS );
659:             }
660:
661:             public void testKeyword_Throw()
662:             {
663:             assertKeywordToken( "throw",
664:             Token.KEYWORD_THROW );
665:             }
666:
667:             public void testKeyword_Throws()
668:             {
669:             assertKeywordToken( "throws",
670:             Token.KEYWORD_THROWS );
671:             }
672:
673:             public void testKeyword_Try()
674:             {
675:             assertKeywordToken( "try",
676:             Token.KEYWORD_TRY );
677:             }
678:
679:             public void testKeyword_While()
680:             {
681:             assertKeywordToken( "while",
682:             Token.KEYWORD_WHILE );
683:             }
684:
685:             public void testUniqueKeywordTypes()
686:             {
687:             Map keywords = Token.getKeywordMap();
688:
689:             Set types = new HashSet();
690:
691:             types.addAll( keywords.values() );
692:
693:             assertEquals( types.size(),
694:             keywords.size() );
695:             }
696:
697:             public void testUnknownTokenType()
698:             {
699:             assertEquals( "<unknown>",
700:             Token.getTokenDescription( 6666 ) );
701:             }
702:
703:             // ----------------------------------------------------------------------
704:             // ----------------------------------------------------------------------
705:
706:             protected void assertKeywordToken(String text,
707:             int expectedType)
708:             {
709:             Token token = Token.keyword( LINE,
710:             COLUMN,
711:             text );
712:
713:             assertToken( token,
714:             expectedType,
715:             text );
716:             }
717:
718:             protected void assertToken(Token token,
719:             int type,
720:             String text)
721:             {
722:             assertToken( token,
723:             type,
724:             text,
725:             '"' + text + '"' );
726:             }
727:
728:             protected void assertToken(Token token,
729:             int type,
730:             String text,
731:             String description)
732:             {
733:             assertEquals( type,
734:             token.getType() );
735:
736:             assertEquals( text,
737:             token.getText() );
738:
739:             assertEquals( description,
740:             token.getDescription() );
741:
742:             assertEquals( LINE,
743:             token.getStartLine() );
744:
745:             assertEquals( COLUMN,
746:             token.getStartColumn() );
747:             }
748:            
749:             */
750:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.