[10723] | 1 | #!./perl |
---|
| 2 | |
---|
| 3 | BEGIN { unshift(@INC,'../lib') if -d '../lib'; } |
---|
| 4 | |
---|
| 5 | use VMS::Filespec; |
---|
| 6 | |
---|
| 7 | foreach (<DATA>) { |
---|
| 8 | chomp; |
---|
| 9 | s/\s*#.*//; |
---|
| 10 | next if /^\s*$/; |
---|
| 11 | push(@tests,$_); |
---|
| 12 | } |
---|
| 13 | print '1..',scalar(@tests)+3,"\n"; |
---|
| 14 | |
---|
| 15 | foreach $test (@tests) { |
---|
| 16 | ($arg,$func,$expect) = split(/\t+/,$test); |
---|
| 17 | $idx++; |
---|
| 18 | $rslt = eval "$func('$arg')"; |
---|
| 19 | if ($@) { print "not ok $idx : eval error: $@\n"; next; } |
---|
| 20 | else { |
---|
| 21 | if ($rslt ne $expect) { |
---|
| 22 | print "not ok $idx : $func('$arg') expected |$expect|, got |$rslt|\n"; |
---|
| 23 | } |
---|
| 24 | else { print "ok $idx\n"; } |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | if (rmsexpand('[]') eq "\U$ENV{DEFAULT}") { print 'ok ',++$idx,"\n"; } |
---|
| 29 | else { |
---|
| 30 | print 'not ok ', ++$idx, ": rmsexpand('[]') = |", rmsexpand('[]'), |
---|
| 31 | "|, \$ENV{DEFAULT} = |\U$ENV{DEFAULT}|\n"; |
---|
| 32 | print "# Note: This failure may have occurred because your default device\n"; |
---|
| 33 | print "# was set using a non-concealed logical name. If this is the case,\n"; |
---|
| 34 | print "# you will need to determine by inspection that the two resultant\n"; |
---|
| 35 | print "# file specifications shwn above are in fact equivalent.\n"; |
---|
| 36 | } |
---|
| 37 | if (rmsexpand('from.here') eq "\L$ENV{DEFAULT}from.here") { |
---|
| 38 | print 'ok ', ++$idx, "\n"; |
---|
| 39 | } |
---|
| 40 | else { |
---|
| 41 | print 'not ok ', ++$idx, ": rmsexpand('from.here') = |", |
---|
| 42 | rmsexpand('from.here'), |
---|
| 43 | "|, \$ENV{DEFAULT}from.here = |\L$ENV{DEFAULT}from.here|\n"; |
---|
| 44 | print "# Note: This failure may have occurred because your default device\n"; |
---|
| 45 | print "# was set using a non-concealed logical name. If this is the case,\n"; |
---|
| 46 | print "# you will need to determine by inspection that the two resultant\n"; |
---|
| 47 | print "# file specifications shwn above are in fact equivalent.\n"; |
---|
| 48 | } |
---|
| 49 | if (rmsexpand('from.here','cant:[get.there];2') eq |
---|
| 50 | 'cant:[get.there]from.here;2') { print 'ok ',++$idx,"\n"; } |
---|
| 51 | else { |
---|
| 52 | print 'not ok ', ++$idx, ': expected |cant:[get.there]from.here;2|, got |', |
---|
| 53 | rmsexpand('from.here','cant:[get.there];2'),"|\n"; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | __DATA__ |
---|
| 57 | |
---|
| 58 | # Basic VMS to Unix filespecs |
---|
| 59 | some:[where.over]the.rainbow unixify /some/where/over/the.rainbow |
---|
| 60 | [.some.where.over]the.rainbow unixify some/where/over/the.rainbow |
---|
| 61 | [-.some.where.over]the.rainbow unixify ../some/where/over/the.rainbow |
---|
| 62 | [.some.--.where.over]the.rainbow unixify some/../../where/over/the.rainbow |
---|
| 63 | [.some...where.over]the.rainbow unixify some/.../where/over/the.rainbow |
---|
| 64 | [...some.where.over]the.rainbow unixify .../some/where/over/the.rainbow |
---|
| 65 | [.some.where.over...]the.rainbow unixify some/where/over/.../the.rainbow |
---|
| 66 | [.some.where.over...] unixify some/where/over/.../ |
---|
| 67 | [.some.where.over.-] unixify some/where/over/../ |
---|
| 68 | [] unixify ./ |
---|
| 69 | [-] unixify ../ |
---|
| 70 | [--] unixify ../../ |
---|
| 71 | [...] unixify .../ |
---|
| 72 | |
---|
| 73 | # and back again |
---|
| 74 | /some/where/over/the.rainbow vmsify some:[where.over]the.rainbow |
---|
| 75 | some/where/over/the.rainbow vmsify [.some.where.over]the.rainbow |
---|
| 76 | ../some/where/over/the.rainbow vmsify [-.some.where.over]the.rainbow |
---|
| 77 | some/../../where/over/the.rainbow vmsify [-.where.over]the.rainbow |
---|
| 78 | .../some/where/over/the.rainbow vmsify [...some.where.over]the.rainbow |
---|
| 79 | some/.../where/over/the.rainbow vmsify [.some...where.over]the.rainbow |
---|
| 80 | /some/.../where/over/the.rainbow vmsify some:[...where.over]the.rainbow |
---|
| 81 | some/where/... vmsify [.some.where...] |
---|
| 82 | /where/... vmsify where:[...] |
---|
| 83 | . vmsify [] |
---|
| 84 | .. vmsify [-] |
---|
| 85 | ../.. vmsify [--] |
---|
| 86 | .../ vmsify [...] |
---|
| 87 | |
---|
| 88 | # Fileifying directory specs |
---|
| 89 | down:[the.garden.path] fileify down:[the.garden]path.dir;1 |
---|
| 90 | [.down.the.garden.path] fileify [.down.the.garden]path.dir;1 |
---|
| 91 | /down/the/garden/path fileify /down/the/garden/path.dir;1 |
---|
| 92 | /down/the/garden/path/ fileify /down/the/garden/path.dir;1 |
---|
| 93 | down/the/garden/path fileify down/the/garden/path.dir;1 |
---|
| 94 | down:[the.garden]path fileify down:[the.garden]path.dir;1 |
---|
| 95 | down:[the.garden]path. fileify # N.B. trailing . ==> null type |
---|
| 96 | down:[the]garden.path fileify |
---|
| 97 | /down/the/garden/path. fileify # N.B. trailing . ==> null type |
---|
| 98 | /down/the/garden.path fileify |
---|
| 99 | |
---|
| 100 | # and pathifying them |
---|
| 101 | down:[the.garden]path.dir;1 pathify down:[the.garden.path] |
---|
| 102 | [.down.the.garden]path.dir pathify [.down.the.garden.path] |
---|
| 103 | /down/the/garden/path.dir pathify /down/the/garden/path/ |
---|
| 104 | down/the/garden/path.dir pathify down/the/garden/path/ |
---|
| 105 | down:[the.garden]path pathify down:[the.garden.path] |
---|
| 106 | down:[the.garden]path. pathify # N.B. trailing . ==> null type |
---|
| 107 | down:[the]garden.path pathify |
---|
| 108 | /down/the/garden/path. pathify # N.B. trailing . ==> null type |
---|
| 109 | /down/the/garden.path pathify |
---|
| 110 | down:[the.garden]path.dir;2 pathify #N.B. ;2 |
---|
| 111 | path pathify path/ |
---|
| 112 | /down/the/garden/. pathify /down/the/garden/./ |
---|
| 113 | /down/the/garden/.. pathify /down/the/garden/../ |
---|
| 114 | /down/the/garden/... pathify /down/the/garden/.../ |
---|
| 115 | path.notdir pathify |
---|
| 116 | |
---|
| 117 | # Both VMS/Unix and file/path conversions |
---|
| 118 | down:[the.garden]path.dir;1 unixpath /down/the/garden/path/ |
---|
| 119 | /down/the/garden/path vmspath down:[the.garden.path] |
---|
| 120 | down:[the.garden.path] unixpath /down/the/garden/path/ |
---|
| 121 | down:[the.garden.path...] unixpath /down/the/garden/path/.../ |
---|
| 122 | /down/the/garden/path.dir vmspath down:[the.garden.path] |
---|
| 123 | [.down.the.garden]path.dir unixpath down/the/garden/path/ |
---|
| 124 | down/the/garden/path vmspath [.down.the.garden.path] |
---|
| 125 | path vmspath [.path] |
---|
| 126 | |
---|
| 127 | # Redundant characters in Unix paths |
---|
| 128 | //some/where//over/../the.rainbow vmsify some:[where]the.rainbow |
---|
| 129 | /some/where//over/./the.rainbow vmsify some:[where.over]the.rainbow |
---|
| 130 | ..//../ vmspath [--] |
---|
| 131 | ./././ vmspath [] |
---|
| 132 | ./../. vmsify [-] |
---|
| 133 | |
---|