...

Text file src/cuelang.org/go/pkg/path/testdata/join.txtar

Documentation: cuelang.org/go/pkg/path/testdata

     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 --
    17import "path"
    18
    19joinSingle: path.Join(["a", "b"])
    20joinSingle: "a/b"
    21
    22Join: unix:    _
    23Join: windows: _
    24
    25Join: [OS=string]: [...{
    26	arg: [...string]
    27
    28	out: path.Join(arg, OS)
    29}]
    30
    31Join: [_]: [
    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 --
    61joinSingle: "a/b"
    62Join: {
    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}

View as plain text