<commit_before>package tests
import so.eval.Router
import so.eval.SandboxedLanguage.Result
import org.scalatest.{BeforeAndAfter, FunSpec, Inside, ParallelTestExecution}
import org.scalatest.matchers.ShouldMatchers

class Ruby
  extends FunSpec
  with ShouldMatchers
  with Inside
  with BeforeAndAfter
  with ParallelTestExecution {

  def setupSimpleRubyTest(code: String = "puts 1") = {
    val rbOption = Router.route("ruby", code)
    rbOption should not be (None)
    val Some(rb) = rbOption
    (rb, rb.evaluate)
  }

  describe("The Ruby implementation") {
    it("should be able to successfully evaluate Ruby") {
      val (rb, evaluated) = setupSimpleRubyTest()
      evaluated should be ('right)
      val Right(result) = evaluated
      inside(result) {
        case Result(stdout, stderr, wallTime, exitCode, compilationResult) =>
          stdout should be ("1")
          // stderr should be ("")
          wallTime should be < 1000L
          exitCode should be (0)
          compilationResult should be (None)
      }
    }

    it("should clean up after itself") {
      val (rb, evaluated) = setupSimpleRubyTest()
      rb.home.exists should be (false)
    }

    it("should time out after 5 seconds") {
      val (rb, evaluated) = setupSimpleRubyTest("puts 1; sleep 10")
      val Right(result) = evaluated
      inside(result) {
        case Result(stdout, stderr, wallTime, exitCode, compilationResult) =>
          stdout should be ("1")
          // stderr should be ("")
          wallTime should be > 4900L
          wallTime should be < 5200L
          exitCode should be (124)<commit_msg>Fix tests<commit_after>package tests
import so.eval.Router
import so.eval.SandboxedLanguage.Result
import org.scalatest.{BeforeAndAfter, FunSpec, Inside, ParallelTestExecution}
import org.scalatest.matchers.ShouldMatchers

class Ruby
  extends FunSpec
  with ShouldMatchers
  with Inside
  with BeforeAndAfter
  with ParallelTestExecution {

  def setupSimpleRubyTest(code: String = "puts 1") = {
    val rbOption = Router.route("ruby", code)
    rbOption should not be (None)
    val Some(rb) = rbOption
    (rb, rb.evaluate)
  }

  describe("The Ruby implementation") {
    it("should be able to successfully evaluate Ruby") {
      val (rb, evaluated) = setupSimpleRubyTest()
      evaluated should be ('right)
      val Right(result) = evaluated
      inside(result) {
        case Result(stdout, stderr, wallTime, exitCode, compilationResult) =>
          stdout should be ("1\n")
          // stderr should be ("")
          wallTime should be < 1000L
          exitCode should be (0)
          compilationResult should be (None)
      }
    }

    it("should clean up after itself") {
      val (rb, evaluated) = setupSimpleRubyTest()
      rb.home.exists should be (false)
    }

    it("should time out after 5 seconds") {
      val (rb, evaluated) = setupSimpleRubyTest("puts 1; sleep 10")
      val Right(result) = evaluated
      inside(result) {
        case Result(stdout, stderr, wallTime, exitCode, compilationResult) =>
          stdout should be ("1\n")
          // stderr should be ("")
          wallTime should be > 4900L
          wallTime should be < 5500L
          exitCode should be (124)
{'fraction_non_alphanumeric': 0.09473684210526316, 'fraction_numerical': 0.014241486068111455, 'mean_word_length': 2.774532710280374, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2959414', 'n_tokens_mistral': 974, 'n_tokens_neox': 910, 'n_words': 292}