Mercurial > projects > dil
annotate trunk/src/docgen/tests/parse.d @ 462:b7503e02fbe7
Docgen code for handling public imports.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Tue, 30 Oct 2007 20:52:29 +0200 |
parents | 4e5b35df3060 |
children | 231c9a44ba8e |
rev | line source |
---|---|
441 | 1 /** |
2 * Author: Jari-Matti Mäkelä | |
3 * License: GPL3 | |
4 */ | |
5 module docgen.tests.parse; | |
6 | |
7 import docgen.misc.parser; | |
8 import tango.io.FileConduit; | |
9 import tango.io.Print: Print; | |
10 import tango.text.convert.Layout : Layout; | |
11 | |
12 void saveToFile(char[] fname, void delegate(Print!(char) file) foo) { | |
13 auto file = new FileConduit("docgen/teststuff/" ~ fname, FileConduit.WriteCreate); | |
14 auto output = new Print!(char)(new Layout!(char), file); | |
15 | |
16 foo(output); | |
17 | |
18 file.close(); | |
19 } | |
20 | |
21 // load some test files | |
22 //@unittest | |
23 void parse1() { | |
24 saveToFile("parse1.txt", (Print!(char) file){ | |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
25 Module[] modules; |
441 | 26 |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
27 Parser.loadModules( |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
28 [ "c" ], [ "docgen/teststuff/" ], |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
29 null, true, -1, |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
30 (char[] fqn, char[] path, Module m) { |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
31 file.format("{0} = {1}\n", fqn, path); |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
32 }, |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
453
diff
changeset
|
33 (Module imported, Module importer, bool isPublic) { |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
34 file.format("{0} <- {1}\n", |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
35 imported ? imported.moduleFQN : "null"[], |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
36 importer ? importer.moduleFQN : "null"[] |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
37 ); |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
38 }, |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
39 modules |
441 | 40 ); |
41 }); | |
42 } | |
43 | |
44 // load the imports of dil | |
45 //@unittest | |
46 void parse2() { | |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
47 saveToFile("parse2.txt", (Print!(char) file){ |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
48 Module[] modules; |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
49 |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
50 Parser.loadModules( |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
51 [ "docgen/testsuite" ], [".", "/home/jm/d/tango/"], |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
52 null, true, -1, |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
53 (char[] fqn, char[] path, Module m) { |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
54 file.format("{0} = {1}\n", fqn, path); |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
55 }, |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
453
diff
changeset
|
56 (Module imported, Module importer, bool isPublic) { |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
57 file.format("{0} <- {1}\n", |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
58 imported ? imported.moduleFQN : "null"[], |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
59 importer ? importer.moduleFQN : "null"[] |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
60 ); |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
61 }, |
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
62 modules |
441 | 63 ); |
449
757bd048482c
Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
64 }); |
453
4e5b35df3060
Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
449
diff
changeset
|
65 } |