Kaynağa Gözat

164288 (Jdeveloper) - fixes and tests in

tags/V1_5_3_final
aclement 17 yıl önce
ebeveyn
işleme
c54fa62036

+ 4
- 3
ajde/src/org/aspectj/ajde/BuildOptionsAdapter.java Dosyayı Görüntüle

@@ -135,13 +135,14 @@ public interface BuildOptionsAdapter {
/**
* JDK Compliance level to be used by the compiler, either
* VERSION_13 or VERSION_14.
* From -1.3 / -1.4
* VERSION_13, VERSION_14 or VERSION_15.
* From -1.3 / -1.4 / -1.5
*/
public String getComplianceLevel();
/**
* Source compatibility level, either VERSION_13 or VERSION_14.
* Source compatibility level, either VERSION_13, VERSION_14
* or VERSION_15
* From -source (eclipse option)
*/
public String getSourceCompatibilityLevel();

+ 11
- 3
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java Dosyayı Görüntüle

@@ -246,6 +246,7 @@ public class CompilerAdapter {
if (options.getSourceCompatibilityLevel() != null && options.getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_5)) {
optionsToSet.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
config.setBehaveInJava5Way(true);
} else if (options.getSourceCompatibilityLevel() != null && options.getSourceCompatibilityLevel().equals(CompilerOptions.VERSION_1_4)) {
optionsToSet.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
@@ -261,6 +262,9 @@ public class CompilerAdapter {
String version = CompilerOptions.VERSION_1_4;
if ( compliance.equals( BuildOptionsAdapter.VERSION_13 ) ) {
version = CompilerOptions.VERSION_1_3;
} else if (compliance.equals(BuildOptionsAdapter.VERSION_15)) {
version = CompilerOptions.VERSION_1_5;
config.setBehaveInJava5Way(true);
}
optionsToSet.put(CompilerOptions.OPTION_Compliance, version );
optionsToSet.put(CompilerOptions.OPTION_Source, version );
@@ -275,12 +279,16 @@ public class CompilerAdapter {
// never set a lower source level than compliance level
// Mik: prepended with 1.5 check
if (sourceLevel.equals(CompilerOptions.VERSION_1_5)) {
optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
config.setBehaveInJava5Way(true);
} else {
if (optionsToSet.containsKey(CompilerOptions.OPTION_Compliance)) {
String setCompliance = (String) optionsToSet.get(CompilerOptions.OPTION_Compliance);
if ( ! (setCompliance.equals(CompilerOptions.VERSION_1_4 )
&& slVersion.equals(CompilerOptions.VERSION_1_3)) ) {
if (setCompliance.equals(CompilerOptions.VERSION_1_5)) {
optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
config.setBehaveInJava5Way(true);
} else if ( ! (setCompliance.equals(CompilerOptions.VERSION_1_4)
&& slVersion.equals(CompilerOptions.VERSION_1_3)) ) {
optionsToSet.put(CompilerOptions.OPTION_Source, slVersion);
}
}

+ 50
- 1
ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java Dosyayı Görüntüle

@@ -68,8 +68,19 @@ public class BuildConfigurationTests extends AjdeTestCase {
String encoding = (String) options.get( CompilerOptions.OPTION_Encoding );
assertEquals( "character encoding", "UTF-8", encoding );
}

public void testComplianceLevelJava13() {
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13 );
buildConfig = compilerAdapter.genBuildConfig( configFile );
assertTrue(configFile + " failed", null != buildConfig);
Map options = buildConfig.getOptions().getMap();
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance);
assertEquals( "source level", CompilerOptions.VERSION_1_3, sourceLevel );
}
public void testComplianceLevel() {
public void testComplianceLevelJava14() {
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 );
buildConfig = compilerAdapter.genBuildConfig( configFile );
assertTrue(configFile + " failed", null != buildConfig);
@@ -122,6 +133,18 @@ public class BuildConfigurationTests extends AjdeTestCase {
}
}
public void testCompilanceLevelJava5() {
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15 );
buildConfig = compilerAdapter.genBuildConfig( configFile );
assertTrue(configFile + " failed", null != buildConfig);
Map options = buildConfig.getOptions().getMap();
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
}
public void testSourceCompatibilityLevel() {
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13);
buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14);
@@ -146,7 +169,33 @@ public class BuildConfigurationTests extends AjdeTestCase {
assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance);
assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel );
}

public void testSourceCompatibilityLevelJava5() {
buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_15);
buildConfig = compilerAdapter.genBuildConfig( configFile );
assertTrue(configFile + " failed", null != buildConfig);
Map options = buildConfig.getOptions().getMap();
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
}
public void testSourceIncompatibilityLevelJava5() {
// because compliance is set to be 1.5 then source compatibility
// will be set to 1.5
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15);
buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14);
buildConfig = compilerAdapter.genBuildConfig( configFile );
assertTrue(configFile + " failed", null != buildConfig);
Map options = buildConfig.getOptions().getMap();
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
}
public void testNullWarnings() {
buildOptions.setWarnings( null );

Loading…
İptal
Kaydet