result = this.preprocessor.preprocess( "MyClass.java", lines ); assertEquals( Preprocessor.CHANGED, result ); styleSheet = this.preprocessor.getStyleSheet(); assertTrue( styleSheet.isUsed("weird"));
try { result = this.preprocessor.preprocess( "MyClass.java", lines ); fail("#style directive should fail when no method call or new operator follows the directive."); } catch (BuildException e) {  }
	public void testStyle() throws BuildException {		String[] sourceLines = new String[] {				"	//#ifdef test1 ",				"	String hello =  \"test1 is defined\";",				"	//#else",				"	//# String hello =  \"test1 is not defined\";",				"	//#style weird",				"	//#endif",				"	System.out.println( hello );"		};		StringList lines = new StringList( sourceLines );		int result = this.preprocessor.preprocess( "MyClass.java", lines );		assertEquals( Preprocessor.NOT_CHANGED, result );		StyleSheet styleSheet = this.preprocessor.getStyleSheet();		assertFalse( styleSheet.isUsed("weird"));				sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style weird",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		result = this.preprocessor.preprocess( "MyClass.java", lines );		assertEquals( Preprocessor.CHANGED, result );		styleSheet = this.preprocessor.getStyleSheet();		assertTrue( styleSheet.isUsed("weird"));				sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style crazy",				"	//# Item myItem = new StringItem(\"label\", \"text\"); // create StringItem... ",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		result = this.preprocessor.preprocess( "MyClass.java", lines );		assertEquals( Preprocessor.CHANGED, result );		styleSheet = this.preprocessor.getStyleSheet();		assertTrue( styleSheet.isUsed("crazy"));				sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style funny",				"	//# Item myItem = new StringItem(",				"	//#		\"label\", ",				"	//#		\"text\"); // create StringItem... ",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		result = this.preprocessor.preprocess( "MyClass.java", lines );		assertEquals( Preprocessor.CHANGED, result );		styleSheet = this.preprocessor.getStyleSheet();		assertTrue( styleSheet.isUsed("funny"));				// without closing semicolon:		sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style funny",				"	//# Item myItem = new StringItem(",				"	//#		\"label\", ",				"	//#		\"text\") // create StringItem... ",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		try {			result = this.preprocessor.preprocess( "MyClass.java", lines );			fail("preprocess should fail when encountering #style directive with syntax errors.");		} catch (BuildException e) {			// expected behaviour!		}		// with single semicolon:		sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style funny",				"	//# Item myItem = new StringItem(",				"	//#		\"label\", ",				"	//#		\"text\") // create StringItem... ",				";",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		try {			result = this.preprocessor.preprocess( "MyClass.java", lines );			fail("preprocess should fail when encountering #style directive with syntax errors.");		} catch (BuildException e) {			// expected behaviour!		}				// test undefined style:		sourceLines = new String[] {				"	//#ifdef XXtest1 ",				"	String hello =  \"XXtest1 is defined\";",				"	//#else",				"	//# String hello =  \"XXtest1 is not defined\";",				"	//#style styleWhichHasNeverBeenDefined, anotherInvalidStyle",				"	//# Item myItem = new StringItem(",				"	//#		\"label\", ",				"	//#		\"text\"); // create StringItem... ",				"	//#endif",				"	System.out.println( hello );"		};		lines = new StringList( sourceLines );		try {			result = this.preprocessor.preprocess( "MyClass.java", lines );			fail("preprocess should fail when encountering #style directive with syntax errors.");		} catch (BuildException e) {			//e.printStackTrace();			// expected behaviour!		}			}	