github.com/solo-io/cue@v0.4.7/cue/testdata/basicrewrite/011_list_arithmetic.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: list arithmetic
     4  #evalPartial
     5  -- in.cue --
     6  list: [1, 2, 3]
     7  mul0: list * 0
     8  mul1: list * 1
     9  mul2: 2 * list
    10  list1: [1]
    11  mul1_0: list1 * 0
    12  mul1_1: 1 * list1
    13  mul1_2: list1 * 2
    14  add1_2: list + list1
    15  e:      list * -1
    16  -- out/def --
    17  list: [1, 2, 3]
    18  mul0: []
    19  mul1: [1, 2, 3]
    20  mul2: [1, 2, 3, 1, 2, 3]
    21  list1: [1]
    22  mul1_0: []
    23  mul1_1: [1]
    24  mul1_2: [1, 1]
    25  e: _|_ // negative number -1 multiplies list
    26  -- out/legacy-debug --
    27  <0>{list: [1,2,3], mul0: [], mul1: [1,2,3], mul2: [1,2,3,1,2,3], list1: [1], mul1_0: [], mul1_1: [1], mul1_2: [1,1], e: _|_((<1>.list * -1):negative number -1 multiplies list)}
    28  -- out/compile --
    29  --- in.cue
    30  {
    31    list: [
    32      1,
    33      2,
    34      3,
    35    ]
    36    mul0: (〈0;list〉 * 0)
    37    mul1: (〈0;list〉 * 1)
    38    mul2: (2 * 〈0;list〉)
    39    list1: [
    40      1,
    41    ]
    42    mul1_0: (〈0;list1〉 * 0)
    43    mul1_1: (1 * 〈0;list1〉)
    44    mul1_2: (〈0;list1〉 * 2)
    45    add1_2: (〈0;list〉 + 〈0;list1〉)
    46    e: (〈0;list〉 * -1)
    47  }
    48  -- out/eval --
    49  Errors:
    50  e: cannot convert negative number to uint64:
    51      ./in.cue:10:9
    52  
    53  Result:
    54  (_|_){
    55    // [eval]
    56    list: (#list){
    57      0: (int){ 1 }
    58      1: (int){ 2 }
    59      2: (int){ 3 }
    60    }
    61    mul0: (#list){
    62    }
    63    mul1: (#list){
    64      0: (int){ 1 }
    65      1: (int){ 2 }
    66      2: (int){ 3 }
    67    }
    68    mul2: (#list){
    69      0: (int){ 1 }
    70      1: (int){ 2 }
    71      2: (int){ 3 }
    72      3: (int){ 1 }
    73      4: (int){ 2 }
    74      5: (int){ 3 }
    75    }
    76    list1: (#list){
    77      0: (int){ 1 }
    78    }
    79    mul1_0: (#list){
    80    }
    81    mul1_1: (#list){
    82      0: (int){ 1 }
    83    }
    84    mul1_2: (#list){
    85      0: (int){ 1 }
    86      1: (int){ 1 }
    87    }
    88    add1_2: (#list){
    89      0: (int){ 1 }
    90      1: (int){ 2 }
    91      2: (int){ 3 }
    92      3: (int){ 1 }
    93    }
    94    e: (_|_){
    95      // [eval] e: cannot convert negative number to uint64:
    96      //     ./in.cue:10:9
    97    }
    98  }