cuelang.org/go@v0.10.1/pkg/list/testdata/list.txtar (about)

     1  -- in.cue --
     2  import "list"
     3  
     4  repeat: {
     5  	[string]: {x: _, n: int, v: list.Repeat(x, n)}
     6  
     7  	t1: {x: [], n: 0}
     8  	t2: {x: [1], n: 0}
     9  
    10  	t3: {x: [1], n: 1}
    11  	t4: {x: [1, 2], n: 1}
    12  
    13  	t5: {x: [], n: 3}
    14  	t6: {x: [1, 2], n: 3}
    15  	t7: {x: [1, 2, 3, 4], n: 3}
    16  
    17  	t8: {x: [1], n: -1}
    18  }
    19  concat: {
    20  	[string]: {x: _, v: list.Concat(x)}
    21  
    22  	t1: x: []
    23  	t2: x: [[]]
    24  
    25  	t3: x: [[1]]
    26  	t4: x: [[1, 2]]
    27  	t5: x: [[1], [2]]
    28  
    29  	t6: x: [[1, 2], [3, 4]]
    30  
    31  	t7: x: 1
    32  	t8: x: [1, [2]]
    33  }
    34  unique: {
    35  	issue797: {
    36  		mylst: [
    37  			{foo: "bar"},
    38  			{foo: "baz"},
    39  		]
    40  
    41  		_testmylst: list.UniqueItems & [ for x in mylst {x.foo}]
    42  	}
    43  }
    44  // Issue #2099
    45  minItems: {
    46  	[string]: list.MinItems(1)
    47  	incomplete1: [...]
    48  	fail1: []
    49  	ok1: [0, ...]
    50  	ok2: [0]
    51  }
    52  
    53  maxItems: {
    54  	[string]: list.MaxItems(1)
    55  	ok1: [...]
    56  	ok2: [0, ...]
    57  	ok3: [0, ...]
    58  
    59  	fail1: [0, 1]
    60  }
    61  
    62  reverse: {
    63      [string]: {x: _, v: list.Reverse(x)}
    64  
    65      t1: x: []
    66      t2: x: [1]
    67      t3: x: [1, 2, 3, 4]
    68  
    69      fail1: x: 1
    70      fail2: x: "bad"
    71  }
    72  
    73  -- out/list-v3 --
    74  Errors:
    75  repeat.t8.v: error in call to list.Repeat: negative count:
    76      ./in.cue:4:30
    77  concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list:
    78      ./in.cue:19:22
    79      ./in.cue:31:10
    80  concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat:
    81      ./in.cue:30:9
    82  minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1):
    83      ./in.cue:45:12
    84      ./in.cue:45:26
    85  maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1):
    86      ./in.cue:53:12
    87      ./in.cue:53:26
    88  reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse:
    89      ./in.cue:68:15
    90  reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse:
    91      ./in.cue:69:15
    92  
    93  Result:
    94  import "list"
    95  
    96  repeat: {
    97  	t1: {
    98  		x: []
    99  		n: 0
   100  		v: []
   101  	}
   102  	t2: {
   103  		x: [1]
   104  		n: 0
   105  		v: []
   106  	}
   107  	t3: {
   108  		x: [1]
   109  		n: 1
   110  		v: [1]
   111  	}
   112  	t4: {
   113  		x: [1, 2]
   114  		n: 1
   115  		v: [1, 2]
   116  	}
   117  	t5: {
   118  		x: []
   119  		n: 3
   120  		v: []
   121  	}
   122  	t6: {
   123  		x: [1, 2]
   124  		n: 3
   125  		v: [1, 2, 1, 2, 1, 2]
   126  	}
   127  	t7: {
   128  		x: [1, 2, 3, 4]
   129  		n: 3
   130  		v: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
   131  	}
   132  	t8: {
   133  		x: [1]
   134  		n: -1
   135  		v: _|_ // repeat.t8.v: error in call to list.Repeat: negative count
   136  	}
   137  }
   138  concat: {
   139  	t1: {
   140  		x: []
   141  		v: []
   142  	}
   143  	t2: {
   144  		x: [[]]
   145  		v: []
   146  	}
   147  	t3: {
   148  		x: [[1]]
   149  		v: [1]
   150  	}
   151  	t4: {
   152  		x: [[1, 2]]
   153  		v: [1, 2]
   154  	}
   155  	t5: {
   156  		x: [[1], [2]]
   157  		v: [1, 2]
   158  	}
   159  	t6: {
   160  		x: [[1, 2], [3, 4]]
   161  		v: [1, 2, 3, 4]
   162  	}
   163  	t7: {
   164  		x: 1
   165  		v: _|_ // concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat
   166  	}
   167  	t8: {
   168  		x: [1, [2]]
   169  		v: _|_ // concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list
   170  	}
   171  }
   172  unique: {
   173  	issue797: {
   174  		mylst: [{
   175  			foo: "bar"
   176  		}, {
   177  			foo: "baz"
   178  		}]
   179  	}
   180  }
   181  // Issue #2099
   182  minItems: {
   183  	incomplete1: [...] & list.MinItems(1)
   184  	fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1)
   185  	ok1: [0, ...]
   186  	ok2: [0]
   187  }
   188  maxItems: {
   189  	ok1: [...]
   190  	ok2: [0, ...]
   191  	ok3: [0, ...]
   192  	fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1)
   193  }
   194  reverse: {
   195  	t1: {
   196  		x: []
   197  		v: []
   198  	}
   199  	t2: {
   200  		x: [1]
   201  		v: [1]
   202  	}
   203  	t3: {
   204  		x: [1, 2, 3, 4]
   205  		v: [4, 3, 2, 1]
   206  	}
   207  	fail1: {
   208  		x: 1
   209  		v: _|_ // reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse
   210  	}
   211  	fail2: {
   212  		x: "bad"
   213  		v: _|_ // reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse
   214  	}
   215  }
   216  -- diff/-out/list-v3<==>+out/list --
   217  diff old new
   218  --- old
   219  +++ new
   220  @@ -9,11 +9,9 @@
   221   minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1):
   222       ./in.cue:45:12
   223       ./in.cue:45:26
   224  -    ./in.cue:47:9
   225   maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1):
   226       ./in.cue:53:12
   227       ./in.cue:53:26
   228  -    ./in.cue:58:9
   229   reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse:
   230       ./in.cue:68:15
   231   reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse:
   232  -- diff/todo/p2 --
   233  Missing error positions.
   234  -- out/list --
   235  Errors:
   236  repeat.t8.v: error in call to list.Repeat: negative count:
   237      ./in.cue:4:30
   238  concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list:
   239      ./in.cue:19:22
   240      ./in.cue:31:10
   241  concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat:
   242      ./in.cue:30:9
   243  minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1):
   244      ./in.cue:45:12
   245      ./in.cue:45:26
   246      ./in.cue:47:9
   247  maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1):
   248      ./in.cue:53:12
   249      ./in.cue:53:26
   250      ./in.cue:58:9
   251  reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse:
   252      ./in.cue:68:15
   253  reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse:
   254      ./in.cue:69:15
   255  
   256  Result:
   257  import "list"
   258  
   259  repeat: {
   260  	t1: {
   261  		x: []
   262  		n: 0
   263  		v: []
   264  	}
   265  	t2: {
   266  		x: [1]
   267  		n: 0
   268  		v: []
   269  	}
   270  	t3: {
   271  		x: [1]
   272  		n: 1
   273  		v: [1]
   274  	}
   275  	t4: {
   276  		x: [1, 2]
   277  		n: 1
   278  		v: [1, 2]
   279  	}
   280  	t5: {
   281  		x: []
   282  		n: 3
   283  		v: []
   284  	}
   285  	t6: {
   286  		x: [1, 2]
   287  		n: 3
   288  		v: [1, 2, 1, 2, 1, 2]
   289  	}
   290  	t7: {
   291  		x: [1, 2, 3, 4]
   292  		n: 3
   293  		v: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
   294  	}
   295  	t8: {
   296  		x: [1]
   297  		n: -1
   298  		v: _|_ // repeat.t8.v: error in call to list.Repeat: negative count
   299  	}
   300  }
   301  concat: {
   302  	t1: {
   303  		x: []
   304  		v: []
   305  	}
   306  	t2: {
   307  		x: [[]]
   308  		v: []
   309  	}
   310  	t3: {
   311  		x: [[1]]
   312  		v: [1]
   313  	}
   314  	t4: {
   315  		x: [[1, 2]]
   316  		v: [1, 2]
   317  	}
   318  	t5: {
   319  		x: [[1], [2]]
   320  		v: [1, 2]
   321  	}
   322  	t6: {
   323  		x: [[1, 2], [3, 4]]
   324  		v: [1, 2, 3, 4]
   325  	}
   326  	t7: {
   327  		x: 1
   328  		v: _|_ // concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat
   329  	}
   330  	t8: {
   331  		x: [1, [2]]
   332  		v: _|_ // concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list
   333  	}
   334  }
   335  unique: {
   336  	issue797: {
   337  		mylst: [{
   338  			foo: "bar"
   339  		}, {
   340  			foo: "baz"
   341  		}]
   342  	}
   343  }
   344  // Issue #2099
   345  minItems: {
   346  	incomplete1: [...] & list.MinItems(1)
   347  	fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1)
   348  	ok1: [0, ...]
   349  	ok2: [0]
   350  }
   351  maxItems: {
   352  	ok1: [...]
   353  	ok2: [0, ...]
   354  	ok3: [0, ...]
   355  	fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1)
   356  }
   357  reverse: {
   358  	t1: {
   359  		x: []
   360  		v: []
   361  	}
   362  	t2: {
   363  		x: [1]
   364  		v: [1]
   365  	}
   366  	t3: {
   367  		x: [1, 2, 3, 4]
   368  		v: [4, 3, 2, 1]
   369  	}
   370  	fail1: {
   371  		x: 1
   372  		v: _|_ // reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse
   373  	}
   374  	fail2: {
   375  		x: "bad"
   376  		v: _|_ // reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse
   377  	}
   378  }