<commit_before>package de.htwg.zeta.parser

import org.scalatest.FreeSpec
import org.scalatest.Matchers

class CommentParserTest extends FreeSpec with Matchers {

  "A comment parser should" - {
    "strip out any inline or multiline comment" in {
      val input = """
       |This is some
       |// hello world comment
       |stuff which // inline comment
       |is interrupted /* multiline
       |comment */ by many annoying
       |comments.""".stripMargin

      val expectedOutput =
        """This is some
         |stuff which is interrupted by many annoying
         |comments."""
        .stripMargin

      val parser = CommentParser()
      val result = parser.parseAll(parser.parsedText, input)
      result.get shouldBe expectedOutput
    }
    "fail on not closed multiline comments" in {
      val input ="""This is some
         |/* multiline
         |comment which isn't closed."""
        .stripMargin

      val parser = CommentParser()
      val result = parser.parseAll(parser.parsedText, input)
      result.successful shouldBe false
    }
  }

}<commit_msg>#183 append this parser in front of other parsers<commit_after>package de.htwg.zeta.parser

import de.htwg.zeta.parser.style.StyleParser
import org.scalatest.FreeSpec
import org.scalatest.Matchers

class CommentParserTest extends FreeSpec with Matchers {

  "A comment parser should" - {
    "strip out any inline or multiline comment" in {
      val input =
        """This is some
         |// hello world comment
         |stuff which // inline comment
         |is interrupted /* multiline
         |comment */ by many annoying
         |comments.""".stripMargin

      val expectedOutput =
        """This is some
         |stuff which is interrupted by many annoying
         |comments."""
          .stripMargin

      val parser = CommentParser()
      val result = parser.parseAll(parser.parsedText, input)
      result.get shouldBe expectedOutput
    }

    "append this parser in front of other parsers" - {
      "and success if all is correct" in {
        val input: String =
          """
           |style ParentStyle { description = "Parent style" }
           |// comment 1
           |style ChildStyle extends ParentStyle { // comment 2
           |  description = "Style which extends a single parent style"
           |  /* comment 3 */
           |}
          """.stripMargin

        val parser = CommentParser()
        val result = parser.parseAll(parser.parsedText, input).get
        StyleParser.parseStyles(result)
      }
    }

    "fail on not closed multiline comments" in {
      val input =
        """This is some
         |/* multiline
         |comment which isn't closed."""
          .stripMargin

      val parser = CommentParser()
      val result = parser.parseAll(parser.parsedText, input)
      result.successful shouldBe false
    }
  }

}
{'fraction_non_alphanumeric': 0.08571428571428572, 'fraction_numerical': 0.0020905923344947735, 'mean_word_length': 2.1308615049073065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4556209', 'n_tokens_mistral': 767, 'n_tokens_neox': 742, 'n_words': 252}