cmd: Make 'if errorlevel' only recognize integer values.
[wine/multimedia.git] / programs / cmd / tests / test_builtins.cmd.exp
blob7a0eec3681d964d5e6670d21db7b3cd79b530e3b
2 @pwd@>echo Tests for cmd's builtin commands@space@
3 Tests for cmd's builtin commands
5 @pwd@>echo ------------ Testing 'echo' [ON] --------------@space@
6 ------------ Testing 'echo' [ON] --------------
8 @pwd@>echo word@space@
9 word
11 @pwd@>echo 'singlequotedword'@space@
12 'singlequotedword'
14 @pwd@>echo "doublequotedword"@space@
15 "doublequotedword"
16 at-echoed-word
18 @pwd@>echo "/?"@space@
19 "/?"
21 @pwd@>echo.
24 @pwd@>echo .@space@
27 @pwd@>echo.word
28 word
30 @pwd@>echo .word@space@
31 .word
33 @pwd@>echo:
36 @pwd@>echo :@space@
39 @pwd@>echo:word
40 word
42 @pwd@>echo :word@space@
43 :word
45 @pwd@>echo off now@space@
46 off now
48 @pwd@>echo word@space@@space@
49 word@space@
51 @pwd@>echo word@space@@space@@space@
52 word@space@@space@
54 @todo_wine@@pwd@>echo word@space@
55 word
57 @pwd@>echo@tab@word@space@
58 word
60 @pwd@>echo@tab@word@space@@tab@@space@
61 word@space@@tab@
63 @pwd@>echo@tab@word@tab@@space@@space@
64 word@tab@@space@
66 @todo_wine@@pwd@>echo word@space@
67 word
69 @pwd@>echo@space@@tab@word@space@
70 @tab@word
72 @pwd@>echo@space@@space@@tab@word@space@
73 @space@@tab@word
75 @pwd@>echo@tab@@tab@word@space@
76 @tab@word
77 ------------ Testing 'echo' [OFF] --------------
78 word
79 'singlequotedword'
80 "doublequotedword"
81 at-echoed-word
82 "/?"
85 word
86 .word
89 word
90 :word
91 on again
92 word@space@
93 word@space@@space@
94 word
95 word
96 word@space@@tab@
97 word@tab@@space@
98 word
99 @tab@word
100 @space@@tab@word
101 @tab@word
102 ------------ Testing mixed echo modes --------------
103 @echo on
104 if 1==1 echo foo
105 if 1==1 @echo bar
106 @echo off
107 if 1==1 echo foo2
108 if 1==1 @echo bar2
110 @todo_wine@@pwd@>if 1 == 1 echo foo@space@
113 @todo_wine@@pwd@>if 1 == 1@space@
115 foo2
116 bar2
117 ------------ Testing rem --------------
119 @pwd@>rem Hello@space@
121 @pwd@>rem Hello@space@
123 @pwd@>rem Hello || foo@space@
125 @pwd@>rem echo lol@space@
127 @pwd@>rem echo foo & echo bar@space@
129 @pwd@>rem @tab@ Hello@space@
131 @pwd@>rem@tab@ Hello@space@
133 @pwd@>rem@tab@echo foo & echo bar@space@
134 ------------ Testing redirection operators --------------
135 ...stdout redirection
137 foo@space@
138 foo@tab@
139 foo@space@
140 foo@tab@
141 foo7@space@@or_broken@foo@tab@
142 foo9@space@@or_broken@foo@tab@
143 foo1
144 foo11
145 foo12
146 ...stdout appending
148 foo@space@
149 foob@space@
150 foob@space@
151 fooc@space@
152 foob@space@
153 fooc@space@
154 food1
155 foob@space@
156 fooc@space@
157 food1
158 food2
159 food21
160 @todo_wine@foo7@space@@space@@or_broken@not supported@space@
161 @todo_wine@foo@or_broken@not supported
162 ...redirections within IF statements
163 @todo_wine@foo1
164 @todo_wine@foo2
165 @todo_wine@foo3
166 file does not exist, ok
167 foo4
168 baz5
169 baz6@space@
170 baz7
171 baz8
173 foo@space@
179 @todo_wine@------------ Testing ^ escape character --------------
180 @todo_wine@hello, world
181 @todo_wine@hello, world
182 @todo_wine@hell^o, world
183 @todo_wine@hell^o, world
185 @todo_wine@baz
186 @todo_wine@foo | echo bar
187 @todo_wine@foo & echo bar
188 @todo_wine@bak &
189 @todo_wine@baz@space@
190 @todo_wine@0@or_broken@1
191 @todo_wine@foo > foo
192 @todo_wine@<
193 @todo_wine@ffoof
194 @todo_wine@FOO=bar | baz
195 @todo_wine@0
196 @todo_wine@FOO=bar ^| baz
197 @todo_wine@bar | baz
198 @todo_wine@0
199 ------------ Testing 'set' --------------
201 @todo_wine@0
202 FOOBAR not defined
203 @todo_wine@ baz
204 FOOBAR = baz
205 @todo_wine@0
206 @todo_wine@ baz2
207 @todo_wine@0
209 @todo_wine@FOOBAR= bar
210 @todo_wine@FOOBAR = baz2
211 FOOBAR = baz2
212 FOOBAR not defined
215 foobar
216 FOO not defined
217 BAZ=bazbaz
218 bazbaz
219 set "FOO=bar" should not include the quotes in the variable value
223 'foo@space@'
224 'foo@tab@'
225 ------------ Testing variable expansion --------------
226 ~dp0 should be directory containing batch file
227 @pwd@\
228 @pwd@\
229 CD value @pwd@@or_broken@CD value@space@
236 ERRORLEVEL
239 0ERRORLEVEL
245 ------------ Testing variable substrings --------------
249 @todo_wine@'ty'@or_broken@''
250 't'@or_broken@''
251 ert@or_broken@qwerty
252 e@or_broken@qwerty
253 ''@or_broken@'qwerty'
254 r@or_broken@qwerty
255 ------------ Testing variable substitution --------------
256 ...in FOR variables
257 @todo_wine@"A B"
259 'A B'@or_broken@''
260 'C'@or_broken@''
261 @pwd@\C D@or_broken@%~ff
262 @pwd@\E@or_broken@%~ff
263 @drive@
264 @drive@
265 @path@@or_broken@%~pd
266 @path@@or_broken@%~pd
269 '.OOL'
270 '.TABC'
272 @todo_wine@'@drive@@shortpath@R S'@or_broken@''
273 @todo_wine@'@drive@@shortpath@T'@or_broken@''
274 @todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
275 @todo_wine@''@or_broken@'%~ai'
276 @todo_wine@''@or_broken@'%~ai'
277 @todo_wine@'--a------'@or_broken@'%~ai'
278 @todo_wine@''@or_broken@'%~ti'
279 @todo_wine@''@or_broken@'%~ti'
280 @todo_wine@''@or_broken@'%~zi'
281 @todo_wine@''@or_broken@'%~zi'
282 @drive@@path@
283 @drive@@path@
284 @drive@
285 @drive@
286 @drive@
287 @drive@
289 '.eh'
290 ...in parameters
291 @todo_wine@"A B"
293 @todo_wine@'A B'@or_broken@''
294 'C'@or_broken@''
295 @todo_wine@@pwd@\C D
296 @pwd@\E
297 @drive@
298 @drive@
299 @path@
300 @path@
301 @todo_wine@L M
303 @todo_wine@'.OOL'
304 '.TABC'
306 @todo_wine@'@drive@@shortpath@R S'@or_broken@''
307 @todo_wine@'@drive@@shortpath@T'@or_broken@''
308 @todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
309 @drive@@path@
310 @drive@@path@
311 @drive@
312 @drive@
313 @drive@
314 @drive@
316 '.eh'@or_broken@''
317 ------------ Testing variable delayed expansion --------------
318 ...default mode (load-time expansion)
320 !FOO!
323 ...runtime (delayed) expansion mode
325 @todo_wine@foo@or_broken@!FOO!
327 @todo_wine@bar@or_broken@foo
329 0@or_broken@1
331 !FOO!
332 ...using /V cmd flag
334 @todo_wine@foo@or_broken@!FOO!
336 !FOO!
337 ------------ Testing conditional execution --------------
338 @todo_wine@...unconditional &
339 foo1
340 bar2@space@
341 foo2
342 foobar deleted
343 @todo_wine@...on success conditional &&
344 @todo_wine@foo3 not created
345 bar4@space@
346 foo4
347 @todo_wine@...on failure conditional ||
348 @todo_wine@foo5
349 @todo_wine@foo6@space@
350 ------------ Testing cd ------------
351 singleFile
352 Current dir: @pwd@\foobar@or_broken@Current dir:@space@
353 @pwd@\foobar
354 @pwd@
355 @pwd@\foobar
356 @pwd@
357 @pwd@\foobar
358 @pwd@
359 @pwd@
360 @pwd@
361 @pwd@\foobar\bar bak
362 @pwd@\foobar\bar bak
363 @pwd@\foobar\bar bak
364 @pwd@
365 @pwd@\foobar
366 ------------ Testing type ------------
368 @pwd@>type foobaz@space@
371 @pwd@>echo ***@space@
375 ------------ Testing NUL ------------
380 @todo_wine@foo created
381 ------------ Testing if/else --------------
382 if/else should work with blocks
383 if seems to work
384 else seems to work
385 if seems not to detect /c as parameter
386 Testing case sensitivity with and without /i option
387 if seems to default to case sensitivity
388 if /i seems to work
389 if /I seems to work
390 Testing string comparisons
391 equal
392 non equal
393 non equal
394 equal
395 Testing tabs handling
396 doom
397 doom
398 doom
400 quake
401 quake
402 quake
403 -----------Testing for -----------
404 ...plain FOR
432 `echo
435 'echo
438 @todo_wine@"echo A B"
439 @todo_wine@"A B"
441 ...imbricated FORs
442 @todo_wine@X Y
443 @todo_wine@X Y
444 @todo_wine@A C
445 @todo_wine@A D
446 @todo_wine@B C
447 @todo_wine@B D
448 @todo_wine@A C
449 @todo_wine@A D
450 @todo_wine@B C
451 @todo_wine@B D
452 ...basic wildcards
453 bazbaz
454 ...for /d
458 ...for /L
469 @todo_wine@ErrorLevel 0
470 @todo_wine@ErrorLevel 0
471 ...for /a
472 ......individual operations
474 @todo_wine@3
475 @todo_wine@-1
476 @todo_wine@3
477 @todo_wine@6
478 @todo_wine@10
479 @todo_wine@4
480 @todo_wine@4
481 @todo_wine@-4
483 @todo_wine@2
484 @todo_wine@2
485 @todo_wine@-2
486 @todo_wine@1
487 @todo_wine@4
488 0@or_broken@1073741824
489 0@or_broken@-1073741824
490 @todo_wine@-4
491 @todo_wine@9
492 @todo_wine@2
494 @todo_wine@-1
495 @todo_wine@-3
497 @todo_wine@1
498 @todo_wine@1
499 @todo_wine@4
500 @todo_wine@1
501 @todo_wine@5
502 @todo_wine@5
503 @todo_wine@7
504 @todo_wine@5
505 @todo_wine@5
506 @todo_wine@5
507 @todo_wine@4
508 @todo_wine@6
509 @todo_wine@1
510 ......precedence and grouping
511 @todo_wine@4
512 @todo_wine@10
513 @todo_wine@18@or_broken@10
514 @todo_wine@2@or_broken@0
515 @todo_wine@2@or_broken@0
516 0@or_broken@4
517 @todo_wine@4
518 @todo_wine@3@or_broken@4
519 ......octal and hexadecimal
520 @todo_wine@3@or_broken@4
521 @todo_wine@18
522 @todo_wine@18
523 @todo_wine@15
524 ......variables
525 @todo_wine@3
526 @todo_wine@3@or_broken@foo not defined
527 @todo_wine@3@or_broken@0
528 @todo_wine@3@or_broken@0
529 @todo_wine@3@or_broken@0
530 @todo_wine@9@or_broken@0
532 @todo_wine@4@or_broken@0
533 @todo_wine@-7@or_broken@0
534 @todo_wine@-1@or_broken@0
535 @todo_wine@5@or_broken@0
536 @todo_wine@4@or_broken@0
537 @todo_wine@1@or_broken@0
539 @todo_wine@5@or_broken@0
541 ...for /F
542 ......string argument
548 ......fileset argument
549 .........basic blank handling
556 .........multi-line with empty lines
560 .........multiple files
571 ......eol option
572 @todo_wine@ad
573 @todo_wine@z@y
574 @todo_wine@a|d
575 @todo_wine@no output
576 @todo_wine@no output
577 ......delims option
578 @todo_wine@a
579 @todo_wine@a@space@
580 @todo_wine@a d
581 @todo_wine@a
582 @todo_wine@C r
583 @todo_wine@foo bar baz
584 @todo_wine@c:\
585 ......skip option
586 @todo_wine@c
587 @todo_wine@no output
588 @todo_wine@no output
589 -----------Testing del /a-----------
590 not-r.test not found after delete, good
591 r.test found before delete, good
592 r.test not found after delete, good
593 ------------ Testing del /q --------------
594 del /q * succeeded on file1
595 del /q * succeeded on file2.dat
596 ------------ Testing del /s --------------
597 ------------ Testing rename ------------
598 ... ren and rename are synonymous ...
599 foo renamed to bar
600 bar renamed to foo
601 ... name collision ...
604 ... rename read-only files ...
605 read-only file renamed
606 ... rename directories ...
607 dir renamed
608 read-only dir renamed
609 ... rename in other directory ...
610 @todo_wine@rename impossible in other directory
611 @todo_wine@original file still present
612 ------------ Testing move ------------
613 ... file move ...
614 file move succeeded
615 @todo_wine@file move with overwrite succeeded@or_broken@file overwrite impossible!
616 @todo_wine@bar@or_broken@baz
617 read-only files are moveable
618 file moved in subdirectory
619 @todo_wine@moving a file to itself is a no-op@or_broken@moving a file to itself should be a no-op!
620 @todo_wine@ErrorLevel: 0@or_broken@ErrorLevel: 1
621 ... directory move ...
622 simple directory move succeeded
623 moving a directory to itself gives error; errlevel 1
624 ...... dir in dir move ......
626 bar2
627 foo2
628 ------------ Testing mkdir ------------
629 ... md and mkdir are synonymous ...
632 ... creating an already existing directory/file must fail ...
635 ... multilevel path creation ...
644 ... trailing backslashes ...
646 dir created
648 ... invalid chars ...
649 mkdir ? gives errorlevel 1
650 mkdir ?\foo gives errorlevel 1
651 mkdir foo\? gives errorlevel 1
652 ok, foo created
653 mkdir foo\bar\? gives errorlevel 1
654 ok, foo\bar created
655 ... multiple directories at once ...
656 foo created
657 bar created
658 foobar created
659 bar\baz created
660 mkdir foo\* errorlevel 1
661 ok, foo created
662 ----------- Testing rmdir -----------
664 dir removed
666 dir removed
669 file not removed
671 non-empty dir not removed
673 non-empty dir not removed
674 recursive rmdir succeeded
675 recursive rmdir succeeded
676 foo removed
677 bar removed
678 foobar removed
679 bar\baz removed
680 ----------- Testing pushd/popd -----------
681 @pwd@
682 ...popd is no-op when dir stack is empty
683 @pwd@
684 ...pushing non-existing dir
685 @pwd@
686 ...basic behaviour
687 @pwd@\foobar
688 @pwd@
689 @pwd@\foobar\baz
690 @pwd@\foobar
691 @pwd@\foobar
692 @pwd@
693 @pwd@\foobar
694 @pwd@
695 ------------ Testing attrib --------------
696 @todo_wine@A @pwd@\foobar\foo@or_broken@A @pwd@\foobar\foo@or_broken@A I @pwd@\foobar\foo
697 ... read-only attribute
698 @todo_wine@A R @pwd@\foobar\foo@or_broken@A R @pwd@\foobar\foo@or_broken@A R I @pwd@\foobar\foo
700 foo original contents
701 Read-only file not deleted
702 Read-only file forcibly deleted
703 ... recursive behaviour
704 @todo_wine@A @pwd@\foobar\baz\level2@or_broken@A @pwd@\foobar\baz\level2@or_broken@A I @pwd@\foobar\baz\level2
705 @todo_wine@A R @pwd@\foobar\level1@or_broken@A R @pwd@\foobar\level1@or_broken@A R I @pwd@\foobar\level1
706 @todo_wine@A R @pwd@\foobar\baz\level2@or_broken@A R @pwd@\foobar\baz\level2@or_broken@A R I @pwd@\foobar\baz\level2
707 @todo_wine@A @pwd@\foobar\bar@or_broken@A @pwd@\foobar\bar@or_broken@A I @pwd@\foobar\bar
708 ... folders processing
709 @todo_wine@ @pwd@\foobar@or_broken@ @pwd@\foobar@or_broken@ I @pwd@\foobar
710 @todo_wine@ R @pwd@\foobar\baz@or_broken@ R @pwd@\foobar\baz@or_broken@ @pwd@\foobar\baz@or_broken@ R I @pwd@\foobar\baz
711 @todo_wine@A @pwd@\foobar\baz\toto@or_broken@A @pwd@\foobar\baz\toto@or_broken@A I @pwd@\foobar\baz\toto
712 toto
713 lulu
714 file created in read-only dir
715 ------------ Testing assoc --------------
716 ...setting association
718 .foo=bar
719 .foo=bar
721 .foo=bar
722 ...resetting association
726 ------------ Testing ftype --------------
727 ...setting association
729 footype=foo_opencmd
730 .foo=footype
731 footype=foo_opencmd
733 footype=foo_opencmd
734 ...resetting association
735 @todo_wine@original value@or_broken@buggyXP@or_broken@!FOO!
736 ------------ Testing CALL ------------
737 ... external script ...
738 foo@space@
739 foo 8
740 foo@space@@space@
741 foo bar@space@
742 @todo_wine@foo ""@space@
743 @todo_wine@"" bar@space@
744 foo ''@space@
745 '' bar@space@
746 ... internal routines ...
747 bar :testRoutine
748 foo@space@
749 foo bar
750 @todo_wine@foo ""
751 @todo_wine@"" bar
752 foo ''
753 '' bar
754 ... with builtins ...
755 @todo_wine@0
756 @todo_wine@foo created
757 @todo_wine@Should expand foobaz
758 @todo_wine@batfile
759 @todo_wine@robinfile
760 @todo_wine@1
761 @todo_wine@1
762 non-builtin dir
763 ------------ Testing SHIFT ------------
764 'p1' 'p2' 'p3' 'p4' 'p5'
765 'p2' 'p3' 'p4' 'p5' ''
766 'p3' 'p4' 'p5' '' ''
767 'p3' 'p5' '' '' ''
768 'p3' 'p5' '' '' ''
769 'p5' '' '' '' ''
770 ------------ Testing cmd invocation ------------
771 ... a batch file can delete itself ...
772 file correctly deleted
773 ... a batch file can alter itself ...
774 @todo_wine@bar
775 ------------ Testing setlocal/endlocal ------------
776 ...enable/disable extensions
777 @todo_wine@ErrLev:@space@
778 ErrLev: 0
779 ErrLev: 0
780 @todo_wine@ErrLev:@space@@or_broken@ErrLev: 0
781 ErrLev: 0
782 ...setlocal with corresponding endlocal
783 globalval
784 localval
785 globalval
786 globalval
787 ...setlocal with no corresponding endlocal
788 globalval
789 localval
790 @todo_wine@globalval
791 -----------Testing Errorlevel-----------
792 9009
794 errorlevel just right, good
795 errorlevel with leading zero just right, good
796 errorlevel with negative number OK
797 abc0def@or_broken@abc1def
798 errorlevel zero, good@or_broken@errorlevel nonzero, bad
799 7 should be 7
800 7 should still be 7
801 -----------Testing GOTO-----------
802 goto with no leading space worked
803 goto with a leading space worked
804 goto with a leading tab worked
805 goto with a following space worked
806 ---------- Testing combined CALLs/GOTOs -----------
807 world
808 cheball
809 barbare
813 cheball
814 barbare