Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1bf32ed357a394295996229d96181ff9b22c9c5d (plain) (blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/*******************************************************************************
 * Copyright (c) 2005, 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;

import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;

public class AST2UtilOldTests extends AST2BaseTest {
	public AST2UtilOldTests() {
	}
	public AST2UtilOldTests(String name) {
		super(name);
	}
	// Kind PRIMARY_EMPTY : void
	public void testPrimaryEmpty() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f();".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f()" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_INTEGER_LITERAL : int 
	public void testPrimaryIntegerLiteral() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(1, 2+3);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, 2 + 3)" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_CHAR_LITERAL : char
	public void testPrimaryCharLiteral() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f('c');".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f('c')" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_FLOAT_LITERAL : float
	public void testPrimaryFloatLiteral() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(1.13);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1.13)" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_STRING_LITERAL : char*
	public void testPrimaryStringLiteral() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(\"str\");".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(\"str\")" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_BOOLEAN_LITERAL : bool
	public void testPrimaryBooleanLiteral() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(true);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(true)" ); //$NON-NLS-1$
	}
	// Kind PRIMARY_THIS : type of inner most enclosing structure scope
	public void testPrimaryThis() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(this);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(this)" ); //$NON-NLS-1$
	}	
	// Kind PRIMARY_BRACKETED_EXPRESSION : LHS
	public void testPrimaryBracketedExpression() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(1, (2+3));".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(1, (2 + 3))" ); //$NON-NLS-1$
	}
	// Kind ID_EXPRESSION : type of the ID
	public void testIdExpression() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(a);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(a)" ); //$NON-NLS-1$
	}	
	// Kind POSTFIX_SUBSCRIPT	
	public void testPostfixSubscript() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(pa[1]);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1])" ); //$NON-NLS-1$
	}
		
 	public void testPostfixSubscriptA() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(pa[1][2]);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(pa[1][2])" ); //$NON-NLS-1$
	}	 
  
	// Kind POSTFIX_FUNCTIONCALL : return type of called function
	public void testPostfixFunctioncallBug42822() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = bar( foo( 3.0 ), foo( 5.0 ) ) ;".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "bar(foo(3.0), foo(5.0))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_SIMPLETYPE_* : simple type
	public void testPostfixSimpletypesBug42823() throws Exception
	{
		IASTTranslationUnit tu = parse("int someInt = foo( int(3), short(4), double(3.0), float(4.0), char( 'a'), wchar_t( 'a' ), signed( 2 ), unsigned( 3 ), bool( false ), long( 3L ) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$
	}
	
	// Kind POSTFIX_DOT_IDEXPRESSION : type of member in the scope of the container
	public void testPostfixDotExpression() throws Exception{
		IASTTranslationUnit tu = parse("class A {int m;}; \n A  a; \n int foo(char); int foo( int ); \n int x = foo( a.m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a.m)" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_ARROW_IDEXPRESSION : type of member in the scope of the container
	public void testPostfixArrowExpression() throws Exception{
		IASTTranslationUnit tu = parse("class A {int m;}; \n A * a; \n int foo(char); int foo( int ); \n int x = foo( a->m );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a->m)" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_INCREMENT : LHS 
	public void testPostfixIncrement() throws Exception
	{
		IASTTranslationUnit tu = parse("int y = foo( x++ );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x++)" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_DECREMENT : LHS
	public void testPostfixDecrement() throws Exception
	{
		IASTTranslationUnit tu = parse("int y = foo( x-- );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(x--)" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_DYNAMIC_CAST 
	public void testPostfixDynamicCast() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( dynamic_cast<B*>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(dynamic_cast<B*>(a))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_REINTERPRET_CAST
	public void testPostfixReinterpretCast() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( reinterpret_cast<double *>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(reinterpret_cast<double *>(a))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_STATIC_CAST
	public void testPostfixStaticCast() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( static_cast<char>(a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(static_cast<char>(a))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_CONST_CAST
	public void testPostfixConstCast() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( const_cast<int *>(&a) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(const_cast<int *>(&a))" ); //$NON-NLS-1$
	}	
	// Kind POSTFIX_TYPEID_EXPRESSION : LHS
	public void testPostfixTypeIdExpression() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( typeid(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(5))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_TYPEID_EXPRESSION : type of the ID
	public void testPostfixTypeIdExpression2() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( typeid(a) );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(a))" ); //$NON-NLS-1$
	}
	// Kind POSTFIX_TYPEID_TYPEID : type of the ID

	public void testPostfixTypeIdTypeId2() throws Exception{
		IASTTranslationUnit tu = parse("class A { }; int foo( int ); int x = foo( typeid(const A) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(typeid(const A))" ); //$NON-NLS-1$
	}	
	// Kind UNARY_INCREMENT : LHS             
	public void testUnaryIncrement() throws Exception
	{
		IASTTranslationUnit tu = parse("int y = foo( ++x );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(++x)" ); //$NON-NLS-1$
	}	
	// Kind UNARY_DECREMENT : LHS             
	public void testUnaryDecrement() throws Exception
	{
		IASTTranslationUnit tu = parse("int y = foo( --x );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(--x)" ); //$NON-NLS-1$
	}
	// Kind UNARY_STAR_CASTEXPRESSION : LHS + t_pointer	
	public void testUnaryStarCastExpression() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(*pa);".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(*pa)" ); //$NON-NLS-1$
	}
	// Kind UNARY_AMPSND_CASTEXPRESSION : LHS + t_reference
	public void testUnaryAmpersandCastExpression() throws Exception
	{
		IASTTranslationUnit tu = parse("int x = f(&pa);".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "f(&pa)" ); //$NON-NLS-1$
	}
	// Kind UNARY_PLUS_CASTEXPRESSION  : LHS
	public void testUnaryPlusCastExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( +5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(+5)" ); //$NON-NLS-1$
	}
	// Kind UNARY_MINUS_CASTEXPRESSION : LHS
	public void testUnaryMinusCastExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( -5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(-5)" ); //$NON-NLS-1$
	}
	// Kind UNARY_NOT_CASTEXPRESSION : LHS   
	public void testUnaryNotCastExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( !b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(!b)" ); //$NON-NLS-1$
	}
	// Kind UNARY_TILDE_CASTEXPRESSION : LHS   
	public void testTildeNotCastExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int y = foo( ~x );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(~x)" ); //$NON-NLS-1$
	}
	// Kind UNARY_SIZEOF_UNARYEXPRESSION : unsigned int 
	public void testUnarySizeofUnaryExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int y = foo( sizeof(5) );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(sizeof (5))" ); //$NON-NLS-1$
	}
	// Kind UNARY_SIZEOF_TYPEID : unsigned int          
	public void testUnarySizeofTypeId() throws Exception { 
		IASTTranslationUnit tu = parse("int x, y = foo( sizeof(x) );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		final IASTInitializerClause expression = ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[1].getInitializer()).getInitializerClause();
        isExpressionStringEqual( expression, "foo(sizeof (x))" ); //$NON-NLS-1$
	}
	// Kind NEW_TYPEID                   
	public void testNewTypeId() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( new A() );".toString(), ParserLanguage.CPP); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(new A())" ); //$NON-NLS-1$
	}

	// Kind CASTEXPRESSION      
	public void testCastExpression() throws Exception{
		IASTTranslationUnit tu = parse("int x = foo( (A*)b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo((A*)b)" ); //$NON-NLS-1$
	}
	         
	// Kind MULTIPLICATIVE_MULTIPLY : usual arithmetic conversions
	public void testMultiplicativeMultiply() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a * b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a * b)" ); //$NON-NLS-1$
	}
	// Kind MULTIPLICATIVE_DIVIDE : usual arithmetic conversions        
	public void testMultiplicativeDivide() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b / a );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b / a)" ); //$NON-NLS-1$
	}	
	// Kind MULTIPLICATIVE_MODULUS : usual arithmetic conversions      
	public void testMultiplicativeModulus() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b % a );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b % a)" ); //$NON-NLS-1$
	}	
	// Kind ADDITIVE_PLUS : usual arithmetic conversions              
	public void testAdditivePlus() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b + a );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b + a)" ); //$NON-NLS-1$
	}	
	// Kind ADDITIVE_MINUS : usual arithmetic conversions           
	public void testAdditiveMinus() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b - a );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b - a)" ); //$NON-NLS-1$
	}	
	// Kind SHIFT_LEFT : LHS
	public void testShiftLeft() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a << 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a << 5)" ); //$NON-NLS-1$
	}              
	// Kind SHIFT_RIGHT : LHS                  
	public void testShiftRight() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a >> 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >> 5)" ); //$NON-NLS-1$
	}
	// Kind RELATIONAL_LESSTHAN : bool          
	public void testRelationalLessThan() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b < 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b < 3)" ); //$NON-NLS-1$
	}
	// Kind RELATIONAL_GREATERTHAN : bool      
	public void testRelationalGreaterThan() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b > 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b > 3)" ); //$NON-NLS-1$
	}
	// Kind RELATIONAL_LESSTHANEQUALTO : bool  
	public void testRelationalLessThanOrEqual() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b <= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b <= 3)" ); //$NON-NLS-1$
	}
	// Kind RELATIONAL_GREATERTHANEQUALTO : bool
	public void testRelationalGreaterThanOrEqual() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b >= 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b >= 3)" ); //$NON-NLS-1$
	}
	// Kind EQUALITY_EQUALS : bool         
	public void testEqualityEquals() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b == 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b == 3)" ); //$NON-NLS-1$
	}
	// Kind EQUALITY_NOTEQUALS : bool      
	public void testEqualityNotEquals() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( b != 3 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(b != 3)" ); //$NON-NLS-1$
	}
	// Kind ANDEXPRESSION  : usual arithmetic conversions          
	public void testAndExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a & b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a & b)" ); //$NON-NLS-1$
	}
	// Kind EXCLUSIVEOREXPRESSION : usual arithmetic conversions      
	public void testExclusiveOrExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a ^ b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^ b)" ); //$NON-NLS-1$
	}
	// Kind INCLUSIVEOREXPRESSION : : usual arithmetic conversions     
	public void testInclusiveOrExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a | b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a | b)" ); //$NON-NLS-1$
	}
	// Kind LOGICALANDEXPRESSION : bool      
	public void testLogicalAndExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a && b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a && b)" ); //$NON-NLS-1$
	}
	// Kind LOGICALOREXPRESSION  : bool      
	public void testLogicalOrExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a || b );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a || b)" ); //$NON-NLS-1$
	}
	// Kind CONDITIONALEXPRESSION : conditional Expression Conversions     
	public void testConditionalExpression() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a > 5 ? b : c );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a > 5 ? b : c)" ); //$NON-NLS-1$
	}
	            
	// Kind ASSIGNMENTEXPRESSION_NORMAL : LHS
	public void testAssignmentExpressionNormal() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a = 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a = 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_PLUS : LHS  
	public void testAssignmentExpressionPlus() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a += 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a += 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_MINUS : LHS 
	public void testAssignmentExpressionMinus() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a -= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a -= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_MULT : LHS  
	public void testAssignmentExpressionMulti() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a *= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a *= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_DIV : LHS   
	public void testAssignmentExpressionDiv() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a /= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a /= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_MOD : LHS   
	public void testAssignmentExpressionMod() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a %= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a %= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_LSHIFT : LHS
	public void testAssignmentExpressionLShift() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a >>= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a >>= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_RSHIFT : LHS
	public void testAssignmentExpressionRShift() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a <<= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a <<= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_AND : LHS
	public void testAssignmentExpressionAnd() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a &= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a &= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_OR : LHS 
	public void testAssignmentExpressionOr() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a |= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a |= 5)" ); //$NON-NLS-1$
	}
	// Kind ASSIGNMENTEXPRESSION_XOR : LHS
	public void testAssignmentExpressionXOr() throws Exception { 
		IASTTranslationUnit tu = parse("int x = foo( a ^= 5 );".toString(), ParserLanguage.C); //$NON-NLS-1$
		IASTDeclaration[] d = tu.getDeclarations();
		isExpressionStringEqual( ((IASTEqualsInitializer)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getInitializerClause(), "foo(a ^= 5)" ); //$NON-NLS-1$
	}
	
}

Back to the top