PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: tafia/quick-xml (rust)

Issue:
Writer::new_with_indent() inserts white space into <![CDATA[ content tags
Problem: the pretty print functionality should not insert spaces new lines before and after `<![CDATA[` tags.

Example input:
```xml
<?xml version="1.0" encoding="UTF-8"?><jobs><job><jobid><![CDATA[00d46e4494e1]]></jobid></job></jobs>
```
Output with `Writer::new_with_indent(out_file, b" "[0], 2);`
```xml
<?xml version="1.0" encoding="UTF-8"?>
<jobs>
  <job>
    <jobid>
      <![CDATA[00d46e4494e1]]>
    </jobid>
  </job>
</jobs>
```
This has now changed the content of the jobid tag, which is bad.

Correct with `xmllint --format`:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<jobs>
  <job>
    <jobid><![CDATA[00d46e4494e1]]></jobid>
  </job>
</jobs>
```
This has correctly preserved the content of the jobid tag.

Pull request:
inline CData events when pretty printing
Close #197

Patch:
diff --git a/src/writer.rs b/src/writer.rs
index 879509d..873607a 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -113,7 +113,12 @@ impl<W: Write> Writer<W> {
                 self.write(&e.escaped())
             }
             Event::Comment(ref e) => self.write_wrapped(b"<!--", e, b"-->"),
-            Event::CData(ref e) => self.write_wrapped(b"<![CDATA[", e, b"]]>"),
+            Event::CData(ref e) => {
+                next_should_line_break = false;
+                self.write(b"<![CDATA[")?;
+                self.write(e)?;
+                self.write(b"]]>")
+            }
             Event::Decl(ref e) => self.write_wrapped(b"<?", e, b"?>"),
             Event::PI(ref e) => self.write_wrapped(b"<?", e, b"?>"),
             Event::DocType(ref e) => self.write_wrapped(b"<!DOCTYPE", e, b">"),


Test patch:
diff --git a/tests/documents/test_writer_indent_cdata.xml b/tests/documents/test_writer_indent_cdata.xml
new file mode 100644
index 0000000..6f5539e
--- /dev/null
+++ b/tests/documents/test_writer_indent_cdata.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<jobs>
+    <job>
+        <jobid><![CDATA[00d46e4494e1]]></jobid>
+    </job>
+</jobs>
\ No newline at end of file
diff --git a/tests/unit_tests.rs b/tests/unit_tests.rs
index 71ee9d4..8893914 100644
--- a/tests/unit_tests.rs
+++ b/tests/unit_tests.rs
@@ -258,6 +258,25 @@ fn test_writer_indent() {
     assert_eq!(result, txt.as_bytes());
 }
 
+#[test]
+fn test_writer_indent_cdata() {
+    let txt = include_str!("../tests/documents/test_writer_indent_cdata.xml");
+    let mut reader = Reader::from_str(txt);
+    reader.trim_text(true);
+    let mut writer = Writer::new_with_indent(Cursor::new(Vec::new()), b' ', 4);
+    let mut buf = Vec::new();
+    loop {
+        match reader.read_event(&mut buf) {
+            Ok(Eof) => break,
+            Ok(e) => assert!(writer.write_event(e).is_ok()),
+            Err(e) => panic!(e),
+        }
+    }
+
+    let result = writer.into_inner().into_inner();
+    assert_eq!(result, txt.as_bytes());
+}
+
 #[test]
 fn test_write_empty_element_attrs() {
     let str_from = r#"<source attr="val"/>"#;
Repository: jlongster/prettier (js)

Issue:
Missing parentheses around class expressions used with operators
Input:

```js
(class extends b {}) + 1
```

Output:

```js
class extends b {} + 1;
```

... which is invalid JavaScript.

Expected:

```js
(class extends b {}) + 1;
```

Or:

```js
(class extends b {} + 1);
```

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22(class%20extends%20b%20%7B%7D)%20%2B%201%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D

---

Input:

```js
(class a extends b {}) + 1
```

Output:

```js
class a extends b {} + 1;
```

... which means:

```js
class a extends b {}
+1;
```

Expected:

```js
(class a extends b {}) + 1;
```

Or:

```js
(class a extends b {} + 1);
```

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22(class%20a%20extends%20b%20%7B%7D)%20%2B%201%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22doc%22%3Afalse%7D%7D

---

Found using the fuzzer.

Pull request:
Fix class inside of binary expression missing parenthesis
Fixes #395

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index 74e994d07..990d7ed0c 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -405,6 +405,7 @@ FPp.needsParens = function(assumeExpressionContext) {
 
     case "ClassExpression":
       switch (parent.type) {
+        case "BinaryExpression":
         case "ExportDefaultDeclaration":
         case "ExpressionStatement":
           return true;


Test patch:
diff --git a/tests/classes/__snapshots__/jsfmt.spec.js.snap b/tests/classes/__snapshots__/jsfmt.spec.js.snap
index 4644dbbd2..d2de13bf1 100644
--- a/tests/classes/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/classes/__snapshots__/jsfmt.spec.js.snap
@@ -74,6 +74,19 @@ new E().x;
 "
 `;
 
+exports[`test binary.js 1`] = `
+"(class {}) + 1;
+(class a {}) + 1;
+(class extends b {}) + 1;
+(class a extends b {}) + 1;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+(class {}) + 1;
+(class a {}) + 1;
+(class extends b {}) + 1;
+(class a extends b {}) + 1;
+"
+`;
+
 exports[`test class_shapes.js 1`] = `
 "/* @flow */
 
diff --git a/tests/classes/binary.js b/tests/classes/binary.js
new file mode 100644
index 000000000..f60f9c8f7
--- /dev/null
+++ b/tests/classes/binary.js
@@ -0,0 +1,4 @@
+(class {}) + 1;
+(class a {}) + 1;
+(class extends b {}) + 1;
+(class a extends b {}) + 1;