...

Text file src/cuelang.org/go/cue/testdata/resolve/025_definitions.txtar

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

     1# DO NOT EDIT; generated by go run testdata/gen.go
     2#
     3#name: definitions
     4#evalPartial
     5-- in.cue --
     6#Foo: {
     7	field: int
     8	recursive: {
     9		field: string
    10	}
    11}
    12
    13// Allowed
    14#Foo1: {field: int}
    15#Foo1: {field2: string}
    16
    17foo: #Foo
    18foo: {feild: 2}
    19
    20foo1: #Foo
    21foo1: {
    22	field: 2
    23	recursive: {
    24		feild: 2 // Not caught as per spec. TODO: change?
    25	}
    26}
    27
    28#Bar: {
    29	field: int
    30	{[A=_]: int}
    31}
    32bar: #Bar
    33bar: {feild: 2}
    34
    35#Mixed: string
    36Mixed:  string
    37
    38mixedRec: {#Mixed: string}
    39mixedRec: {Mixed: string}
    40-- out/def --
    41#Foo: {
    42	field: int
    43	recursive: {
    44		field: string
    45	}
    46}
    47
    48// Allowed
    49#Foo1: {
    50	field:  int
    51	field2: string
    52}
    53foo:  _|_ // field "feild" not allowed in closed struct
    54foo1: #Foo & {
    55	field: 2
    56	recursive: {
    57		feild: 2
    58	}
    59}
    60#Bar: {
    61	{[A=string]: int}
    62	field: int
    63}
    64bar: #Bar & {
    65	feild: 2
    66}
    67#Mixed: string
    68Mixed:  string
    69mixedRec: {
    70	#Mixed: string
    71	Mixed:  string
    72}
    73-- out/legacy-debug --
    74<0>{#Foo: <1>C{field: int, recursive: <2>C{field: string}}, #Foo1: <3>C{field: int, field2: string}, foo: _|_(2:field "feild" not allowed in closed struct), foo1: <4>C{field: 2, recursive: _|_(2:field "feild" not allowed in closed struct)}, #Bar: <5>{[]: <6>(A: string)->int, field: int}, bar: <7>{[]: <8>(A: string)->int, field: int, feild: 2}, #Mixed: string, Mixed: string, mixedRec: <9>{#Mixed: string, Mixed: string}}
    75-- out/compile --
    76--- in.cue
    77{
    78  #Foo: {
    79    field: int
    80    recursive: {
    81      field: string
    82    }
    83  }
    84  #Foo1: {
    85    field: int
    86  }
    87  #Foo1: {
    88    field2: string
    89  }
    90  foo: 〈0;#Foo〉
    91  foo: {
    92    feild: 2
    93  }
    94  foo1: 〈0;#Foo〉
    95  foo1: {
    96    field: 2
    97    recursive: {
    98      feild: 2
    99    }
   100  }
   101  #Bar: {
   102    field: int
   103    {
   104      [_]: int
   105    }
   106  }
   107  bar: 〈0;#Bar〉
   108  bar: {
   109    feild: 2
   110  }
   111  #Mixed: string
   112  Mixed: string
   113  mixedRec: {
   114    #Mixed: string
   115  }
   116  mixedRec: {
   117    Mixed: string
   118  }
   119}
   120-- out/eval/stats --
   121Leaks:  0
   122Freed:  28
   123Reused: 24
   124Allocs: 4
   125Retain: 0
   126
   127Unifications: 28
   128Conjuncts:    43
   129Disjuncts:    28
   130-- out/evalalpha --
   131Errors:
   132foo1.recursive.feild: field not allowed:
   133    ./in.cue:19:3
   134foo.feild: field not allowed:
   135    ./in.cue:12:6
   136    ./in.cue:13:7
   137
   138Result:
   139(_|_){
   140  // [eval]
   141  #Foo: (#struct){
   142    field: (int){ int }
   143    recursive: (#struct){
   144      field: (string){ string }
   145    }
   146  }
   147  #Foo1: (#struct){
   148    field: (int){ int }
   149    field2: (string){ string }
   150  }
   151  foo: (_|_){
   152    // [eval]
   153    feild: (_|_){
   154      // [eval] foo.feild: field not allowed:
   155      //     ./in.cue:12:6
   156      //     ./in.cue:13:7
   157    }
   158    field: (int){ int }
   159    recursive: (#struct){
   160      field: (string){ string }
   161    }
   162  }
   163  foo1: (_|_){
   164    // [eval]
   165    field: (int){ 2 }
   166    recursive: (_|_){
   167      // [eval]
   168      feild: (_|_){
   169        // [eval] foo1.recursive.feild: field not allowed:
   170        //     ./in.cue:19:3
   171      }
   172      field: (string){ string }
   173    }
   174  }
   175  #Bar: (#struct){
   176    field: (int){ int }
   177  }
   178  bar: (#struct){
   179    feild: (int){ 2 }
   180    field: (int){ int }
   181  }
   182  #Mixed: (string){ string }
   183  Mixed: (string){ string }
   184  mixedRec: (struct){
   185    #Mixed: (string){ string }
   186    Mixed: (string){ string }
   187  }
   188}
   189-- diff/-out/evalalpha<==>+out/eval --
   190diff old new
   191--- old
   192+++ new
   193@@ -1,12 +1,9 @@
   194 Errors:
   195+foo1.recursive.feild: field not allowed:
   196+    ./in.cue:19:3
   197 foo.feild: field not allowed:
   198-    ./in.cue:1:7
   199     ./in.cue:12:6
   200     ./in.cue:13:7
   201-foo1.recursive.feild: field not allowed:
   202-    ./in.cue:3:13
   203-    ./in.cue:15:7
   204-    ./in.cue:19:3
   205 
   206 Result:
   207 (_|_){
   208@@ -23,16 +20,15 @@
   209   }
   210   foo: (_|_){
   211     // [eval]
   212-    field: (int){ int }
   213-    recursive: (#struct){
   214-      field: (string){ string }
   215-    }
   216     feild: (_|_){
   217       // [eval] foo.feild: field not allowed:
   218-      //     ./in.cue:1:7
   219       //     ./in.cue:12:6
   220       //     ./in.cue:13:7
   221     }
   222+    field: (int){ int }
   223+    recursive: (#struct){
   224+      field: (string){ string }
   225+    }
   226   }
   227   foo1: (_|_){
   228     // [eval]
   229@@ -39,13 +35,11 @@
   230     field: (int){ 2 }
   231     recursive: (_|_){
   232       // [eval]
   233-      field: (string){ string }
   234       feild: (_|_){
   235         // [eval] foo1.recursive.feild: field not allowed:
   236-        //     ./in.cue:3:13
   237-        //     ./in.cue:15:7
   238         //     ./in.cue:19:3
   239       }
   240+      field: (string){ string }
   241     }
   242   }
   243   #Bar: (#struct){
   244@@ -52,8 +46,8 @@
   245     field: (int){ int }
   246   }
   247   bar: (#struct){
   248-    field: (int){ int }
   249     feild: (int){ 2 }
   250+    field: (int){ int }
   251   }
   252   #Mixed: (string){ string }
   253   Mixed: (string){ string }
   254-- diff/todo/p2 --
   255Positions / reordering.
   256-- out/eval --
   257Errors:
   258foo.feild: field not allowed:
   259    ./in.cue:1:7
   260    ./in.cue:12:6
   261    ./in.cue:13:7
   262foo1.recursive.feild: field not allowed:
   263    ./in.cue:3:13
   264    ./in.cue:15:7
   265    ./in.cue:19:3
   266
   267Result:
   268(_|_){
   269  // [eval]
   270  #Foo: (#struct){
   271    field: (int){ int }
   272    recursive: (#struct){
   273      field: (string){ string }
   274    }
   275  }
   276  #Foo1: (#struct){
   277    field: (int){ int }
   278    field2: (string){ string }
   279  }
   280  foo: (_|_){
   281    // [eval]
   282    field: (int){ int }
   283    recursive: (#struct){
   284      field: (string){ string }
   285    }
   286    feild: (_|_){
   287      // [eval] foo.feild: field not allowed:
   288      //     ./in.cue:1:7
   289      //     ./in.cue:12:6
   290      //     ./in.cue:13:7
   291    }
   292  }
   293  foo1: (_|_){
   294    // [eval]
   295    field: (int){ 2 }
   296    recursive: (_|_){
   297      // [eval]
   298      field: (string){ string }
   299      feild: (_|_){
   300        // [eval] foo1.recursive.feild: field not allowed:
   301        //     ./in.cue:3:13
   302        //     ./in.cue:15:7
   303        //     ./in.cue:19:3
   304      }
   305    }
   306  }
   307  #Bar: (#struct){
   308    field: (int){ int }
   309  }
   310  bar: (#struct){
   311    field: (int){ int }
   312    feild: (int){ 2 }
   313  }
   314  #Mixed: (string){ string }
   315  Mixed: (string){ string }
   316  mixedRec: (struct){
   317    #Mixed: (string){ string }
   318    Mixed: (string){ string }
   319  }
   320}

View as plain text