<commit_before>package io.mth.pirate

class TextSpec extends test.Spec { def is = s2"""

  Text Properties
  ===============

  all spaces                                      $spaces
  correct length                                  $length
  wrap no longer than width                       $width
  wrap no longer than width + ident               $ident
  never lose content                              $safe

"""

  import Text._

  def spaces = prop((i: Int) => (i >= 0 && i <= 1000) ==> {
    space(i).forall(_ == ' ') })

  def length = prop((i: Int) => (i >= 0 && i <= 1000) ==> {
    space(i).length == i })

  def width = prop((s: String) => s.length > 70 ==> {
    wrap(s, 80, 0).split('\n').forall(_.length <= 80) })

  def ident = prop((s: String) => s.length > 70 ==> {
    wrap(s, 80, 10).split('\n').forall(_.length <= 90) })

  def safe = prop((s: String) => s.length > 70 ==> {
    drains(s, wrap(s, 80, 0)) })

  def drains(orig: String, modded: String): Boolean = {
    var i = 0
    modded.foreach(c =>
      if (i < orig.length && (orig.charAt(i) == c || (orig.charAt(i) == ' ' && c == '\n')))
        i += 1
    )
    orig.length == i<commit_msg>Fix excessive prop generation in TextSpec with custom Gens<commit_after>package io.mth.pirate

import org.scalacheck._, Prop.forAll

class TextSpec extends test.Spec { def is = s2"""

  Text Properties
  ===============

  all spaces                                      $spaces
  correct length                                  $length
  wrap no longer than width                       $width
  wrap no longer than width + ident               $ident
  never lose content                              $safe

"""

  import Text._

  private val shortInt = Gen.choose(0, 1000)
  private val longLine = for {i <- Gen.choose(70, 1000); cs <- Gen.listOfN(i, Arbitrary.arbChar.arbitrary)} yield cs.mkString

  def spaces = forAll(shortInt)(i => space(i).forall(_ == ' '))

  def length = forAll(shortInt)(i => space(i).length == i )

  def width = forAll(longLine)(s => wrap(s, 80, 0).split('\n').forall(_.length <= 80))

  def ident = forAll(longLine)(s => wrap(s, 80, 10).split('\n').forall(_.length <= 90))

  def safe = forAll(longLine)(s => drains(s, wrap(s, 80, 0)))

  def drains(orig: String, modded: String): Boolean = {
    var i = 0
    modded.foreach(c =>
      if (i < orig.length && (orig.charAt(i) == c || (orig.charAt(i) == ' ' && c == '\n')))
        i += 1
    )
    orig.length == i
{'fraction_non_alphanumeric': 0.1737012987012987, 'fraction_numerical': 0.024756493506493508, 'mean_word_length': 2.031980319803198, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2263111', 'n_tokens_mistral': 860, 'n_tokens_neox': 772, 'n_words': 222}