<commit_before>package org.jetbrains.plugins.scala.debugger.evaluateExpression

import org.jetbrains.plugins.scala.debugger.ScalaDebuggerTestCase


/**
 * User: Alefas
 * Date: 17.10.11
 */

class ScalaMethodEvaluationTest extends ScalaDebuggerTestCase {
  def testBigIntAndSorted() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 2)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalStartsWith("BigInt(2)", "2")
      evalEquals("Seq(4, 3, 2, 1).sorted", "List(1, 2, 3, 4)")
    }
  }

  def testBoxing() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 2)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalStartsWith("1 -> 2", "(1,2)")
      evalEquals("123.toString", "123")
    }
  }
  
  def testSmartBoxing() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def foo(x: AnyVal) = 1
      |  def goo(x: Int) = x + 1
      |  def main(args: Array[String]) {
      |    val z = java.lang.Integer.valueOf(5)
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 5)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo(1)", "1")
      evalEquals("goo(z)", "6")
    }
  }  

  def testChangingFunction() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  var i = 1
      |  def foo = {
      |    i = i + 1
      |    i
      |  }
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 7)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo", "2")
      evalEquals("foo", "3")
    }
  }

  def testSimpleFunction() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def foo() = 2
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 3)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo", "2")
    }
  }
  
  def testApplyCall() {
    addFileToProject("Sample.scala",<commit_msg>test for evaluation private method<commit_after>package org.jetbrains.plugins.scala.debugger.evaluateExpression

import org.jetbrains.plugins.scala.debugger.ScalaDebuggerTestCase


/**
 * User: Alefas
 * Date: 17.10.11
 */

class ScalaMethodEvaluationTest extends ScalaDebuggerTestCase {
  def testBigIntAndSorted() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 2)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalStartsWith("BigInt(2)", "2")
      evalEquals("Seq(4, 3, 2, 1).sorted", "List(1, 2, 3, 4)")
    }
  }

  def testBoxing() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 2)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalStartsWith("1 -> 2", "(1,2)")
      evalEquals("123.toString", "123")
    }
  }
  
  def testSmartBoxing() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def foo(x: AnyVal) = 1
      |  def goo(x: Int) = x + 1
      |  def main(args: Array[String]) {
      |    val z = java.lang.Integer.valueOf(5)
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 5)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo(1)", "1")
      evalEquals("goo(z)", "6")
    }
  }  

  def testChangingFunction() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  var i = 1
      |  def foo = {
      |    i = i + 1
      |    i
      |  }
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 7)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo", "2")
      evalEquals("foo", "3")
    }
  }

  def testSimpleFunction() {
    addFileToProject("Sample.scala",
      """
      |object Sample {
      |  def foo() = 2
      |  def main(args: Array[String]) {
      |    "stop here"
      |  }
      |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 3)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo", "2")
    }
  }

  def testPrivateMethods() {
    addFileToProject("Sample.scala",
      """
        |import Sample._
        |object Sample {
        |  private def foo() = 2
        |  def main(args: Array[String]) {
        |    "stop here"
        |  }
        |}
        |class Sample {
        |  private def bar() = 1
        |}
      """.stripMargin.trim()
    )
    addBreakpoint("Sample.scala", 4)
    runDebugger("Sample") {
      waitForBreakpoint()
      evalEquals("foo", "2")
      evalEquals("new Sample().bar()", "1")
    }
  }
  
  def testApplyCall() {
    addFileToProject("Sample.scala",
{'fraction_non_alphanumeric': 0.16103848946986202, 'fraction_numerical': 0.016521423384168482, 'mean_word_length': 2.043646408839779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '22440', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1874, 'n_words': 313}