-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: org.scala-ide.sdt.core.tests/src/org/scalaide/TestsSuite.scala org.scala-ide.sdt.core/src/org/scalaide/core/internal/builder/zinc/JavaEclipseCompiler.scala
- Loading branch information
Showing
35 changed files
with
710 additions
and
251 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
58 changes: 58 additions & 0 deletions
58
...ala-ide.sdt.core.tests/src/org/scalaide/core/sbtbuilder/ScalacNotUnderstandJavaTest.scala
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,58 @@ | ||
package org.scalaide.core | ||
package sbtbuilder | ||
|
||
import org.eclipse.core.resources.IFile | ||
import org.eclipse.core.resources.IncrementalProjectBuilder | ||
import org.eclipse.core.runtime.NullProgressMonitor | ||
import org.junit.Assert._ | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
import org.scalaide.core.testsetup.SDTTestUtils | ||
|
||
object ScalacNotUnderstandJavaTest extends testsetup.TestProjectSetup("scalacnotunderstandjava") { | ||
@BeforeClass def setup(): Unit = { | ||
SDTTestUtils.enableAutoBuild(false) | ||
} | ||
} | ||
|
||
class ScalacNotUnderstandJavaTest { | ||
import ScalacNotUnderstandJavaTest._ | ||
import testsetup.SDTTestUtils._ | ||
|
||
@Test def shouldContinueJavaCompilationEvenWhenScalacDoesNotUnderstandJavaFile(): Unit = { | ||
val NoErrors = 0 | ||
val JavaCannotConvertFromStringToInt = 1 | ||
cleanProject() | ||
|
||
val SScalaCU = compilationUnit("test/S.scala") | ||
val JJavaCU = compilationUnit("test/J.java") | ||
def findProblems() = getProblemMarkers(JJavaCU, SScalaCU) | ||
|
||
rebuild() | ||
val problems0 = findProblems() | ||
assertTrue("One build error expected, got: " + markersMessages(problems0), problems0.length == NoErrors) | ||
|
||
val originalSScala = slurpAndClose(project.underlying.getFile("src/test/S.scala").getContents) | ||
changeContentOfFile(SScalaCU.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changedSScala) | ||
rebuild() | ||
val problems1 = findProblems() | ||
assertTrue("One build error expected, got: " + markersMessages(problems1), problems1.length == JavaCannotConvertFromStringToInt) | ||
|
||
changeContentOfFile(SScalaCU.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], originalSScala) | ||
rebuild() | ||
val problems2 = findProblems() | ||
assertTrue("Build errors found: " + markersMessages(problems2), problems2.isEmpty) | ||
} | ||
|
||
private def rebuild(): Unit = { | ||
project.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor) | ||
} | ||
|
||
lazy private val changedSScala = """ | ||
package test | ||
class S { | ||
def foo = "51" | ||
} | ||
""" | ||
} |
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
70 changes: 70 additions & 0 deletions
70
...la-ide.sdt.core.tests/src/org/scalaide/ui/internal/preferences/StringListMapperTest.scala
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,70 @@ | ||
package org.scalaide.ui.internal.preferences | ||
|
||
import org.junit.Assert._ | ||
import org.junit.Test | ||
|
||
class StringListMapperTest { | ||
private def testWith(strs: String*): Unit = { | ||
val encoded = StringListMapper.encode(strs) | ||
val decoded = StringListMapper.decode(encoded) | ||
assertEquals(s"Error related to encoded representation '$encoded'", strs, decoded) | ||
} | ||
|
||
private def expectExceptionOnDecode(str: String): Unit = { | ||
try { | ||
StringListMapper.decode(str) | ||
throw new AssertionError(s"Expected IllegalArgumentException for input $str") | ||
} catch { | ||
case _: IllegalArgumentException => () | ||
} | ||
} | ||
|
||
@Test | ||
def emptyList(): Unit = { | ||
testWith() | ||
} | ||
|
||
@Test | ||
def emptyString(): Unit = { | ||
testWith("") | ||
} | ||
|
||
@Test | ||
def singleString(): Unit = { | ||
testWith("single") | ||
testWith("0") | ||
testWith("1") | ||
} | ||
|
||
@Test | ||
def mulitpleStrings(): Unit = { | ||
testWith("a", "b") | ||
testWith("", "") | ||
testWith("", "", "") | ||
testWith("0", "0", "0") | ||
testWith("", "", "", "a", "b", "abc") | ||
testWith("0", "1", " ", "a", "b", "abc", "\n", "12340") | ||
} | ||
|
||
@Test | ||
def withListOfEncodedLists(): Unit = { | ||
testWith( | ||
StringListMapper.encode(Seq()), | ||
StringListMapper.encode(Seq("")), | ||
StringListMapper.encode(Seq("", "1", "22"))) | ||
} | ||
|
||
@Test | ||
def noStackOverflow(): Unit = { | ||
testWith(Seq.fill(10000)(""): _*) | ||
} | ||
|
||
@Test | ||
def testWithIllegalInput(): Unit = { | ||
expectExceptionOnDecode("1") | ||
expectExceptionOnDecode("2|a") | ||
expectExceptionOnDecode("1|1|2|1") | ||
expectExceptionOnDecode("asdf3|||") | ||
expectExceptionOnDecode("9|8|") | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
org.scala-ide.sdt.core.tests/test-workspace/scalacnotunderstandjava/.classpath
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
18 changes: 18 additions & 0 deletions
18
org.scala-ide.sdt.core.tests/test-workspace/scalacnotunderstandjava/.project
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>scalacnotunderstandjava</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
14 changes: 14 additions & 0 deletions
14
org.scala-ide.sdt.core.tests/test-workspace/scalacnotunderstandjava/src/test/J.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,14 @@ | ||
package test; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(value=RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE_USE, ElementType.PARAMETER, ElementType.METHOD, ElementType.TYPE}) | ||
@interface ScalacDoesNotGetMe {} | ||
|
||
class J<@ScalacDoesNotGetMe X> { | ||
public int f = (new S()).foo(); | ||
} |
5 changes: 5 additions & 0 deletions
5
org.scala-ide.sdt.core.tests/test-workspace/scalacnotunderstandjava/src/test/S.scala
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,5 @@ | ||
package test | ||
|
||
class S { | ||
def foo = 51 | ||
} |
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
Oops, something went wrong.