github.com/solo-io/cue@v0.4.7/cue/testdata/resolve/018_slice.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: slice
     4  #evalPartial
     5  -- in.cue --
     6  a:  [2][0:0]
     7  b:  [0][1:1]
     8  e1: [][1:1]
     9  e2: [0][-1:0]
    10  e3: [0][1:0]
    11  e4: [0][1:2]
    12  e5: 4[1:2]
    13  e6: [2]["":]
    14  e7: [2][:"9"]
    15  -- out/def --
    16  a: []
    17  b: []
    18  e1: _|_ // slice bounds out of range
    19  e2: _|_ // negative slice index
    20  e3: _|_ // invalid slice index: 1 > 0
    21  e4: _|_ // slice bounds out of range
    22  e5: _|_ // cannot slice 4 (type int)
    23  e6: _|_ // invalid slice index "" (type string)
    24  e7: _|_ // invalid slice index "9" (type string)
    25  -- out/legacy-debug --
    26  <0>{a: [], b: [], e1: _|_(1:slice bounds out of range), e2: _|_([0]:negative slice index), e3: _|_([0]:invalid slice index: 1 > 0), e4: _|_(2:slice bounds out of range), e5: _|_(4:cannot slice 4 (type int)), e6: _|_("":invalid slice index "" (type string)), e7: _|_("9":invalid slice index "9" (type string))}
    27  -- out/compile --
    28  --- in.cue
    29  {
    30    a: [
    31      2,
    32    ][0:0]
    33    b: [
    34      0,
    35    ][1:1]
    36    e1: [][1:1]
    37    e2: [
    38      0,
    39    ][-1:0]
    40    e3: [
    41      0,
    42    ][1:0]
    43    e4: [
    44      0,
    45    ][1:2]
    46    e5: 4[1:2]
    47    e6: [
    48      2,
    49    ]["":]
    50    e7: [
    51      2,
    52    ][:"9"]
    53  }
    54  -- out/eval --
    55  Errors:
    56  e1: index 1 out of range:
    57      ./in.cue:3:5
    58  e2: cannot convert negative number to uint64:
    59      ./in.cue:4:5
    60  e3: invalid slice index: 1 > 0:
    61      ./in.cue:5:5
    62  e4: index 2 out of range:
    63      ./in.cue:6:5
    64  e5: cannot slice 4 (type int):
    65      ./in.cue:7:5
    66  e6: cannot use "" (type string) as type int in slice index:
    67      ./in.cue:8:5
    68      ./in.cue:8:9
    69  e7: cannot use "9" (type string) as type int in slice index:
    70      ./in.cue:9:5
    71      ./in.cue:9:10
    72  
    73  Result:
    74  (_|_){
    75    // [eval]
    76    a: (#list){
    77    }
    78    b: (#list){
    79    }
    80    e1: (_|_){
    81      // [eval] e1: index 1 out of range:
    82      //     ./in.cue:3:5
    83    }
    84    e2: (_|_){
    85      // [eval] e2: cannot convert negative number to uint64:
    86      //     ./in.cue:4:5
    87    }
    88    e3: (_|_){
    89      // [eval] e3: invalid slice index: 1 > 0:
    90      //     ./in.cue:5:5
    91    }
    92    e4: (_|_){
    93      // [eval] e4: index 2 out of range:
    94      //     ./in.cue:6:5
    95    }
    96    e5: (_|_){
    97      // [eval] e5: cannot slice 4 (type int):
    98      //     ./in.cue:7:5
    99    }
   100    e6: (_|_){
   101      // [eval] e6: cannot use "" (type string) as type int in slice index:
   102      //     ./in.cue:8:5
   103      //     ./in.cue:8:9
   104    }
   105    e7: (_|_){
   106      // [eval] e7: cannot use "9" (type string) as type int in slice index:
   107      //     ./in.cue:9:5
   108      //     ./in.cue:9:10
   109    }
   110  }