blob: adfc2fc6bbfa441b8444e58ce178192d90b95816 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// file : tests/indentation/cxx/driver.cxx
// author : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2006-2010 Boris Kolpackov
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <iostream>
#include <cult/types.hxx>
#include <backend-elements/indentation/cxx.hxx>
#include <backend-elements/indentation/clip.hxx>
using namespace Cult::Types;
using namespace BackendElements::Indentation;
using std::cout;
using std::endl;
Int
main ()
{
std::ostream& os (cout);
Clip<CXX, Char> clip (os);
os << "if (true)"
<< "{"
<< "// Hello there" << endl
<< "//" << endl
<< "a ();"
<< "}"
<< "else"
<< "{"
<< "b ();"
<< "}";
os << "if (false)"
<< "{"
<< "if (true)"
<< "{"
<< "// test" << endl
<< "}"
<< "else"
<< "{"
<< "// test" << endl
<< "b ();"
<< "}"
<< "}";
os << "namespace a"
<< "{"
<< "void f ();"
<< "}"
<< "#if defined(__HP_aCC) && __HP_aCC <= 39999" << endl
<< "#include <foo.h>" << endl
<< "#endif" << endl
<< endl
<< "namespace b"
<< "{"
<< "void f ();"
<< "}";
// Test do-while handling.
//
os << "do" << endl
<< "f ();"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "f ();"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "if (f ())"
<< "{"
<< "g ();"
<< "}"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "do" << endl
<< "f ();"
<< "while (false);"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "do"
<< "{"
<< "f ();"
<< "}"
<< "while (false);"
<< "}"
<< "while (false);"
<< endl;
}
|