<commit_before>package ammonite.repl

import ammonite.repl.frontend._
import ammonite.repl.interp.Interpreter
import utest._


class Checker {
  var allOutput = ""
  val interp = new Interpreter(
    (_, _) => (),
    Ref[String](""),
    stdout = allOutput += _
  )

  def session(sess: String): Unit ={
//    println("SESSION")
//    println(sess)
    val margin = sess.lines.filter(_.trim != "").map(_.takeWhile(_ == ' ').length).min
    val steps = sess.replace("\n" + margin, "\n").split("\n\n")
    for(step <- steps){

      val (cmdLines, resultLines) = step.lines.map(_.drop(margin)).partition(_.startsWith("@"))
      val commandText = cmdLines.map(_.stripPrefix("@ ")).toVector

      val expected = resultLines.mkString("\n").trim
      for(line <- commandText.init) {
        allOutput += "\n@ " + line
        val (processed, printed) = run(line)
        if (!line.startsWith("//")) {
          failLoudly(assert(processed.isInstanceOf[Res.Buffer]))
        }<commit_msg>fix CHecker<commit_after>package ammonite.repl

import ammonite.repl.frontend._
import ammonite.repl.interp.Interpreter
import utest._


class Checker {
  var allOutput = ""
  val interp = new Interpreter(
    (_, _) => (),
    Ref[String](""),
    stdout = allOutput += _,
    initialHistory = Nil
  )

  def session(sess: String): Unit ={
//    println("SESSION")
//    println(sess)
    val margin = sess.lines.filter(_.trim != "").map(_.takeWhile(_ == ' ').length).min
    val steps = sess.replace("\n" + margin, "\n").split("\n\n")
    for(step <- steps){

      val (cmdLines, resultLines) = step.lines.map(_.drop(margin)).partition(_.startsWith("@"))
      val commandText = cmdLines.map(_.stripPrefix("@ ")).toVector

      val expected = resultLines.mkString("\n").trim
      for(line <- commandText.init) {
        allOutput += "\n@ " + line
        val (processed, printed) = run(line)
        if (!line.startsWith("//")) {
          failLoudly(assert(processed.isInstanceOf[Res.Buffer]))
        }
{'fraction_non_alphanumeric': 0.17753259779338015, 'fraction_numerical': 0.0, 'mean_word_length': 2.966202783300199, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2133047', 'n_tokens_mistral': 677, 'n_tokens_neox': 648, 'n_words': 123}