...

Text file src/cuelang.org/go/cue/testdata/resolve/016_index.txtar

Documentation: cuelang.org/go/cue/testdata/resolve

     1# DO NOT EDIT; generated by go run testdata/gen.go
     2#
     3#name: index
     4#evalPartial
     5-- in.cue --
     6a: [2][0]
     7b: {foo:       "bar"}["foo"]
     8c: (*l | {"3": 3})["3"]
     9d: (*[] | [1])[0]
    10l: []
    11e1: [2][""]
    12e2: 2[2]
    13e3: [][true]
    14e4: [1, 2, 3][3]
    15e5: [1, 2, 3][-1]
    16e6: (*[] | {})[1]
    17e7: [1, 2, 3][3]
    18e8: [1, 2, 3][-1]
    19e9: (*[] | {})[1]
    20
    21def: {
    22	a:  1
    23	#b: 3
    24}
    25e7: def["b"]
    26-- out/def --
    27a: 2
    28b: "bar"
    29c: _|_ // invalid list index "3" (type string)
    30l: []
    31d:  _|_ // index 0 out of bounds
    32e1: _|_ // invalid list index "" (type string)
    33e2: _|_ // invalid operation: 2[2] (type int does not support indexing)
    34e3: _|_ // invalid list index true (type bool)
    35e4: _|_ // index 3 out of bounds
    36e5: _|_ // invalid list index -1 (index must be non-negative)
    37e6: _|_ // index 1 out of bounds
    38def: {
    39	a:  1
    40	#b: 3
    41}
    42e7: def["b"]
    43-- out/legacy-debug --
    44<0>{a: 2, b: "bar", c: _|_("3":invalid list index "3" (type string)), l: [], d: _|_([]:index 0 out of bounds), e1: _|_("":invalid list index "" (type string)), e2: _|_(2:invalid operation: 2[2] (type int does not support indexing)), e3: _|_(true:invalid list index true (type bool)), e4: _|_([1,2,3]:index 3 out of bounds), e5: _|_(-1:invalid list index -1 (index must be non-negative)), e6: _|_([]:index 1 out of bounds), def: <1>{a: 1, #b: 3}, e7: <2>.def["b"]}
    45-- out/compile --
    46--- in.cue
    47{
    48  a: [
    49    2,
    50  ][0]
    51  b: {
    52    foo: "bar"
    53  }["foo"]
    54  c: (*〈0;l〉|{
    55    "3": 3
    56  })["3"]
    57  d: (*[]|[
    58    1,
    59  ])[0]
    60  l: []
    61  e1: [
    62    2,
    63  ][""]
    64  e2: 2[2]
    65  e3: [][true]
    66  e4: [
    67    1,
    68    2,
    69    3,
    70  ][3]
    71  e5: [
    72    1,
    73    2,
    74    3,
    75  ][-1]
    76  e6: (*[]|{})[1]
    77  e7: [
    78    1,
    79    2,
    80    3,
    81  ][3]
    82  e8: [
    83    1,
    84    2,
    85    3,
    86  ][-1]
    87  e9: (*[]|{})[1]
    88  def: {
    89    a: 1
    90    #b: 3
    91  }
    92  e7: 〈0;def〉["b"]
    93}
    94-- out/eval/stats --
    95Leaks:  10
    96Freed:  32
    97Reused: 26
    98Allocs: 16
    99Retain: 16
   100
   101Unifications: 34
   102Conjuncts:    48
   103Disjuncts:    46
   104-- out/eval --
   105Errors:
   106c: invalid list index "3" (type string):
   107    ./in.cue:3:20
   108d: index out of range [0] with length 0:
   109    ./in.cue:4:16
   110e1: invalid list index "" (type string):
   111    ./in.cue:6:9
   112e2: invalid operand 2 (found int, want list or struct):
   113    ./in.cue:7:5
   114e3: invalid index true (invalid type bool):
   115    ./in.cue:8:5
   116    ./in.cue:8:8
   117e4: index out of range [3] with length 3:
   118    ./in.cue:9:15
   119e5: invalid index -1 (index must be non-negative):
   120    ./in.cue:10:5
   121    ./in.cue:10:15
   122e6: invalid list index 1 (out of bounds):
   123    ./in.cue:11:16
   124e7: index out of range [3] with length 3:
   125    ./in.cue:12:15
   126e8: invalid index -1 (index must be non-negative):
   127    ./in.cue:13:5
   128    ./in.cue:13:15
   129e9: invalid list index 1 (out of bounds):
   130    ./in.cue:14:16
   131
   132Result:
   133(_|_){
   134  // [eval]
   135  a: (int){ 2 }
   136  b: (string){ "bar" }
   137  c: (_|_){
   138    // [eval] c: invalid list index "3" (type string):
   139    //     ./in.cue:3:20
   140  }
   141  d: (_|_){
   142    // [eval] d: index out of range [0] with length 0:
   143    //     ./in.cue:4:16
   144  }
   145  l: (#list){
   146  }
   147  e1: (_|_){
   148    // [eval] e1: invalid list index "" (type string):
   149    //     ./in.cue:6:9
   150  }
   151  e2: (_|_){
   152    // [eval] e2: invalid operand 2 (found int, want list or struct):
   153    //     ./in.cue:7:5
   154  }
   155  e3: (_|_){
   156    // [eval] e3: invalid index true (invalid type bool):
   157    //     ./in.cue:8:5
   158    //     ./in.cue:8:8
   159  }
   160  e4: (_|_){
   161    // [eval] e4: index out of range [3] with length 3:
   162    //     ./in.cue:9:15
   163  }
   164  e5: (_|_){
   165    // [eval] e5: invalid index -1 (index must be non-negative):
   166    //     ./in.cue:10:5
   167    //     ./in.cue:10:15
   168  }
   169  e6: (_|_){
   170    // [eval] e6: invalid list index 1 (out of bounds):
   171    //     ./in.cue:11:16
   172  }
   173  e7: (_|_){
   174    // [eval] e7: index out of range [3] with length 3:
   175    //     ./in.cue:12:15
   176  }
   177  e8: (_|_){
   178    // [eval] e8: invalid index -1 (index must be non-negative):
   179    //     ./in.cue:13:5
   180    //     ./in.cue:13:15
   181  }
   182  e9: (_|_){
   183    // [eval] e9: invalid list index 1 (out of bounds):
   184    //     ./in.cue:14:16
   185  }
   186  def: (struct){
   187    a: (int){ 1 }
   188    #b: (int){ 3 }
   189  }
   190}

View as plain text