Source Code Cross Referenced for FortranTokenizerTest.java in  » Code-Analyzer » pmd-4.2rc1 » test » net » sourceforge » pmd » cpd » 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 » Code Analyzer » pmd 4.2rc1 » test.net.sourceforge.pmd.cpd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         */package test.net.sourceforge.pmd.cpd;
004:
005:        import java.io.IOException;
006:
007:        import net.sourceforge.pmd.PMD;
008:        import net.sourceforge.pmd.cpd.FortranTokenizer;
009:        import net.sourceforge.pmd.cpd.SourceCode;
010:
011:        import org.junit.Before;
012:        import org.junit.Test;
013:
014:        import test.net.sourceforge.pmd.testframework.AbstractTokenizerTest;
015:
016:        /**
017:         * @author rpelisse
018:         *
019:         */
020:        public class FortranTokenizerTest extends AbstractTokenizerTest {
021:
022:            @Before
023:            @Override
024:            public void buildTokenizer() {
025:                this .tokenizer = new FortranTokenizer();
026:                this .sourceCode = new SourceCode(
027:                        new SourceCode.StringCodeLoader(this .getSampleCode(),
028:                                "sample.for"));
029:            }
030:
031:            @Override
032:            public String getSampleCode() {
033:                return "       options/extend_source"
034:                        + PMD.EOL
035:                        + "       program tp3"
036:                        + PMD.EOL
037:                        + "       implicit none"
038:                        + PMD.EOL
039:                        + ""
040:                        + PMD.EOL
041:                        + "! Ce programme va demander la saisie de la commande, puis on va separer les differentes"
042:                        + PMD.EOL
043:                        + "!parties de la chaine en plusieurs variables, ensuite selon l'action demandee on appelera le"
044:                        + PMD.EOL
045:                        + "!sous programme correspondant."
046:                        + PMD.EOL
047:                        + ""
048:                        + PMD.EOL
049:                        + "       character*60 COMMANDE"
050:                        + PMD.EOL
051:                        + "       integer*4 IOS,"
052:                        + PMD.EOL
053:                        + "       1         COMPTEUR,"
054:                        + PMD.EOL
055:                        + "       1         SORTIE,"
056:                        + PMD.EOL
057:                        + "       1         ERRONE,"
058:                        + PMD.EOL
059:                        + "       1         CONF,"
060:                        + PMD.EOL
061:                        + "       1         POSITION_ESPACE,"
062:                        + PMD.EOL
063:                        + "       1         DEBUT_MOT,"
064:                        + PMD.EOL
065:                        + "       1         FIN_MOT,"
066:                        + PMD.EOL
067:                        + "       1         NB_MOTS,"
068:                        + PMD.EOL
069:                        + "       1         NB_MOTS_MAX,"
070:                        + PMD.EOL
071:                        + "       1         FIN_CHAINE,"
072:                        + PMD.EOL
073:                        + "       1         TROUVER_FIN,"
074:                        + PMD.EOL
075:                        + "       1         NUM_CARACTERE,"
076:                        + PMD.EOL
077:                        + "       1         ACTION,"
078:                        + PMD.EOL
079:                        + "       1         PREMIERE_LETTRE,"
080:                        + PMD.EOL
081:                        + "       1         DERNIERE_LETTRE,"
082:                        + PMD.EOL
083:                        + "       1         INTERVALLE_MAJ_MIN,"
084:                        + PMD.EOL
085:                        + "       1         APRES_MAJ,"
086:                        + PMD.EOL
087:                        + "       1         TAILLE_COLONNE,"
088:                        + PMD.EOL
089:                        + "       1         TAILLE_LIGNE,"
090:                        + PMD.EOL
091:                        + "       1         LIGNES_DESC"
092:                        + PMD.EOL
093:                        + ""
094:                        + PMD.EOL
095:                        + "       parameter(NB_MOTS_MAX = 9) !une saisie correcte ne contient pas plus de 8 mots, si"
096:                        + PMD.EOL
097:                        + "!elle en contient 9, alors la saisie sera jugee incorrecte."
098:                        + PMD.EOL
099:                        + "       parameter(ERRONE = 1)"
100:                        + PMD.EOL
101:                        + "       parameter(SORTIE = - 1)"
102:                        + PMD.EOL
103:                        + "       parameter(ACTION = 1)  !il s'agit du 1er mot de la chaine de caracteres"
104:                        + PMD.EOL
105:                        + "       parameter(PREMIERE_LETTRE = 1)  !correspond a la 1ere lettre d'un mot"
106:                        + PMD.EOL
107:                        + "       parameter(DERNIERE_LETTRE = 18)  !correspond a la derniere lettre d'un mot"
108:                        + PMD.EOL
109:                        + "       parameter(INTERVALLE_MAJ_MIN = 32)  !nombre separant un meme caractere"
110:                        + PMD.EOL
111:                        + "!minuscule de son majuscule"
112:                        + PMD.EOL
113:                        + "       parameter(APRES_MAJ = 96)  !correspond au dernier caractere avant les MIN"
114:                        + PMD.EOL
115:                        + "       parameter(TAILLE_COLONNE = 7)"
116:                        + PMD.EOL
117:                        + "       parameter(TAILLE_LIGNE = 12)"
118:                        + PMD.EOL
119:                        + "       parameter(LIGNES_DESC = 11)"
120:                        + PMD.EOL
121:                        + ""
122:                        + PMD.EOL
123:                        + "        character*19 N(TAILLE_COLONNE,TAILLE_LIGNE)"
124:                        + PMD.EOL
125:                        + "       character*19 MOTS_COMMANDE(NB_MOTS_MAX)"
126:                        + PMD.EOL
127:                        + "       character*60 DESC(LIGNES_DESC)"
128:                        + PMD.EOL
129:                        + ""
130:                        + PMD.EOL
131:                        + "       write(*,*) ' '"
132:                        + PMD.EOL
133:                        + "       write(*,*) '      -----------------------------------------------------'"
134:                        + PMD.EOL
135:                        + "       write(*,*) '      | Bonjour, et bienvenue dans le programme DASHBOARD |'"
136:                        + PMD.EOL
137:                        + "       write(*,*) '      -----------------------------------------------------'"
138:                        + PMD.EOL
139:                        + "       write(*,*) ' '"
140:                        + PMD.EOL
141:                        + "       write(*,*) ' '"
142:                        + PMD.EOL
143:                        + "       write(*,*) ' Voici un rappel des fonctions disponibles pour ce DASHBOARD : '"
144:                        + PMD.EOL
145:                        + "       write(*,*) ' '"
146:                        + PMD.EOL
147:                        + "       write(*,*) '   _ TASK pour creer une tache (ex : TASK IDTACHE CIBLE AUTEUR)'"
148:                        + PMD.EOL
149:                        + "       write(*,*) ' '"
150:                        + PMD.EOL
151:                        + "       write(*,*) '   _ SHOW pour voir la description (ex : SHOW IDTACHE)'"
152:                        + PMD.EOL
153:                        + "       write(*,*) ' '"
154:                        + PMD.EOL
155:                        + "       write(*,*) '   _ REMOVE pour enlever une tache (ex : REMOVE IDTACHE)'"
156:                        + PMD.EOL
157:                        + "       write(*,*) ' '"
158:                        + PMD.EOL
159:                        + "       write(*,*) '   _ CLEAR pour effacer le DASHBOARD (ex : CLEAR)'"
160:                        + PMD.EOL
161:                        + "       write(*,*) ' '"
162:                        + PMD.EOL
163:                        + "       write(*,*) '   _ CANCEL, DONE, TODO pour modifier lHEREetat de la tache (ex : DONE IDTACHE)'"
164:                        + PMD.EOL
165:                        + "       write(*,*) ' '"
166:                        + PMD.EOL
167:                        + ""
168:                        + PMD.EOL
169:                        + "! La boucle de sortie pour quitter si l'on appuie sur F10"
170:                        + PMD.EOL
171:                        + "       do while (IOS .ne. SORTIE)"
172:                        + PMD.EOL
173:                        + ""
174:                        + PMD.EOL
175:                        + "! Initialisons les variables, afin de ne pas garder les anciennes valeurs pour chaque variable."
176:                        + PMD.EOL
177:                        + "               POSITION_ESPACE = 0"
178:                        + PMD.EOL
179:                        + "               DEBUT_MOT = 0"
180:                        + PMD.EOL
181:                        + "               FIN_MOT = 0"
182:                        + PMD.EOL
183:                        + "               NB_MOTS = 0"
184:                        + PMD.EOL
185:                        + "               FIN_CHAINE = 0"
186:                        + PMD.EOL
187:                        + ""
188:                        + PMD.EOL
189:                        + "! Initialisons aussi le tableau des MOTS_COMMANDE"
190:                        + PMD.EOL
191:                        + "               do COMPTEUR = ACTION, NB_MOTS_MAX"
192:                        + PMD.EOL
193:                        + "                       MOTS_COMMANDE (COMPTEUR) = ' '"
194:                        + PMD.EOL
195:                        + "               end do"
196:                        + PMD.EOL
197:                        + ""
198:                        + PMD.EOL
199:                        + "! Appelons le sous prgramme qui gere la saisie de la commande et aussi la sortie, si "
200:                        + PMD.EOL
201:                        + "!l'utilisateur le demande"
202:                        + PMD.EOL
203:                        + "               call SAISIE(COMMANDE, IOS)"
204:                        + PMD.EOL
205:                        + ""
206:                        + PMD.EOL
207:                        + "               if (IOS .eq. 0) then"
208:                        + PMD.EOL
209:                        + ""
210:                        + PMD.EOL
211:                        + "! Trouvons la fin de la chaine"
212:                        + PMD.EOL
213:                        + "                       FIN_CHAINE = TROUVER_FIN (COMMANDE)"
214:                        + PMD.EOL
215:                        + "                       COMPTEUR = 1"
216:                        + PMD.EOL
217:                        + "                       do while (POSITION_ESPACE .lt. FIN_CHAINE .and. NB_MOTS .lt. NB_MOTS_MAX)"
218:                        + PMD.EOL
219:                        + "                               DEBUT_MOT = POSITION_ESPACE + 1"
220:                        + PMD.EOL
221:                        + ""
222:                        + PMD.EOL
223:                        + "! Decoupons les mots"
224:                        + PMD.EOL
225:                        + "                               POSITION_ESPACE = POSITION_ESPACE + index (COMMANDE (DEBUT_MOT:), ' ')"
226:                        + PMD.EOL
227:                        + "                               FIN_MOT = POSITION_ESPACE - 1"
228:                        + PMD.EOL
229:                        + ""
230:                        + PMD.EOL
231:                        + "! Ensuite on les enregistre dans MOTS_COMMANDE"
232:                        + PMD.EOL
233:                        + "                               MOTS_COMMANDE (COMPTEUR) = COMMANDE (DEBUT_MOT : FIN_MOT)"
234:                        + PMD.EOL
235:                        + ""
236:                        + PMD.EOL
237:                        + "! Comptons les mots"
238:                        + PMD.EOL
239:                        + "                               if (MOTS_COMMANDE (COMPTEUR) .ne. ' ') then"
240:                        + PMD.EOL
241:                        + "                                       NB_MOTS = NB_MOTS + 1"
242:                        + PMD.EOL
243:                        + "                                       COMPTEUR = COMPTEUR + 1"
244:                        + PMD.EOL
245:                        + "                               end if"
246:                        + PMD.EOL
247:                        + "                       end do"
248:                        + PMD.EOL
249:                        + ""
250:                        + PMD.EOL
251:                        + "! Le programme ne doit pas tenir compte de la casse, ainsi peu importe la maniere"
252:                        + PMD.EOL
253:                        + "!dont est ecrit le mot, il sera mis en majuscule"
254:                        + PMD.EOL
255:                        + "                       do COMPTEUR = 1, NB_MOTS"
256:                        + PMD.EOL
257:                        + "                               do NUM_CARACTERE = PREMIERE_LETTRE, DERNIERE_LETTRE"
258:                        + PMD.EOL
259:                        + "                                       if (ichar(MOTS_COMMANDE (COMPTEUR)(NUM_CARACTERE:NUM_CARACTERE))"
260:                        + PMD.EOL
261:                        + "       1 .gt. APRES_MAJ) then"
262:                        + PMD.EOL
263:                        + "                                               MOTS_COMMANDE (COMPTEUR)(NUM_CARACTERE:NUM_CARACTERE) ="
264:                        + PMD.EOL
265:                        + "       1 char(ichar(MOTS_COMMANDE (COMPTEUR)(NUM_CARACTERE:NUM_CARACTERE)) - INTERVALLE_MAJ_MIN)"
266:                        + PMD.EOL
267:                        + "                                       end if"
268:                        + PMD.EOL
269:                        + "                               end do"
270:                        + PMD.EOL
271:                        + "                       end do"
272:                        + PMD.EOL
273:                        + ""
274:                        + PMD.EOL
275:                        + "!! Affichons les mots (provisoire)"
276:                        + PMD.EOL
277:                        + "!!                     do COMPTEUR = 1, NB_MOTS"
278:                        + PMD.EOL
279:                        + "!!                             write(*,*) COMPTEUR, ': ', MOTS_COMMANDE (COMPTEUR)"
280:                        + PMD.EOL
281:                        + "!!                     end do"
282:                        + PMD.EOL
283:                        + "!!"
284:                        + PMD.EOL
285:                        + "!! Testons si le mot est bien en majuscule (etape provisoire)"
286:                        + PMD.EOL
287:                        + "!!                     write(*,*) MOTS_COMMANDE (ACTION), ': voila lHEREaction'"
288:                        + PMD.EOL
289:                        + ""
290:                        + PMD.EOL
291:                        + ""
292:                        + PMD.EOL
293:                        + "! Si la commande contient plus de 8 mots, on demande de recommencer"
294:                        + PMD.EOL
295:                        + ""
296:                        + PMD.EOL
297:                        + "                       if (NB_MOTS .eq. NB_MOTS_MAX) then"
298:                        + PMD.EOL
299:                        + "                               write(*,*) ' '"
300:                        + PMD.EOL
301:                        + "                               write(*,*) 'ERR> Trop de mot, veuillez ressaisir'"
302:                        + PMD.EOL
303:                        + "                       else"
304:                        + PMD.EOL
305:                        + ""
306:                        + PMD.EOL
307:                        + "! Maintenant, en fonction du premier mot entre, on va appeler le sous programme correspondant"
308:                        + PMD.EOL
309:                        + "                               if (MOTS_COMMANDE (ACTION) .eq. 'TASK') then"
310:                        + PMD.EOL
311:                        + "                                       call TACHE(MOTS_COMMANDE, DESC, N)"
312:                        + PMD.EOL
313:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'SHOW') then"
314:                        + PMD.EOL
315:                        + "!                                      write(*,*) 'on appelle le sous prgrm SHOW'"
316:                        + PMD.EOL
317:                        + "                                       call SHOW(MOTS_COMMANDE, N)"
318:                        + PMD.EOL
319:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'REMOVE') then"
320:                        + PMD.EOL
321:                        + "!                                      write(*,*) 'on appelle le sous prgrm REMOVE'"
322:                        + PMD.EOL
323:                        + "                                       call REMOVE(MOTS_COMMANDE, DESC, N)"
324:                        + PMD.EOL
325:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'CLEAR') then"
326:                        + PMD.EOL
327:                        + "!                                      write(*,*) 'on appelle le sous prgrm CLEAR'"
328:                        + PMD.EOL
329:                        + "                                       call CLEAR(MOTS_COMMANDE, N)"
330:                        + PMD.EOL
331:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'CANCEL') then"
332:                        + PMD.EOL
333:                        + "!                                      write(*,*) 'on appelle le sous prgrm CANCEL'"
334:                        + PMD.EOL
335:                        + "                                       call CANCEL(MOTS_COMMANDE, N)"
336:                        + PMD.EOL
337:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'DONE') then"
338:                        + PMD.EOL
339:                        + "!                                      write(*,*) 'on appelle le sous prgrm DONE'"
340:                        + PMD.EOL
341:                        + "                                       call DONE(MOTS_COMMANDE, N)"
342:                        + PMD.EOL
343:                        + "                               else if (MOTS_COMMANDE (ACTION) .eq. 'TODO') then"
344:                        + PMD.EOL
345:                        + "!                                      write(*,*) 'on appelle le sous prgrm TODO'"
346:                        + PMD.EOL
347:                        + "                                       call TODO(MOTS_COMMANDE, N)"
348:                        + PMD.EOL
349:                        + "                               else"
350:                        + PMD.EOL
351:                        + "                                       write(*,*) ' '"
352:                        + PMD.EOL
353:                        + "                                       write(*,*) 'L''action suivante n''a pas ete',"
354:                        + PMD.EOL
355:                        + "       1 ' comprise: ', MOTS_COMMANDE (ACTION)"
356:                        + PMD.EOL + "                               end if"
357:                        + PMD.EOL + "                       end if" + PMD.EOL
358:                        + "               end if" + PMD.EOL + "       end do"
359:                        + PMD.EOL + "       end" + PMD.EOL;
360:            }
361:
362:            @Test
363:            public void tokenizeTest() throws IOException {
364:                this .expectedTokenCount = 434;
365:                super .tokenizeTest();
366:            }
367:
368:            public static junit.framework.Test suite() {
369:                return new junit.framework.JUnit4TestAdapter(
370:                        FortranTokenizerTest.class);
371:            }
372:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.