github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/resolve/011_bounds.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: bounds
     4  #evalPartial
     5  -- in.cue --
     6  i1: >1 & 5
     7  i2: (>=0 & <=10) & 5
     8  i3: !=null & []
     9  i4: !=2 & !=4
    10  
    11  s1: >=0 & <=10 & !=1  // no simplification
    12  s2: >=0 & <=10 & !=11 // >=0 & <=10
    13  s3: >5 & !=5          // >5
    14  s4: <10 & !=10        // <10
    15  s5: !=2 & !=2
    16  
    17  // TODO: could change inequality
    18  s6: !=2 & >=2
    19  s7: >=2 & !=2
    20  
    21  s8: !=5 & >5
    22  
    23  s10: >=0 & <=10 & <12 & >1 // >1  & <=10
    24  s11: >0 & >=0 & <=12 & <12 // >0  & <12
    25  
    26  s20: >=10 & <=10 // 10
    27  
    28  s22:  >5 & <=6         // no simplification
    29  s22a: >5 & (<=6 & int) // 6
    30  s22b: (int & >5) & <=6 // 6
    31  s22c: >=5 & (<6 & int) // 5
    32  s22d: (int & >=5) & <6 // 5
    33  s22e: (>=5 & <6) & int // 5
    34  s22f: int & (>=5 & <6) // 5
    35  
    36  s23:  >0 & <2         // no simplification
    37  s23a: (>0 & <2) & int // int & 1
    38  s23b: int & (>0 & <2) // int & 1
    39  s23c: (int & >0) & <2 // int & 1
    40  s23d: >0 & (int & <2) // int & 1
    41  s23e: >0.0 & <2.0     // no simplification
    42  
    43  s30: >0 & int
    44  
    45  floats: {
    46  	[string]: float
    47  	f1:       <10.0 & <=5.0
    48  	f2:       <=10.0 & <5.0
    49  	f3:       <1.1 & <=1.1
    50  	f4:       <=1.1 & <=1.1
    51  	f5:       >1.1 & >=1.1
    52  	f6:       >=1.1 & >1.1
    53  	f7:       >=1.1 & <=1.1
    54  
    55  	issue1310: >=2.1 & <=1.0
    56  	fe2:       >2.1 & <=2.1
    57  
    58  	fe3: float & >2 & <=3
    59  }
    60  
    61  e1: null & !=null
    62  e2: !=null & null
    63  e3: >1 & 1
    64  e4: <0 & 0
    65  e5: >1 & <0
    66  e6: >11 & <11
    67  e7: >=11 & <11
    68  e8: >11 & <=11
    69  e9: >"a" & <1
    70  -- out/def --
    71  i1: 5
    72  i2: 5
    73  i3: []
    74  i4: !=2 & !=4
    75  s1: >=0 & <=10 & !=1
    76  s2: >=0 & <=10
    77  s3: >5
    78  s4: <10
    79  s5: !=2
    80  
    81  // TODO: could change inequality
    82  s6:   !=2
    83  s7:   !=2
    84  s8:   >5
    85  s10:  >1 & <=10
    86  s11:  >0 & <12
    87  s20:  10
    88  s22:  >5 & <=6
    89  s22a: 6
    90  s22b: 6
    91  s22c: 5
    92  s22d: 5
    93  s22e: 5
    94  s22f: 5
    95  s23:  >0 & <2
    96  s23a: 1
    97  s23b: 1
    98  s23c: 1
    99  s23d: 1
   100  s23e: >0.0 & <2.0
   101  s30:  >0
   102  e1:   _|_ // invalid value null (excluded by !=null)
   103  e2:   _|_ // invalid value null (excluded by !=null)
   104  e3:   _|_ // invalid value 1 (out of bound >1)
   105  e4:   _|_ // invalid value 0 (out of bound <0)
   106  e5:   _|_ // conflicting bounds >1 and <0
   107  e6:   _|_ // conflicting bounds >11 and <11
   108  e7:   _|_ // conflicting bounds >=11 and <11
   109  e8:   _|_ // conflicting bounds >11 and <=11
   110  e9:   _|_ // conflicting values >"a" and <1 (mismatched types string and number)
   111  -- out/legacy-debug --
   112  <0>{i1: 5, i2: 5, i3: [], i4: (!=2 & !=4), s1: (>=0 & <=10 & !=1), s2: (>=0 & <=10), s3: >5, s4: <10, s5: !=2, s6: (!=2 & >=2), s7: (>=2 & !=2), s8: >5, s10: (<=10 & >1), s11: (>0 & <12), s20: 10, s22: (>5 & <=6), s22a: 6, s22b: 6, s22c: 5, s22d: 5, s22e: 5, s22f: 5, s23: (>0 & <2), s23a: 1, s23b: 1, s23c: 1, s23d: 1, s23e: (>0.0 & <2.0), s30: int & >0, e1: _|_((!=null & null):invalid value null (excluded by !=null)), e2: _|_((!=null & null):invalid value null (excluded by !=null)), e3: _|_((>1 & 1):invalid value 1 (out of bound >1)), e4: _|_((<0 & 0):invalid value 0 (out of bound <0)), e5: _|_(conflicting bounds >1 and <0), e6: _|_(conflicting bounds >11 and <11), e7: _|_(conflicting bounds >=11 and <11), e8: _|_(conflicting bounds >11 and <=11), e9: _|_((>"a" & <1):conflicting values >"a" and <1 (mismatched types string and number))}
   113  -- out/compile --
   114  --- in.cue
   115  {
   116    i1: (>1 & 5)
   117    i2: ((>=0 & <=10) & 5)
   118    i3: (!=null & [])
   119    i4: (!=2 & !=4)
   120    s1: ((>=0 & <=10) & !=1)
   121    s2: ((>=0 & <=10) & !=11)
   122    s3: (>5 & !=5)
   123    s4: (<10 & !=10)
   124    s5: (!=2 & !=2)
   125    s6: (!=2 & >=2)
   126    s7: (>=2 & !=2)
   127    s8: (!=5 & >5)
   128    s10: (((>=0 & <=10) & <12) & >1)
   129    s11: (((>0 & >=0) & <=12) & <12)
   130    s20: (>=10 & <=10)
   131    s22: (>5 & <=6)
   132    s22a: (>5 & (<=6 & int))
   133    s22b: ((int & >5) & <=6)
   134    s22c: (>=5 & (<6 & int))
   135    s22d: ((int & >=5) & <6)
   136    s22e: ((>=5 & <6) & int)
   137    s22f: (int & (>=5 & <6))
   138    s23: (>0 & <2)
   139    s23a: ((>0 & <2) & int)
   140    s23b: (int & (>0 & <2))
   141    s23c: ((int & >0) & <2)
   142    s23d: (>0 & (int & <2))
   143    s23e: (>0.0 & <2.0)
   144    s30: (>0 & int)
   145    floats: {
   146      [string]: float
   147      f1: (<10.0 & <=5.0)
   148      f2: (<=10.0 & <5.0)
   149      f3: (<1.1 & <=1.1)
   150      f4: (<=1.1 & <=1.1)
   151      f5: (>1.1 & >=1.1)
   152      f6: (>=1.1 & >1.1)
   153      f7: (>=1.1 & <=1.1)
   154      issue1310: (>=2.1 & <=1.0)
   155      fe2: (>2.1 & <=2.1)
   156      fe3: ((float & >2) & <=3)
   157    }
   158    e1: (null & !=null)
   159    e2: (!=null & null)
   160    e3: (>1 & 1)
   161    e4: (<0 & 0)
   162    e5: (>1 & <0)
   163    e6: (>11 & <11)
   164    e7: (>=11 & <11)
   165    e8: (>11 & <=11)
   166    e9: (>"a" & <1)
   167  }
   168  -- out/eval --
   169  Errors:
   170  e1: conflicting values null and !=null (mismatched types null and (bool|string|bytes|func|list|struct|number)):
   171      ./in.cue:56:5
   172      ./in.cue:56:12
   173  e2: conflicting values !=null and null (mismatched types (bool|string|bytes|func|list|struct|number) and null):
   174      ./in.cue:57:5
   175      ./in.cue:57:14
   176  e5: incompatible bounds >1 and <0:
   177      ./in.cue:60:5
   178      ./in.cue:60:10
   179  e6: incompatible bounds >11 and <11:
   180      ./in.cue:61:5
   181      ./in.cue:61:11
   182  e7: incompatible bounds >=11 and <11:
   183      ./in.cue:62:5
   184      ./in.cue:62:12
   185  e8: incompatible bounds >11 and <=11:
   186      ./in.cue:63:5
   187      ./in.cue:63:11
   188  e9: conflicting values >"a" and <1 (mismatched types string and number):
   189      ./in.cue:64:5
   190      ./in.cue:64:12
   191  floats.fe2: incompatible bounds >2.1 and <=2.1:
   192      ./in.cue:51:13
   193      ./in.cue:51:20
   194  floats.issue1310: incompatible bounds >=2.1 and <=1.0:
   195      ./in.cue:50:13
   196      ./in.cue:50:21
   197  e3: invalid value 1 (out of bound >1):
   198      ./in.cue:58:5
   199      ./in.cue:58:10
   200  e4: invalid value 0 (out of bound <0):
   201      ./in.cue:59:5
   202      ./in.cue:59:10
   203  
   204  Result:
   205  (_|_){
   206    // [eval]
   207    i1: (int){ 5 }
   208    i2: (int){ 5 }
   209    i3: (#list){
   210    }
   211    i4: (number){ &(!=2, !=4) }
   212    s1: (number){ &(>=0, <=10, !=1) }
   213    s2: (number){ &(>=0, <=10) }
   214    s3: (number){ >5 }
   215    s4: (number){ <10 }
   216    s5: (number){ !=2 }
   217    s6: (number){ &(>=2, !=2) }
   218    s7: (number){ &(>=2, !=2) }
   219    s8: (number){ >5 }
   220    s10: (number){ &(>1, <=10) }
   221    s11: (number){ &(>0, <12) }
   222    s20: (number){ 10 }
   223    s22: (number){ &(>5, <=6) }
   224    s22a: (int){ 6 }
   225    s22b: (int){ 6 }
   226    s22c: (int){ 5 }
   227    s22d: (int){ 5 }
   228    s22e: (int){ 5 }
   229    s22f: (int){ 5 }
   230    s23: (number){ &(>0, <2) }
   231    s23a: (int){ 1 }
   232    s23b: (int){ 1 }
   233    s23c: (int){ 1 }
   234    s23d: (int){ 1 }
   235    s23e: (number){ &(>0.0, <2.0) }
   236    s30: (int){ &(>0, int) }
   237    floats: (_|_){
   238      // [eval]
   239      f1: (float){ &(<=5.0, float) }
   240      f2: (float){ &(<5.0, float) }
   241      f3: (float){ &(<1.1, float) }
   242      f4: (float){ &(<=1.1, float) }
   243      f5: (float){ &(>1.1, float) }
   244      f6: (float){ &(>1.1, float) }
   245      f7: (number){ 1.1 }
   246      issue1310: (_|_){
   247        // [eval] floats.issue1310: incompatible bounds >=2.1 and <=1.0:
   248        //     ./in.cue:50:13
   249        //     ./in.cue:50:21
   250      }
   251      fe2: (_|_){
   252        // [eval] floats.fe2: incompatible bounds >2.1 and <=2.1:
   253        //     ./in.cue:51:13
   254        //     ./in.cue:51:20
   255      }
   256      fe3: (float){ &(>2, <=3, float) }
   257    }
   258    e1: (_|_){
   259      // [eval] e1: conflicting values null and !=null (mismatched types null and (bool|string|bytes|func|list|struct|number)):
   260      //     ./in.cue:56:5
   261      //     ./in.cue:56:12
   262    }
   263    e2: (_|_){
   264      // [eval] e2: conflicting values !=null and null (mismatched types (bool|string|bytes|func|list|struct|number) and null):
   265      //     ./in.cue:57:5
   266      //     ./in.cue:57:14
   267    }
   268    e3: (_|_){
   269      // [eval] e3: invalid value 1 (out of bound >1):
   270      //     ./in.cue:58:5
   271      //     ./in.cue:58:10
   272    }
   273    e4: (_|_){
   274      // [eval] e4: invalid value 0 (out of bound <0):
   275      //     ./in.cue:59:5
   276      //     ./in.cue:59:10
   277    }
   278    e5: (_|_){
   279      // [eval] e5: incompatible bounds >1 and <0:
   280      //     ./in.cue:60:5
   281      //     ./in.cue:60:10
   282    }
   283    e6: (_|_){
   284      // [eval] e6: incompatible bounds >11 and <11:
   285      //     ./in.cue:61:5
   286      //     ./in.cue:61:11
   287    }
   288    e7: (_|_){
   289      // [eval] e7: incompatible bounds >=11 and <11:
   290      //     ./in.cue:62:5
   291      //     ./in.cue:62:12
   292    }
   293    e8: (_|_){
   294      // [eval] e8: incompatible bounds >11 and <=11:
   295      //     ./in.cue:63:5
   296      //     ./in.cue:63:11
   297    }
   298    e9: (_|_){
   299      // [eval] e9: conflicting values >"a" and <1 (mismatched types string and number):
   300      //     ./in.cue:64:5
   301      //     ./in.cue:64:12
   302    }
   303  }