8196551: Update TestSourceVersion.java to be robust across version changes

Reviewed-by: vromero
This commit is contained in:
Joe Darcy 2018-02-01 09:16:03 -08:00
parent 7d09a4bc83
commit 69287b5b99

View File

@ -23,7 +23,7 @@
/*
* @test
* @bug 7025809 8028543 6415644 8028544 8029942 8187951 8193291
* @bug 7025809 8028543 6415644 8028544 8029942 8187951 8193291 8196551
* @summary Test latest, latestSupported, underscore as keyword, etc.
* @author Joseph D. Darcy
* @modules java.compiler
@ -46,11 +46,20 @@ public class TestSourceVersion {
}
private static void testLatestSupported() {
if (SourceVersion.latest() != RELEASE_11 ||
SourceVersion.latestSupported() != RELEASE_10)
SourceVersion[] values = SourceVersion.values();
SourceVersion last = values[values.length - 1];
SourceVersion latest = SourceVersion.latest();
SourceVersion latestSupported = SourceVersion.latestSupported();
if (latest == last &&
latestSupported == SourceVersion.valueOf("RELEASE_" + Runtime.version().feature()) &&
(latest == latestSupported || (latest.ordinal() - latestSupported.ordinal() == 1)) )
return;
else {
throw new RuntimeException("Unexpected release value(s) found:\n" +
"latest:\t" + SourceVersion.latest() + "\n" +
"latestSupported:\t" + SourceVersion.latestSupported());
"latest:\t" + latest + "\n" +
"latestSupported:\t" + latestSupported);
}
}
private static void testVersionVaryingKeywords() {