<commit_before>package com.natpryce.snodge.demo

import com.natpryce.snodge.Mutagen
import com.natpryce.snodge.Random
import com.natpryce.snodge.json.defaultJsonMutagens
import com.natpryce.snodge.json.forStrings
import com.natpryce.snodge.mutant
import com.natpryce.snodge.text.replaceWithPossiblyMeaningfulText
import com.natpryce.snodge.text.splice
import com.natpryce.snodge.xml.defaultXmlMutagens
import com.natpryce.snodge.xml.forStrings
import org.w3c.dom.HTMLButtonElement
import org.w3c.dom.HTMLElement
import org.w3c.dom.HTMLSelectElement
import org.w3c.dom.HTMLTextAreaElement
import kotlin.browser.document
import kotlin.browser.window
import kotlin.dom.addClass
import kotlin.dom.removeClass

external class SyntaxError : Throwable

val random = Random()
val originalTextArea = document.getElementById("original") as HTMLTextAreaElement
val mutantTextArea = document.getElementById("mutant") as HTMLTextAreaElement
val inputTypeSelector = document.getElementById("type") as HTMLSelectElement

data class Format(
    val example: String,
    val mutagen: () -> Mutagen<String>
)

//language=JSON
val jsonExample = """{
    "demo": {
        "instructions": {
            "1": "press the button in the middle to mutate this JSON",
            "2": "a random mutation will appear in the right pane",
            "3": "press the button again to get another mutant",
            "4": "hold the button to repeatedly mutate this JSON",
            "5": "you can replace this with your own JSON",
            "6": "or mutate a different data format"
        },
        "uses": [
            "Robustness testing",
            "Security testing",
            "Negative testing",
            "Property-based testing"
        ]
    }
}"""

//language=XML
val xmlExample = """<demo>
  <instructions>
    <step n="1">press the button in the middle to mutate this XML</step>
    <step n="2">a random mutation will appear in the right pane</step>
    <step n="3">press the button again to get another mutant</step>
    <step n="4">hold the button to repeatedly mutate this XML</step>
    <step n="5">you can replace this with your own XML</step>
    <step n="6">or mutate a different data format</step>
  </instructions>
  <uses>
    <use>Robustness testing</use><commit_msg>Indent JSON 2 spaces instead of 4<commit_after>package com.natpryce.snodge.demo

import com.natpryce.snodge.Mutagen
import com.natpryce.snodge.Random
import com.natpryce.snodge.json.defaultJsonMutagens
import com.natpryce.snodge.json.forStrings
import com.natpryce.snodge.mutant
import com.natpryce.snodge.text.replaceWithPossiblyMeaningfulText
import com.natpryce.snodge.text.splice
import com.natpryce.snodge.xml.defaultXmlMutagens
import com.natpryce.snodge.xml.forStrings
import org.w3c.dom.HTMLButtonElement
import org.w3c.dom.HTMLElement
import org.w3c.dom.HTMLSelectElement
import org.w3c.dom.HTMLTextAreaElement
import kotlin.browser.document
import kotlin.browser.window
import kotlin.dom.addClass
import kotlin.dom.removeClass

external class SyntaxError : Throwable

val random = Random()
val originalTextArea = document.getElementById("original") as HTMLTextAreaElement
val mutantTextArea = document.getElementById("mutant") as HTMLTextAreaElement
val inputTypeSelector = document.getElementById("type") as HTMLSelectElement

data class Format(
    val example: String,
    val mutagen: () -> Mutagen<String>
)

//language=JSON
val jsonExample = """{
  "demo": {
    "instructions": {
      "1": "press the button in the middle to mutate this JSON",
      "2": "a random mutation will appear in the right pane",
      "3": "press the button again to get another mutant",
      "4": "hold the button to repeatedly mutate this JSON",
      "5": "you can replace this with your own JSON",
      "6": "or mutate a different data format"
    },
    "uses": [
       "Robustness testing",
       "Security testing",
       "Negative testing",
       "Property-based testing"
    ]
  }
}"""

//language=XML
val xmlExample = """<demo>
  <instructions>
    <step n="1">press the button in the middle to mutate this XML</step>
    <step n="2">a random mutation will appear in the right pane</step>
    <step n="3">press the button again to get another mutant</step>
    <step n="4">hold the button to repeatedly mutate this XML</step>
    <step n="5">you can replace this with your own XML</step>
    <step n="6">or mutate a different data format</step>
  </instructions>
  <uses>
    <use>Robustness testing</use>
{'fraction_non_alphanumeric': 0.1051693404634581, 'fraction_numerical': 0.007575757575757576, 'mean_word_length': 3.842502696871629, 'pattern_counts': {'":': 18, '<': 41, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6605347', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1374, 'n_words': 405}