~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/append/ExpressionTest.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
 
3
 * Rapperswil, University of applied sciences and others
 
4
 * All rights reserved. This program and the accompanying materials 
 
5
 * are made available under the terms of the Eclipse Public License v1.0 
 
6
 * which accompanies this distribution, and is available at 
 
7
 * http://www.eclipse.org/legal/epl-v10.html  
 
8
 *  
 
9
 * Contributors: 
 
10
 *     Institute for Software - initial API and implementation
 
11
 *******************************************************************************/
 
12
package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.append;
 
13
 
 
14
import junit.framework.Test;
 
15
 
 
16
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
 
17
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
 
18
import org.eclipse.cdt.core.dom.ast.IASTExpression;
 
19
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
 
20
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
 
21
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
 
22
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
 
23
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
 
24
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
 
25
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
 
26
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
 
27
 
 
28
public class ExpressionTest extends ChangeGeneratorTest {
 
29
 
 
30
        public ExpressionTest(){
 
31
                super("Append Expression"); //$NON-NLS-1$
 
32
        }
 
33
 
 
34
        @Override
 
35
        protected void setUp() throws Exception {
 
36
                source = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5;}"; //$NON-NLS-1$
 
37
                expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5, c = 9;}"; //$NON-NLS-1$
 
38
                super.setUp();
 
39
        }
 
40
        @Override
 
41
        protected ASTVisitor createModificator(final ASTModificationStore modStore) {
 
42
                return new ASTVisitor() {
 
43
                        {
 
44
                                shouldVisitExpressions = true;
 
45
                        }
 
46
                        
 
47
                        @Override
 
48
                        public int visit(IASTExpression expression) {
 
49
                                if (expression instanceof IASTExpressionList) {
 
50
                                        IASTExpressionList expressionList = (IASTExpressionList) expression;
 
51
                                        expressionList.getExpressions();
 
52
                                        CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, new CPPASTIdExpression(new CPPASTName("c".toCharArray())), new CPPASTLiteralExpression(0, "9")); //$NON-NLS-1$ //$NON-NLS-2$
 
53
                                        ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, expressionList, binEx, null);
 
54
                                        modStore.storeModification(null, modification);
 
55
                                }
 
56
 
 
57
                                return PROCESS_CONTINUE;
 
58
                        }
 
59
                        
 
60
                };
 
61
        }
 
62
        public static Test suite() {
 
63
                return new ExpressionTest();
 
64
                
 
65
        }
 
66
}