@@ -61,6 +61,11 @@ describe("Test precedence", function () {
6161 } ) ;
6262 it ( "test instanceof" , function ( ) {
6363 shouldBeSame ( "$a instanceof $b && $c" , "($a instanceof $b) && $c" ) ;
64+ shouldBeSame ( "$a + $b instanceof $c" , "$a + ($b instanceof $c)" ) ;
65+ shouldBeSame ( "$a * $b instanceof $c" , "$a * ($b instanceof $c)" ) ;
66+ shouldBeSame ( "-$a instanceof $b" , "(-$a) instanceof $b" ) ;
67+ shouldBeSame ( "+$a instanceof $b" , "(+$a) instanceof $b" ) ;
68+ shouldBeSame ( "~$a instanceof $b" , "(~$a) instanceof $b" ) ;
6469 } ) ;
6570 it ( "test <<" , function ( ) {
6671 shouldBeSame ( "1 + 3 << 5" , "(1 + 3) << 5" ) ;
@@ -119,11 +124,15 @@ describe("Test precedence", function () {
119124 shouldBeSame ( "5 AND 4 + 3" , "5 AND (4 + 3)" ) ;
120125 } ) ;
121126 it ( "test unary : !" , function ( ) {
122- shouldBeSame ( "!$a instanceof $b" , "(!$a) instanceof $b" ) ;
123- shouldBeSame ( "!$a + $b instanceof $c" , "(( !$a) + $b) instanceof $c" ) ;
127+ shouldBeSame ( "!$a instanceof $b" , "!($a instanceof $b) " ) ;
128+ shouldBeSame ( "!$a + $b instanceof $c" , "(!$a) + ($b instanceof $c) " ) ;
124129 shouldBeSame ( "6 + !4 + 5" , "6 + (!4) + 5" ) ;
125130 shouldBeSame ( "if($a && !$b) {}" , "if($a && (!$b)) {}" ) ;
126131 } ) ;
132+ it ( "test unary : - (prettier/plugin-php#2501)" , function ( ) {
133+ shouldBeSame ( "5 * -1 + 2" , "(5 * (-1)) + 2" ) ;
134+ shouldBeSame ( '5 * -1 . "foo"' , '(5 * (-1)) . "foo"' ) ;
135+ } ) ;
127136 it ( "test concat" , function ( ) {
128137 shouldBeSame ( '"a"."b"."c"."d"' , '((("a"."b")."c")."d")' ) ;
129138 } ) ;
0 commit comments