<commit_before># Formatter Tests

The formatter is a pure function that formats some input text based on the
indentation rules of this project.  Test cases are created with the following
format, which will be parsed and executed by the test runner.

    ```in
    input code here
    ```

    ```out
    output code here
    ```

Certain cases are affected by cursor location, represented by the pipe `|`
character.


## No Closers

```in
(defn foo
  [arg
  ret
```

```out
(defn foo
  [arg]
  ret)
```

```in
(defn foo
  [arg
   ret
```

```out
(defn foo
  [arg
   ret])
```

```in
(defn foo
[arg
   ret
```

```out
(defn foo)
[arg
   ret]
```

```in
(defn foo
[arg
ret
```

```out
(defn foo)
[arg]
ret
```

## Bad Closers

```in
(def foo [a b]]
```

```out
(def foo [a b])
```

```in
(let [x {:foo 1 :bar 2]
  x)
```

```out
(let [x {:foo 1 :bar 2}]
  x)
```

## Strings

We allow temporary imbalances when inserting strings.

```in
(def foo "as
```

```out
(def foo "as
```

```in
(defn foo [a "])
```

```out
(defn foo [a "])
```

Multiline strings:

```in
(defn foo
  "This is docstring.
  Line 2 here."
  ret
```

```out
(defn foo
  "This is docstring.
  Line 2 here."
  ret)
```

Multiline strings do not affect indentation:

```in
(let [a "Hello
World"
      b 2
  ret
```

```out
(let [a "Hello
World"
      b 2]
  ret)
```

String with delimiters:

```in
(let [a "])"
      b 2
```

```out
(let [a "])"
      b 2])
```

Escaped quotes

```in
(def foo "\""
```

```out
(def foo "\"")
```

## Character syntax

```in
(defn foo [a b
  \[
  ret
```

```out
(defn foo [a b]
  \[
  ret)
```

```in<commit_msg>test that code with unbalance quotes is not processed (#15)<commit_after># Formatter Tests

The formatter is a pure function that formats some input text based on the
indentation rules of this project.  Test cases are created with the following
format, which will be parsed and executed by the test runner.

    ```in
    input code here
    ```

    ```out
    output code here
    ```

Certain cases are affected by cursor location, represented by the pipe `|`
character.


## No Closers

```in
(defn foo
  [arg
  ret
```

```out
(defn foo
  [arg]
  ret)
```

```in
(defn foo
  [arg
   ret
```

```out
(defn foo
  [arg
   ret])
```

```in
(defn foo
[arg
   ret
```

```out
(defn foo)
[arg
   ret]
```

```in
(defn foo
[arg
ret
```

```out
(defn foo)
[arg]
ret
```

## Bad Closers

```in
(def foo [a b]]
```

```out
(def foo [a b])
```

```in
(let [x {:foo 1 :bar 2]
  x)
```

```out
(let [x {:foo 1 :bar 2}]
  x)
```

## Strings

We allow temporary imbalances when inserting strings.

```in
(def foo "as
```

```out
(def foo "as
```

```in
(defn foo [a "])
```

```out
(defn foo [a "])
```

Multiline strings:

```in
(defn foo
  "This is docstring.
  Line 2 here."
  ret
```

```out
(defn foo
  "This is docstring.
  Line 2 here."
  ret)
```

Multiline strings do not affect indentation:

```in
(let [a "Hello
World"
      b 2
  ret
```

```out
(let [a "Hello
World"
      b 2]
  ret)
```

String with delimiters:

```in
(let [a "])"
      b 2
```

```out
(let [a "])"
      b 2])
```

Escaped quotes

```in
(def foo "\""
```

```out
(def foo "\"")
```

Strings that contain code that would be rewritten if it was ever considered
code.  See [Issue #15](https://github.com/shaunlebron/parinfer/issues/15).

```in
"|"]"
```

```out
""]"
```

```in
(def foo
  "|
  "(a b)
      c")
```

```out
(def foo
  "
  "(a b)
      c")
```

## Character syntax

```in
(defn foo [a b
  \[
  ret
```

```out
(defn foo [a b]
  \[
  ret)
```

```in
{'fraction_non_alphanumeric': 0.19458544839255498, 'fraction_numerical': 0.007332205301748449, 'mean_word_length': 2.773404255319149, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '7511518', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1427, 'n_words': 507}