/**
* Test method for {@link org.kie.rule.builder.dialect.java.JavaExprAnalyzer#analyzeBlock(java.lang.String, java.util.Set[])}.
*/
@Test
public void testAnalyzeBlock() {
JavaExprAnalyzer analyzer = new JavaExprAnalyzer();
String codeBlock = "int x;\n"+
"Cheese cheese = new Cheese();\n"+
"for( Iterator it = list.iterator(); it.hasNext(); ) {\n" +
" int shouldNotBeIncluded = 1;\n"+
"}\n" +
"{\n" +
" String anotherNonTopLevelVar = \"test\";\n" +
"}\n" +
"double thisIsAGoodVar = 0;\n" +
"method();\n";
try {
JavaAnalysisResult analysis = analyzer.analyzeBlock( codeBlock, new BoundIdentifiers( new HashMap<String, Class<?>>(), new HashMap<String, Class<?>>() ) );
Set<String> vars = analysis.getLocalVariables();
assertEquals( 3, vars.size() );
assertTrue( vars.contains( "x" ));
assertTrue( vars.contains( "cheese" ));
assertTrue( vars.contains( "thisIsAGoodVar" ));