Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added tests for quick fixes

  • Loading branch information...
commit 545f0b9200959d6bee3c502d0bc6c752818d7012 1 parent 4285a15
@kaptoxic authored
View
69 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/quickfix/QuickFixesTests.scala
@@ -25,6 +25,7 @@ import org.eclipse.jdt.ui.text.java.IProblemLocation
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal
import org.eclipse.jdt.core.compiler.IProblem
import scala.collection.mutable.Buffer
+import org.eclipse.jdt.ui.JavaUI
object QuickFixesTests extends TestProjectSetup("quickfix") {
@@ -72,17 +73,15 @@ class QuickFixesTests {
// do a compiler reload before checking for problems
val dummy = new Response[Unit]
compiler.askReload(List(src), dummy)
- dummy.get
-//
-// val cu = unit.getCompilationUnit.asInstanceOf[CompilationUnit]
-//
-//
-// val problems = cu.getProblems
+ dummy.get
val problems = compiler.problemsOf(unit)
assertTrue("No problems found.", problems.size > 0)
assertNumberOfProblems(expectedQuickFixesList.size, problems.toArray)
+ val editor = JavaUI.openInEditor(unit.getCompilationUnit)
+ Thread.sleep(5000)
+
// check each problem quickfix
for ( (problem, expectedQuickFixes) <- problems zip expectedQuickFixesList) {
// here we will accumulate proposals
@@ -94,11 +93,8 @@ class QuickFixesTests {
val context= new AssistContext(unit.getCompilationUnit, offset, length)
val problemLocation: IProblemLocation = new ProblemLocation(problem);
- //val status = JavaCorrectionProcessor.collectCorrections(context, Array( problemLocation ), proposals)
- val status = JavaCorrectionProcessor.collectAssists(context, Array( problemLocation ), proposals)
+ val status = JavaCorrectionProcessor.collectCorrections(context, Array( problemLocation ), proposals)
- assertTrue("proposals" + proposals.size(), false)
-
// assert that status is okay
assertStatusOk(status)
@@ -129,11 +125,54 @@ class QuickFixesTests {
stringPattern.format("List[List[Int]]()","List[List[Int]]().head"),
stringPattern.format("List[List[Int]]()","List[List[Int]]().last")
),
- List(stringPattern.format("List[List[Int]]()","List[List[Int]]().flatten") ),
- List(stringPattern.format("List[List[Int]]()","List[List[Int]]().flatten") ),
- List(stringPattern.format("List[List[Int]]()","List[List[Int]]().flatten") ),
- List(stringPattern.format("List[List[Int]]()","List[List[Int]]().flatten") ),
- List(stringPattern.format("List[List[Int]]()","List[List[Int]]().flatten") )
+ List(
+ stringPattern.format("listOfInt_val","listOfInt_val.flatten"),
+ stringPattern.format("listOfInt_val","listOfInt_val.head"),
+ stringPattern.format("listOfInt_val","listOfInt_val.last")
+ ),
+ List(
+ stringPattern.format("intVal","Some(intVal)"),
+ stringPattern.format("intVal","Option(intVal)")
+ ),
+ List(
+ stringPattern.format("List[Int]()","List[Int]().toArray")
+ ),
+ List(
+ stringPattern.format("arrayOfInt_val","arrayOfInt_val.toArray")
+ )
+// ,
+// List(
+// stringPattern.format("5","Some(5)"),
+// stringPattern.format("5","Option(5)")
+// ),
+// List(
+// stringPattern.format("5 * 3 + 2","Some(5 * 3 + 2)"),
+// stringPattern.format("5 * 3 + 2","Option(5 * 3 + 2)")
+// ),
+// List(
+// stringPattern.format("5 * 3 + intVal","Some(5 * 3 + intVal)"),
+// stringPattern.format("5 * 3 + intVal","Option(5 * 3 + intVal)")
+// ),
+// List(
+// stringPattern.format("true","Some(true)"),
+// stringPattern.format("true","Option(true)")
+// ),
+// List(
+// stringPattern.format("(intVal % 4 == 2)","Some((intVal % 4 == 2))"),
+// stringPattern.format("(intVal % 4 == 2)","Option((intVal % 4 == 2))")
+// ),
+// List(
+// stringPattern.format("'5'","Some('5')"),
+// stringPattern.format("'5'","Option('5')")
+// ),
+// List(
+// stringPattern.format("\"asd\"","Some(\"asd\")"),
+// stringPattern.format("\"asd\"","Option(\"asd\")")
+// ),
+// List(
+// stringPattern.format("5.3f","Some(5.3f)"),
+// stringPattern.format("5.3f","Option(5.3f)")
+// )
)
)
}
View
13 org.scala-ide.sdt.core.tests/test-workspace/quickfix/src/typemismatch/Basic.scala
@@ -10,13 +10,22 @@ object Basic {
val listOfInt_identifier: List[Int] = listOfInt_val
// options
- val optionOfInt_expression: Option[Int] = 5
val intVal = 5
val optionOfInt_identifier: Option[Int] = intVal
-
+
// arrays
val arrayOfInt_expression: Array[Int] = List[Int]()
val arrayOfInt_val = List[Int]()
val arrayOfInt_identifier: Array[Int] = arrayOfInt_val
+
+ // options literals
+// val optionOfInt_expression: Option[Int] = 5
+// val optionOfInt_expression2: Option[Int] = 5 * 3 + 2
+// val optionOfInt_expression3: Option[Int] = 5 * 3 + intVal
+// val optionOfBoolean_expression: Option[Boolean] = true
+// val optionOfBoolean_expression2: Option[Boolean] = (intVal % 4 == 2)
+// val optionOfChar_expression: Option[Char] = '5'
+// val optionOfString_expression: Option[String] = "asd"
+// val optionOfFloat_expression: Option[Float] = 5.3f
}
Please sign in to comment.
Something went wrong with that request. Please try again.