nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: prettier/plugin-php
Pull request #2062 (2022-09-09 00:37:32)

Fix for inline closure

cseufert: fixes #1959 

Patch:
diff --git a/src/printer.js b/src/printer.js
index b5d8e46..01e6e1b 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1811,6 +1811,7 @@ function printNode(path, options, print) {
       return printFunction(path, options, print);
     case "arrowfunc":
       return concat([
+        node.parenthesizedExpression ? "(" : "",
         ...printAttrs(path, options, print, { inline: true }),
         node.isStatic ? "static " : "",
         "fn",
@@ -1820,6 +1821,7 @@ function printNode(path, options, print) {
           : "",
         " => ",
         path.call(print, "body"),
+        node.parenthesizedExpression ? ")" : "",
       ]);
     case "parameter": {
       let promoted = "";


Test patch:
diff --git a/tests/closure/__snapshots__/jsfmt.spec.js.snap b/tests/closure/__snapshots__/jsfmt.spec.js.snap
index f39aa6c..2917294 100644
--- a/tests/closure/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/closure/__snapshots__/jsfmt.spec.js.snap
@@ -143,6 +143,7 @@ $fn = function &() use (&$value) { return $value; };
 
 $var = function () {};
 
+$a = (fn() => 0)();
 =====================================output=====================================
 <?php
 
@@ -281,5 +282,7 @@ $fn = function &() use (&$value) {
 
 $var = function () {};
 
+$a = (fn() => 0)();
+
 ================================================================================
 `;
diff --git a/tests/closure/closure.php b/tests/closure/closure.php
index 28e02fe..57e58c8 100644
--- a/tests/closure/closure.php
+++ b/tests/closure/closure.php
@@ -134,3 +134,5 @@ $func = static function() {};
 $fn = function &() use (&$value) { return $value; };
 
 $var = function () {};
+
+$a = (fn() => 0)();
\ No newline at end of file
Repository: prettier/plugin-php
Pull request #2258 (2023-10-06 02:04:47)

fix(match): Indent match conditions
This updates `match($cond)` printing to ... er ... match `if ($cond)` (etc) when the condition can't fit onto a single line.

## Input
```php
match($really_really_really_really_really_really_really_really_long_variable_name) {
default => null
};
```

## Current behavior on `master`
```php
match(
$really_really_really_really_really_really_really_really_long_variable_name
) {
    default => null
};
```

## Behavior with this change
```php
match(
    $really_really_really_really_really_really_really_really_long_variable_name
) {
    default => null
};
```

I added a test to the snapsnots, and this change also corrects/changes one of the other `match` snapshots.


Patch:
diff --git a/src/printer.js b/src/printer.js
index d788ed8..79a010b 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -2847,7 +2847,7 @@ function printNode(path, options, print) {
       }, "arms");
       return group([
         "match (",
-        group([softline, indent(print("cond")), softline]),
+        group([indent([softline, print("cond")]), softline]),
         ") {",
         group(indent([...arms])),
         " ",


Test patch:
diff --git a/tests/match/__snapshots__/jsfmt.spec.js.snap b/tests/match/__snapshots__/jsfmt.spec.js.snap
index 7a17b33..2279ebf 100644
--- a/tests/match/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/match/__snapshots__/jsfmt.spec.js.snap
@@ -66,6 +66,10 @@ match ($a) {
 
 };
 
+match($really_really_really_really_really_really_really_really_long_variable_name) {
+default => null
+};
+
 =====================================output=====================================
 <?php
 
@@ -94,7 +98,7 @@ $a = match (true) {
 };
 
 $nest = match (
-match ($a) {
+    match ($a) {
         true => 1,
         false => 2
     }
@@ -148,6 +152,12 @@ match ($a) {
     "b" => 2
 };
 
+match (
+    $really_really_really_really_really_really_really_really_long_variable_name
+) {
+    default => null
+};
+
 ================================================================================
 `;
 
@@ -217,6 +227,10 @@ match ($a) {
 
 };
 
+match($really_really_really_really_really_really_really_really_long_variable_name) {
+default => null
+};
+
 =====================================output=====================================
 <?php
 
@@ -245,7 +259,7 @@ $a = match (true) {
 };
 
 $nest = match (
-match ($a) {
+    match ($a) {
         true => 1,
         false => 2,
     }
@@ -299,5 +313,11 @@ match ($a) {
     "b" => 2,
 };
 
+match (
+    $really_really_really_really_really_really_really_really_long_variable_name
+) {
+    default => null,
+};
+
 ================================================================================
 `;
diff --git a/tests/match/match.php b/tests/match/match.php
index d88c953..907a130 100644
--- a/tests/match/match.php
+++ b/tests/match/match.php
@@ -55,3 +55,7 @@ match ($a) {
     'b' => 2
 
 };
+
+match($really_really_really_really_really_really_really_really_long_variable_name) {
+default => null
+};
Repository: PMEAL/OpenPNM
Pull request #1715 (2020-10-23 13:50:39)

Workspace should returns the project, rather than nothing or the network
This fixes issue #1684 


Patch:
diff --git a/openpnm/utils/Workspace.py b/openpnm/utils/Workspace.py
index 609a0dee6..6942f6c46 100644
--- a/openpnm/utils/Workspace.py
+++ b/openpnm/utils/Workspace.py
@@ -188,7 +188,8 @@ class Workspace(dict):
 
         """
         from openpnm.io import PNM
-        PNM.load_project(filename=filename)
+        proj = PNM.load_project(filename=filename)
+        return proj
 
     def close_project(self, project):
         r"""


Test patch:
diff --git a/tests/unit/utils/WorkspaceTest.py b/tests/unit/utils/WorkspaceTest.py
index 364e61ca9..ff892e92c 100644
--- a/tests/unit/utils/WorkspaceTest.py
+++ b/tests/unit/utils/WorkspaceTest.py
@@ -1,6 +1,7 @@
 import os
 import pytest
 import openpnm as op
+from numpy.testing import assert_allclose
 
 
 class WorkspaceTest:
@@ -56,14 +57,26 @@ class WorkspaceTest:
         self.ws.close_project(proj)
         assert 'test_proj' not in self.ws.keys()
         assert proj.workspace == {}
-        self.ws.load_project(filename='test_proj.pnm')
+        proj = self.ws.load_project(filename='test_proj.pnm')
         assert 'test_proj' in self.ws.keys()
+        assert isinstance(proj, op.Project)
+        assert_allclose(proj.network.shape, [3, 3, 3])
         self.ws.clear()
         try:
             os.remove('test_proj.pnm')
         except PermissionError:
             print('Could not delete test_proj.pnm')
 
+    def test_load_project_with_name_conflict(self):
+        self.ws.clear()
+        proj = self.ws.new_project(name='test')
+        pn = op.network.Cubic(shape=[3, 3, 3], project=proj)
+        op.phases.Air(network=pn)
+        self.ws.save_project(proj, filename='test.pnm')
+        self.ws.load_project('test.pnm')
+        assert set(self.ws.keys()) == set(['test', 'proj_01'])
+        os.remove('test.pnm')
+
     # def test_save_and_load_project_from_pickled_list(self):
     #     proj = self.ws.new_project()
     #     pn = op.network.Cubic(shape=[3, 3, 3], project=proj)
@@ -87,16 +100,6 @@ class WorkspaceTest:
     #         self.ws.load_project('single_object.pnm')
     #     os.remove('single_object.pnm')
 
-    def test_load_project_with_name_conflict(self):
-        self.ws.clear()
-        proj = self.ws.new_project(name='test')
-        pn = op.network.Cubic(shape=[3, 3, 3], project=proj)
-        op.phases.Air(network=pn)
-        self.ws.save_project(proj, filename='test.pnm')
-        self.ws.load_project('test.pnm')
-        assert set(self.ws.keys()) == set(['test', 'proj_01'])
-        os.remove('test.pnm')
-
     # def test_save_and_load_workspace(self):
     #     self.ws.clear()
     #     proj1 = self.ws.new_project('test_proj_1')
@@ -121,5 +124,5 @@ if __name__ == '__main__':
     t.setup_class()
     for item in t.__dir__():
         if item.startswith('test'):
-            print('running test: '+item)
+            print(f"Running test {item}")
             t.__getattribute__(item)()