<commit_before>/* global describe, it */

// -----------------------------------------------------------------------------
// Compile tests from Markdown to JSON

require('./cases/build.js').buildAll()
const indentCases = require('./cases/indent-mode.json')
const parenCases = require('./cases/paren-mode.json')
const smartCases = require('./cases/smart-mode.json')

// NOTE:
// Add some additional tests that do not participate in the "test cases in markdown" system
// This is a hack in order to ensure that adding configurable comment characters
// did not break anything.
// Long-term: I want to refactor the "test cases in markdown" approach
// -- <NAME>, 06 Sep 2020

const indentModeCommentTest9000 = {
  text: '(def foo \\,\n(def bar \\ # <-- space',
  options: {
    commentChars: ['#']
  },
  result: {
    text: '(def foo \\,)\n(def bar \\ )# <-- space',
    success: true
  },
  source: {
    lineNo: 9000,
    in: [
      '(def foo \\,\n(def bar \\ # <-- space'
    ],
    out: '(def foo \\,)\n(def bar \\ )# <-- space'
  }
}

const indentModeCommentTest9100 = {
  text: '(def foo [a b]\n  # "my multiline\n  # docstring."\nret)',
  options: { commentChars: ['#'] },
  result: {
    text: '(def foo [a b])\n  # "my multiline\n  # docstring."\nret',
    success: true
  },
  source: {
    lineNo: 9100,
    in: [
      '(def foo [a b]\n  # "my multiline\n  # docstring."\nret)'
    ],
    out: '(def foo [a b])\n  # "my multiline\n  # docstring."\nret'
  }
}

indentCases.push(indentModeCommentTest9000)
indentCases.push(indentModeCommentTest9100)

// -----------------------------------------------------------------------------
// STRUCTURE TEST
// Diff the relevant result properties.

const parinfer = require('../parinfer.js')
const assert = require('assert')

function assertStructure (actual, expected, description) {
  assert.strictEqual(actual.text, expected.text)
  assert.strictEqual(actual.success, expected.success)
  assert.strictEqual(actual.cursorX, expected.cursorX)<commit_msg>add more test cases for commentChars option<commit_after>/* global describe, it */

// -----------------------------------------------------------------------------
// Compile tests from Markdown to JSON

require('./cases/build.js').buildAll()
const indentCases = require('./cases/indent-mode.json')
const parenCases = require('./cases/paren-mode.json')
const smartCases = require('./cases/smart-mode.json')

// NOTE:
// Add some additional tests that do not participate in the "test cases in markdown" system
// This is a hack in order to ensure that adding configurable comment characters
// did not break anything.
// Long-term: I want to refactor the "test cases in markdown" approach
// -- <NAME>, 06 Sep 2020

const indentModeCommentTest9000 = {
  text: '(def foo \\,\n(def bar \\ # <-- space',
  options: {
    commentChars: ['#']
  },
  result: {
    text: '(def foo \\,)\n(def bar \\ )# <-- space',
    success: true
  },
  source: {
    lineNo: 9000,
    in: [
      '(def foo \\,\n(def bar \\ # <-- space'
    ],
    out: '(def foo \\,)\n(def bar \\ )# <-- space'
  }
}

const indentModeCommentTest9050 = {
  text: '(def foo q)',
  options: { commentChars: 'q' },
  result: {
    text: '(def foo) q)',
    success: true
  },
  source: {
    lineNo: 9050,
    in: [
      '(def foo q)'
    ],
    out: '(def foo) q)'
  }
}

const indentModeCommentTest9100 = {
  text: '(def foo [a b]\n  # "my multiline\n  # docstring."\nret)',
  options: { commentChars: ['#'] },
  result: {
    text: '(def foo [a b])\n  # "my multiline\n  # docstring."\nret',
    success: true
  },
  source: {
    lineNo: 9100,
    in: [
      '(def foo [a b]\n  # "my multiline\n  # docstring."\nret)'
    ],
    out: '(def foo [a b])\n  # "my multiline\n  # docstring."\nret'
  }
}

const indentModeCommentTest9150 = {
  text: '(let [a 1\n      b 2\n      c {:foo 1\n         ## :bar 2}]\n  ret)',
  options: { commentChars: '#' },
  result: {
    text: '(let [a 1\n      b 2\n      c {:foo 1}]\n         ## :bar 2}]\n  ret)',
    success: true
  },
  source: {
    lineNo: 9150,
    in: [
      '(let [a 1\n      b 2\n      c {:foo 1\n         ## :bar 2}]\n  ret)'
    ],
    out: '(let [a 1\n      b 2\n      c {:foo 1}]\n         ## :bar 2}]\n  ret)'
  }
}

indentCases.push(indentModeCommentTest9000)
indentCases.push(indentModeCommentTest9050)
indentCases.push(indentModeCommentTest9100)
indentCases.push(indentModeCommentTest9150)

// -----------------------------------------------------------------------------
// STRUCTURE TEST
// Diff the relevant result properties.

const parinfer = require('../parinfer.js')
const assert = require('assert')

function assertStructure (actual, expected, description) {
  assert.strictEqual(actual.text, expected.text)
  assert.strictEqual(actual.success, expected.success)
  assert.strictEqual(actual.cursorX, expected.cursorX)
{'fraction_non_alphanumeric': 0.22110242698477992, 'fraction_numerical': 0.020567667626491155, 'mean_word_length': 2.2014483212639893, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4459276', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1587, 'n_words': 432}