@@ -21,16 +21,19 @@ test("inconsistently quoted arguments", () => {
2121 expect ( tokenizeArgs ( `command "arg"um"en"t` ) ) . toEqual ( [ "command" , "argument" ] ) ;
2222} ) ;
2323
24- test ( "forgive incomplete quotes" , ( ) => {
25- expect ( tokenizeArgs ( `command "arg` ) ) . toEqual ( [ "command" , "arg" ] ) ;
26- } ) ;
27-
28- test ( "detects incomplete quotes in strict mode" , ( ) => {
24+ test ( "detects incomplete quotes " , ( ) => {
2925 expect ( ( ) => {
30- tokenizeArgs ( `command "arg` , { strict : true } ) ;
26+ tokenizeArgs ( `command "arg1 "arg2" "arg3"` ) ;
3127 } ) . toThrow ( "Unexpected end of string. Closing quote is missing." ) ;
3228} ) ;
3329
30+ test ( "forgive incomplete quotes in loose mode" , ( ) => {
31+ expect ( tokenizeArgs ( `command "arg1 "arg2" "arg3"` , { loose : true } ) ) . toEqual ( [
32+ "command" ,
33+ "arg1 arg2 arg3" ,
34+ ] ) ;
35+ } ) ;
36+
3437test ( "escape quotes and spaces with other quotes" , ( ) => {
3538 expect ( tokenizeArgs ( `command 'quote "' "quote '"` ) ) . toEqual ( [
3639 "command" ,
@@ -47,7 +50,7 @@ test("escape quotes with backslashes", () => {
4750} ) ;
4851
4952test ( "escape spaces with backslashes" , ( ) => {
50- expect ( tokenizeArgs ( `command space\\ " ` ) ) . toEqual ( [ "command" , "space " ] ) ;
53+ expect ( tokenizeArgs ( `command space\\ ` ) ) . toEqual ( [ "command" , "space " ] ) ;
5154} ) ;
5255
5356test ( "ignore escaped newlines outside of quotes" , ( ) => {
0 commit comments