From 7a78073d7d0bee35bc8c7e79f502c3c78ff266d2 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 15 May 2008 13:07:55 +0000 Subject: [PATCH] report the IProblemBinding ID constant name on failure --- .../core/parser/tests/ast2/AST2BaseTest.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index 40ef0254769..bce70155acb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -8,10 +8,12 @@ * Contributors: * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; import java.io.IOException; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -456,11 +458,34 @@ public class AST2BaseTest extends BaseTestCase { public IBinding assertNonProblem(String section, int len) { IBinding binding= binding(section, len); - assertTrue("ProblemBinding for name: " + section.substring(0, len), - !(binding instanceof IProblemBinding)); + if(binding instanceof IProblemBinding) { + IProblemBinding problem= (IProblemBinding) binding; + fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")"); + } + if(binding == null) { + fail("Null binding resolved for name: " + section.substring(0, len)); + } return binding; } + private String renderProblemID(int i) { + try { + for(Field field : IProblemBinding.class.getDeclaredFields()) { + if(field.getName().startsWith("SEMANTIC_")) { + if(field.getType() == int.class) { + Integer ci= (Integer) field.get(null); + if(ci.intValue() == i) { + return field.getName(); + } + } + } + } + } catch(IllegalAccessException iae) { + throw new RuntimeException(iae); + } + return "Unknown problem ID"; + } + public T assertNonProblem(String section, int len, Class type, Class... cs) { IBinding binding= binding(section, len); assertTrue("ProblemBinding for name: " + section.substring(0, len),