cuelang.org/go@v0.10.1/pkg/path/testdata/join.txtar (about) 1 // Copyright 2020 CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 16 -- in.cue -- 17 import "path" 18 19 joinSingle: path.Join(["a", "b"]) 20 joinSingle: "a/b" 21 22 Join: unix: _ 23 Join: windows: _ 24 25 Join: [OS=string]: [...{ 26 arg: [...string] 27 28 out: path.Join(arg, OS) 29 }] 30 31 Join: [_]: [ 32 {arg: ["a", "b"]}, 33 {arg: ["a/b", "c/d"]}, 34 35 {arg: ["/"]}, 36 {arg: ["a"]}, 37 38 {arg: ["a", "b"]}, 39 {arg: ["a", ""]}, 40 {arg: ["", "b"]}, 41 {arg: ["/", "a"]}, 42 {arg: ["/", "a/b"]}, 43 {arg: ["/", ""]}, 44 {arg: ["//", "a"]}, 45 46 {arg: ["directory", "file"]}, 47 48 {arg: [#"C:\Windows\"#, #"System32"#]}, 49 {arg: [#"C:\Windows\"#, #""#]}, 50 {arg: [#"C:\"#, #"Windows"#]}, 51 {arg: [#"C:"#, #"a\b"#]}, 52 {arg: [#"C:"#, #"a"#, #"b"#]}, 53 {arg: [#"C:"#, #""#, #""#, #"b"#]}, 54 {arg: [#"C:"#, #""#]}, 55 {arg: [#"C:"#, #""#, #""#]}, 56 {arg: [#"C:."#, #"a"#]}, 57 {arg: [#"C:a"#, #"b"#]}, 58 {arg: [#"\\host\share"#, #"foo"#]}, 59 ] 60 -- out/path-v3 -- 61 joinSingle: "a/b" 62 Join: { 63 unix: [{ 64 arg: ["a", "b"] 65 out: "a/b" 66 }, { 67 arg: ["a/b", "c/d"] 68 out: "a/b/c/d" 69 }, { 70 arg: ["/"] 71 out: "/" 72 }, { 73 arg: ["a"] 74 out: "a" 75 }, { 76 arg: ["a", "b"] 77 out: "a/b" 78 }, { 79 arg: ["a", ""] 80 out: "a" 81 }, { 82 arg: ["", "b"] 83 out: "b" 84 }, { 85 arg: ["/", "a"] 86 out: "/a" 87 }, { 88 arg: ["/", "a/b"] 89 out: "/a/b" 90 }, { 91 arg: ["/", ""] 92 out: "/" 93 }, { 94 arg: ["//", "a"] 95 out: "/a" 96 }, { 97 arg: ["directory", "file"] 98 out: "directory/file" 99 }, { 100 arg: ["C:\\Windows\\", "System32"] 101 out: "C:\\Windows\\/System32" 102 }, { 103 arg: ["C:\\Windows\\", ""] 104 out: "C:\\Windows\\" 105 }, { 106 arg: ["C:\\", "Windows"] 107 out: "C:\\/Windows" 108 }, { 109 arg: ["C:", "a\\b"] 110 out: "C:/a\\b" 111 }, { 112 arg: ["C:", "a", "b"] 113 out: "C:/a/b" 114 }, { 115 arg: ["C:", "", "", "b"] 116 out: "C:/b" 117 }, { 118 arg: ["C:", ""] 119 out: "C:" 120 }, { 121 arg: ["C:", "", ""] 122 out: "C:" 123 }, { 124 arg: ["C:.", "a"] 125 out: "C:./a" 126 }, { 127 arg: ["C:a", "b"] 128 out: "C:a/b" 129 }, { 130 arg: ["\\\\host\\share", "foo"] 131 out: "\\\\host\\share/foo" 132 }] 133 windows: [{ 134 arg: ["a", "b"] 135 out: "a\\b" 136 }, { 137 arg: ["a/b", "c/d"] 138 out: "a\\b\\c\\d" 139 }, { 140 arg: ["/"] 141 out: "\\" 142 }, { 143 arg: ["a"] 144 out: "a" 145 }, { 146 arg: ["a", "b"] 147 out: "a\\b" 148 }, { 149 arg: ["a", ""] 150 out: "a" 151 }, { 152 arg: ["", "b"] 153 out: "b" 154 }, { 155 arg: ["/", "a"] 156 out: "\\a" 157 }, { 158 arg: ["/", "a/b"] 159 out: "\\a\\b" 160 }, { 161 arg: ["/", ""] 162 out: "\\" 163 }, { 164 arg: ["//", "a"] 165 out: "\\a" 166 }, { 167 arg: ["directory", "file"] 168 out: "directory\\file" 169 }, { 170 arg: ["C:\\Windows\\", "System32"] 171 out: "C:\\Windows\\System32" 172 }, { 173 arg: ["C:\\Windows\\", ""] 174 out: "C:\\Windows" 175 }, { 176 arg: ["C:\\", "Windows"] 177 out: "C:\\Windows" 178 }, { 179 arg: ["C:", "a\\b"] 180 out: "C:a\\b" 181 }, { 182 arg: ["C:", "a", "b"] 183 out: "C:a\\b" 184 }, { 185 arg: ["C:", "", "", "b"] 186 out: "C:b" 187 }, { 188 arg: ["C:", ""] 189 out: "C:." 190 }, { 191 arg: ["C:", "", ""] 192 out: "C:." 193 }, { 194 arg: ["C:.", "a"] 195 out: "C:a" 196 }, { 197 arg: ["C:a", "b"] 198 out: "C:a\\b" 199 }, { 200 arg: ["\\\\host\\share", "foo"] 201 out: "\\\\host\\share\\foo" 202 }] 203 } 204 -- diff/-out/path-v3<==>+out/path -- 205 diff old new 206 --- old 207 +++ new 208 @@ -37,37 +37,37 @@ 209 arg: ["directory", "file"] 210 out: "directory/file" 211 }, { 212 - arg: [#"C:\Windows\"#, #"System32"#] 213 + arg: ["C:\\Windows\\", "System32"] 214 out: "C:\\Windows\\/System32" 215 }, { 216 - arg: [#"C:\Windows\"#, #""#] 217 + arg: ["C:\\Windows\\", ""] 218 out: "C:\\Windows\\" 219 }, { 220 - arg: [#"C:\"#, #"Windows"#] 221 + arg: ["C:\\", "Windows"] 222 out: "C:\\/Windows" 223 }, { 224 - arg: [#"C:"#, #"a\b"#] 225 + arg: ["C:", "a\\b"] 226 out: "C:/a\\b" 227 }, { 228 - arg: [#"C:"#, #"a"#, #"b"#] 229 + arg: ["C:", "a", "b"] 230 out: "C:/a/b" 231 }, { 232 - arg: [#"C:"#, #""#, #""#, #"b"#] 233 + arg: ["C:", "", "", "b"] 234 out: "C:/b" 235 }, { 236 - arg: [#"C:"#, #""#] 237 - out: "C:" 238 - }, { 239 - arg: [#"C:"#, #""#, #""#] 240 - out: "C:" 241 - }, { 242 - arg: [#"C:."#, #"a"#] 243 + arg: ["C:", ""] 244 + out: "C:" 245 + }, { 246 + arg: ["C:", "", ""] 247 + out: "C:" 248 + }, { 249 + arg: ["C:.", "a"] 250 out: "C:./a" 251 }, { 252 - arg: [#"C:a"#, #"b"#] 253 + arg: ["C:a", "b"] 254 out: "C:a/b" 255 }, { 256 - arg: [#"\\host\share"#, #"foo"#] 257 + arg: ["\\\\host\\share", "foo"] 258 out: "\\\\host\\share/foo" 259 }] 260 windows: [{ 261 @@ -107,37 +107,37 @@ 262 arg: ["directory", "file"] 263 out: "directory\\file" 264 }, { 265 - arg: [#"C:\Windows\"#, #"System32"#] 266 + arg: ["C:\\Windows\\", "System32"] 267 out: "C:\\Windows\\System32" 268 }, { 269 - arg: [#"C:\Windows\"#, #""#] 270 - out: "C:\\Windows" 271 - }, { 272 - arg: [#"C:\"#, #"Windows"#] 273 - out: "C:\\Windows" 274 - }, { 275 - arg: [#"C:"#, #"a\b"#] 276 - out: "C:a\\b" 277 - }, { 278 - arg: [#"C:"#, #"a"#, #"b"#] 279 - out: "C:a\\b" 280 - }, { 281 - arg: [#"C:"#, #""#, #""#, #"b"#] 282 + arg: ["C:\\Windows\\", ""] 283 + out: "C:\\Windows" 284 + }, { 285 + arg: ["C:\\", "Windows"] 286 + out: "C:\\Windows" 287 + }, { 288 + arg: ["C:", "a\\b"] 289 + out: "C:a\\b" 290 + }, { 291 + arg: ["C:", "a", "b"] 292 + out: "C:a\\b" 293 + }, { 294 + arg: ["C:", "", "", "b"] 295 out: "C:b" 296 }, { 297 - arg: [#"C:"#, #""#] 298 - out: "C:." 299 - }, { 300 - arg: [#"C:"#, #""#, #""#] 301 - out: "C:." 302 - }, { 303 - arg: [#"C:."#, #"a"#] 304 + arg: ["C:", ""] 305 + out: "C:." 306 + }, { 307 + arg: ["C:", "", ""] 308 + out: "C:." 309 + }, { 310 + arg: ["C:.", "a"] 311 out: "C:a" 312 }, { 313 - arg: [#"C:a"#, #"b"#] 314 - out: "C:a\\b" 315 - }, { 316 - arg: [#"\\host\share"#, #"foo"#] 317 + arg: ["C:a", "b"] 318 + out: "C:a\\b" 319 + }, { 320 + arg: ["\\\\host\\share", "foo"] 321 out: "\\\\host\\share\\foo" 322 }] 323 } 324 -- diff/todo/p2 -- 325 Differing string representation of semantically identical strings. 326 -- out/path -- 327 joinSingle: "a/b" 328 Join: { 329 unix: [{ 330 arg: ["a", "b"] 331 out: "a/b" 332 }, { 333 arg: ["a/b", "c/d"] 334 out: "a/b/c/d" 335 }, { 336 arg: ["/"] 337 out: "/" 338 }, { 339 arg: ["a"] 340 out: "a" 341 }, { 342 arg: ["a", "b"] 343 out: "a/b" 344 }, { 345 arg: ["a", ""] 346 out: "a" 347 }, { 348 arg: ["", "b"] 349 out: "b" 350 }, { 351 arg: ["/", "a"] 352 out: "/a" 353 }, { 354 arg: ["/", "a/b"] 355 out: "/a/b" 356 }, { 357 arg: ["/", ""] 358 out: "/" 359 }, { 360 arg: ["//", "a"] 361 out: "/a" 362 }, { 363 arg: ["directory", "file"] 364 out: "directory/file" 365 }, { 366 arg: [#"C:\Windows\"#, #"System32"#] 367 out: "C:\\Windows\\/System32" 368 }, { 369 arg: [#"C:\Windows\"#, #""#] 370 out: "C:\\Windows\\" 371 }, { 372 arg: [#"C:\"#, #"Windows"#] 373 out: "C:\\/Windows" 374 }, { 375 arg: [#"C:"#, #"a\b"#] 376 out: "C:/a\\b" 377 }, { 378 arg: [#"C:"#, #"a"#, #"b"#] 379 out: "C:/a/b" 380 }, { 381 arg: [#"C:"#, #""#, #""#, #"b"#] 382 out: "C:/b" 383 }, { 384 arg: [#"C:"#, #""#] 385 out: "C:" 386 }, { 387 arg: [#"C:"#, #""#, #""#] 388 out: "C:" 389 }, { 390 arg: [#"C:."#, #"a"#] 391 out: "C:./a" 392 }, { 393 arg: [#"C:a"#, #"b"#] 394 out: "C:a/b" 395 }, { 396 arg: [#"\\host\share"#, #"foo"#] 397 out: "\\\\host\\share/foo" 398 }] 399 windows: [{ 400 arg: ["a", "b"] 401 out: "a\\b" 402 }, { 403 arg: ["a/b", "c/d"] 404 out: "a\\b\\c\\d" 405 }, { 406 arg: ["/"] 407 out: "\\" 408 }, { 409 arg: ["a"] 410 out: "a" 411 }, { 412 arg: ["a", "b"] 413 out: "a\\b" 414 }, { 415 arg: ["a", ""] 416 out: "a" 417 }, { 418 arg: ["", "b"] 419 out: "b" 420 }, { 421 arg: ["/", "a"] 422 out: "\\a" 423 }, { 424 arg: ["/", "a/b"] 425 out: "\\a\\b" 426 }, { 427 arg: ["/", ""] 428 out: "\\" 429 }, { 430 arg: ["//", "a"] 431 out: "\\a" 432 }, { 433 arg: ["directory", "file"] 434 out: "directory\\file" 435 }, { 436 arg: [#"C:\Windows\"#, #"System32"#] 437 out: "C:\\Windows\\System32" 438 }, { 439 arg: [#"C:\Windows\"#, #""#] 440 out: "C:\\Windows" 441 }, { 442 arg: [#"C:\"#, #"Windows"#] 443 out: "C:\\Windows" 444 }, { 445 arg: [#"C:"#, #"a\b"#] 446 out: "C:a\\b" 447 }, { 448 arg: [#"C:"#, #"a"#, #"b"#] 449 out: "C:a\\b" 450 }, { 451 arg: [#"C:"#, #""#, #""#, #"b"#] 452 out: "C:b" 453 }, { 454 arg: [#"C:"#, #""#] 455 out: "C:." 456 }, { 457 arg: [#"C:"#, #""#, #""#] 458 out: "C:." 459 }, { 460 arg: [#"C:."#, #"a"#] 461 out: "C:a" 462 }, { 463 arg: [#"C:a"#, #"b"#] 464 out: "C:a\\b" 465 }, { 466 arg: [#"\\host\share"#, #"foo"#] 467 out: "\\\\host\\share\\foo" 468 }] 469 }