-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'gwtproject:main' into java-17-support-test
- Loading branch information
Showing
9 changed files
with
215 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
user/test-super/com/google/gwt/dev/jjs/super/com/google/gwt/dev/jjs/test/Java17Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.gwt.dev.jjs.test; | ||
|
||
import com.google.gwt.core.client.GwtScriptOnly; | ||
import com.google.gwt.junit.client.GWTTestCase; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Tests Java 17 features. It is super sourced so that gwt can be compiles under Java 11. | ||
* | ||
* IMPORTANT: For each test here there must exist the corresponding method in the non super sourced | ||
* version. | ||
* | ||
* Eventually this test will graduate and not be super sourced. | ||
*/ | ||
@GwtScriptOnly | ||
public class Java17Test extends GWTTestCase { | ||
|
||
public interface TextBlock { | ||
String text = """ | ||
line 1 | ||
line 2 | ||
line 3 | ||
"""; | ||
} | ||
|
||
public sealed class Shape permits Square, Circle { | ||
|
||
} | ||
|
||
public final class Square extends Shape { | ||
|
||
} | ||
|
||
public final class Circle extends Shape { | ||
|
||
} | ||
|
||
@Override | ||
public String getModuleName() { | ||
return "com.google.gwt.dev.jjs.test.Java17Test"; | ||
} | ||
|
||
public void testTextBlocks() { | ||
List<String> lines = Arrays.asList(TextBlock.text.split("\n")); | ||
assertEquals(3, lines.size()); | ||
assertEquals("line 1", lines.get(0)); | ||
assertEquals("line 2", lines.get(1)); | ||
assertEquals("line 3", lines.get(2)); | ||
} | ||
|
||
public void testSealedClassesPermitted() { | ||
Shape square = new Square(); | ||
Shape circle = new Circle(); | ||
|
||
checkIfCompiled(square, circle); | ||
} | ||
|
||
private void checkIfCompiled(Shape square, Shape circle) { | ||
assertTrue(square instanceof Square); | ||
assertTrue(circle instanceof Circle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- --> | ||
<!-- Copyright 2019 Google Inc. --> | ||
<!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> | ||
<!-- may not use this file except in compliance with the License. You may --> | ||
<!-- may obtain a copy of the License at --> | ||
<!-- --> | ||
<!-- http://www.apache.org/licenses/LICENSE-2.0 --> | ||
<!-- --> | ||
<!-- Unless required by applicable law or agreed to in writing, software --> | ||
<!-- distributed under the License is distributed on an "AS IS" BASIS, --> | ||
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> | ||
<!-- implied. License for the specific language governing permissions and --> | ||
<!-- limitations under the License. --> | ||
|
||
<!-- Contains tests for breaking out of the client source path --> | ||
<module> | ||
<inherits name="com.google.gwt.core.Core" /> | ||
<super-source path='super' /> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.google.gwt.dev.jjs.test; | ||
|
||
import com.google.gwt.dev.util.arg.SourceLevel; | ||
import com.google.gwt.junit.DoNotRunWith; | ||
import com.google.gwt.junit.JUnitShell; | ||
import com.google.gwt.junit.Platform; | ||
import com.google.gwt.junit.client.GWTTestCase; | ||
|
||
/** | ||
* Dummy test case. Java17Test is super sourced so that GWT can be compiled by Java 8. | ||
* | ||
* NOTE: Make sure this class has the same test methods of its supersourced variant. | ||
*/ | ||
@DoNotRunWith(Platform.Devel) | ||
public class Java17Test extends GWTTestCase { | ||
|
||
@Override | ||
public String getModuleName() { | ||
return "com.google.gwt.dev.jjs.Java17Test"; | ||
} | ||
|
||
@Override | ||
public void runTest() throws Throwable { | ||
// Only run these tests if -sourceLevel 17 (or greater) is enabled. | ||
if (isGwtSourceLevel17()) { | ||
super.runTest(); | ||
} | ||
} | ||
|
||
public void testTextBlocks() { | ||
assertFalse(isGwtSourceLevel17()); | ||
} | ||
|
||
public void testSealedClassesPermitted() { | ||
assertFalse(isGwtSourceLevel17()); | ||
} | ||
|
||
private boolean isGwtSourceLevel17() { | ||
return JUnitShell.getCompilerOptions().getSourceLevel().compareTo(SourceLevel.JAVA17) >= 0; | ||
} | ||
} |