...

Text file src/cuelang.org/go/cue/testdata/builtins/all.txtar

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

     1-- in.cue --
     2fatalArg: {
     3	x: len("eee" + 'eee')
     4}
     5
     6// don't call builtin for a permanent error of a child node
     7fatalChild: {
     8	#b: {}
     9	x: and([{a: #b.c}])
    10}
    11
    12// allow incomplete child values. The error will persist after `and` is
    13// evaluated down the line. This allows the and-ing of templates that may
    14// complete later.
    15okIncompleteChild: {
    16	b: {}
    17	x: and([{a: b.c}, {b: 1}])
    18}
    19-- out/eval/stats --
    20Leaks:  2
    21Freed:  12
    22Reused: 8
    23Allocs: 6
    24Retain: 2
    25
    26Unifications: 14
    27Conjuncts:    17
    28Disjuncts:    14
    29-- out/evalalpha --
    30Errors:
    31fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    32    ./in.cue:2:9
    33    ./in.cue:2:17
    34fatalChild.0.a: undefined field: c:
    35    ./in.cue:8:17
    36
    37Result:
    38(_|_){
    39  // [eval]
    40  fatalArg: (_|_){
    41    // [eval]
    42    x: (_|_){
    43      // [eval] fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    44      //     ./in.cue:2:9
    45      //     ./in.cue:2:17
    46    }
    47  }
    48  fatalChild: (_|_){
    49    // [eval]
    50    #b: (#struct){
    51    }
    52    x: (_|_){
    53      // [eval] fatalChild.0.a: undefined field: c:
    54      //     ./in.cue:8:17
    55    }
    56  }
    57  okIncompleteChild: (struct){
    58    b: (struct){
    59    }
    60    x: (struct){
    61      a: (_|_){
    62        // [incomplete] okIncompleteChild.x.a: undefined field: c:
    63        //     ./in.cue:16:16
    64      }
    65      b: (int){ 1 }
    66    }
    67  }
    68}
    69-- diff/-out/evalalpha<==>+out/eval --
    70diff old new
    71--- old
    72+++ new
    73@@ -2,7 +2,7 @@
    74 fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
    75     ./in.cue:2:9
    76     ./in.cue:2:17
    77-fatalChild.x.a: undefined field: c:
    78+fatalChild.0.a: undefined field: c:
    79     ./in.cue:8:17
    80 
    81 Result:
    82@@ -21,11 +21,8 @@
    83     #b: (#struct){
    84     }
    85     x: (_|_){
    86-      // [eval]
    87-      a: (_|_){
    88-        // [eval] fatalChild.x.a: undefined field: c:
    89-        //     ./in.cue:8:17
    90-      }
    91+      // [eval] fatalChild.0.a: undefined field: c:
    92+      //     ./in.cue:8:17
    93     }
    94   }
    95   okIncompleteChild: (struct){
    96-- diff/todo/p2 --
    97Path of old and new error is incorrect.
    98-- out/eval --
    99Errors:
   100fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
   101    ./in.cue:2:9
   102    ./in.cue:2:17
   103fatalChild.x.a: undefined field: c:
   104    ./in.cue:8:17
   105
   106Result:
   107(_|_){
   108  // [eval]
   109  fatalArg: (_|_){
   110    // [eval]
   111    x: (_|_){
   112      // [eval] fatalArg.x: invalid operands "eee" and 'eee' to '+' (type string and bytes):
   113      //     ./in.cue:2:9
   114      //     ./in.cue:2:17
   115    }
   116  }
   117  fatalChild: (_|_){
   118    // [eval]
   119    #b: (#struct){
   120    }
   121    x: (_|_){
   122      // [eval]
   123      a: (_|_){
   124        // [eval] fatalChild.x.a: undefined field: c:
   125        //     ./in.cue:8:17
   126      }
   127    }
   128  }
   129  okIncompleteChild: (struct){
   130    b: (struct){
   131    }
   132    x: (struct){
   133      a: (_|_){
   134        // [incomplete] okIncompleteChild.x.a: undefined field: c:
   135        //     ./in.cue:16:16
   136      }
   137      b: (int){ 1 }
   138    }
   139  }
   140}
   141-- out/compile --
   142--- in.cue
   143{
   144  fatalArg: {
   145    x: len(("eee" + 'eee'))
   146  }
   147  fatalChild: {
   148    #b: {}
   149    x: and([
   150      {
   151        a: 〈2;#b〉.c
   152      },
   153    ])
   154  }
   155  okIncompleteChild: {
   156    b: {}
   157    x: and([
   158      {
   159        a: 〈2;b〉.c
   160      },
   161      {
   162        b: 1
   163      },
   164    ])
   165  }
   166}

View as plain text