@@ -737,4 +737,69 @@ public function getTestsForOctalNumbers()
737
737
'negative octal number ' => [-28 , '-034 ' ],
738
738
];
739
739
}
740
+
741
+ /**
742
+ * @dataProvider unquotedExclamationMarkThrowsProvider
743
+ */
744
+ public function testUnquotedExclamationMarkThrows (string $ value )
745
+ {
746
+ $ this ->expectException (ParseException::class);
747
+ $ this ->expectExceptionMessageRegExp ('/^Using the unquoted scalar value "!" is not supported\. You must quote it at line 1 \(near "/ ' );
748
+
749
+ Inline::parse ($ value );
750
+ }
751
+
752
+ public function unquotedExclamationMarkThrowsProvider ()
753
+ {
754
+ return [
755
+ ['! ' ],
756
+ ['! ' ],
757
+ ['! ' ],
758
+ [' ! ' ],
759
+ ['[!] ' ],
760
+ ['[! ] ' ],
761
+ ['[! ] ' ],
762
+ ['[!, "foo"] ' ],
763
+ ['["foo", !, "ccc"] ' ],
764
+ ['{foo: !} ' ],
765
+ ['{foo: !} ' ],
766
+ ['{foo: !, bar: "ccc"} ' ],
767
+ ['{bar: "ccc", foo: ! } ' ],
768
+ ['!]]] ' ],
769
+ ['!} ' ],
770
+ ['!,}foo,] ' ],
771
+ ['! [!] ' ],
772
+ ];
773
+ }
774
+
775
+ /**
776
+ * @dataProvider quotedExclamationMarkProvider
777
+ */
778
+ public function testQuotedExclamationMark ($ expected , string $ value )
779
+ {
780
+ $ this ->assertSame ($ expected , Inline::parse ($ value ));
781
+ }
782
+
783
+ // This provider should stay consistent with unquotedExclamationMarkThrowsProvider
784
+ public function quotedExclamationMarkProvider ()
785
+ {
786
+ return [
787
+ ['! ', '"!" ' ],
788
+ ['! ' , '"! " ' ],
789
+ [' ! ' , '" !" ' ],
790
+ [' ! ' , '" ! " ' ],
791
+ [['! ' ], '["!"] ' ],
792
+ [['! ' ], '["! "] ' ],
793
+ [['! ' , 'foo ' ], '["!", "foo"] ' ],
794
+ [['foo ' , '! ' , 'ccc ' ], '["foo", "!", "ccc"] ' ],
795
+ [['foo ' => '! ' ], '{foo: "!"} ' ],
796
+ [['foo ' => ' ! ' ], '{foo: " !"} ' ],
797
+ [['foo ' => '! ' , 'bar ' => 'ccc ' ], '{foo: "!", bar: "ccc"} ' ],
798
+ [['bar ' => 'ccc ' , 'foo ' => '! ' ], '{bar: "ccc", foo: "! "} ' ],
799
+ ['!]]] ' , '"!]]]" ' ],
800
+ ['!} ' , '"!}" ' ],
801
+ ['!,}foo,] ' , '"!,}foo,]" ' ],
802
+ [['! ' ], '! ["!"] ' ],
803
+ ];
804
+ }
740
805
}
0 commit comments