github.com/solo-io/cue@v0.4.7/cue/testdata/resolve/048_builtins.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: builtins
     4  #evalPartial
     5  -- in.cue --
     6  import (
     7    "list"
     8    "strings"
     9  )
    10  
    11  a1: {
    12  	a: and([b, c])
    13  	b: =~"oo"
    14  	c: =~"fo"
    15  }
    16  a2: a1 & {a: "foo"}
    17  a3: a1 & {a: "bar"}
    18  
    19  o1: {
    20  	a: or([b, c])
    21  	b: string
    22  	c: "bar"
    23  }
    24  o2: o1 & {a: "foo"}
    25  o3: o1 & {a: "foo", b: "baz"}
    26  
    27  // Issue #585
    28  stringListErrors: {
    29      a: {
    30          x: [string, ...string]
    31          result: strings.Join(x, " ")
    32      }
    33  
    34      b: {
    35          x: [int, ...string]
    36          result: strings.Join(x, " ")
    37      }
    38  
    39      c: {
    40          x: []
    41          result: strings.Join(x, int)
    42      }
    43  }
    44  
    45  decimalListErrors: {
    46      a: {
    47          x: [string]
    48          result: list.Avg(x)
    49      }
    50  
    51      b: {
    52          x: [int, ...string]
    53          result: list.Avg(x)
    54      }
    55  }
    56  
    57  -- out/def --
    58  a1: {
    59  	a: =~"oo" & =~"fo"
    60  	b: =~"oo"
    61  	c: =~"fo"
    62  }
    63  a2: a1 & {
    64  	a: "foo"
    65  }
    66  a3: a1 & {
    67  	a: "bar"
    68  }
    69  o1: {
    70  	a: string
    71  	b: string
    72  	c: "bar"
    73  }
    74  o2: o1 & {
    75  	a: "foo"
    76  }
    77  o3: o1 & {
    78  	a: "foo"
    79  	b: "baz"
    80  }
    81  -- out/legacy-debug --
    82  <0>{a1: <1>{a: (=~"oo" & =~"fo"), b: =~"oo", c: =~"fo"}, a2: <2>{a: "foo", b: =~"oo", c: =~"fo"}, a3: <3>{a: _|_((=~"oo" & "bar"):invalid value "bar" (does not match =~"oo")), b: =~"oo", c: =~"fo"}, o1: <4>{a: string, b: string, c: "bar"}, o2: <5>{a: "foo", b: string, c: "bar"}, o3: <6>{a: _|_(("baz" & "foo"):empty disjunction: conflicting values "baz" and "foo";("bar" & "foo"):empty disjunction: conflicting values "bar" and "foo"), b: "baz", c: "bar"}}
    83  -- out/eval --
    84  Errors:
    85  o3.a: 2 errors in empty disjunction:
    86  o3.a: conflicting values "bar" and "foo":
    87      ./in.cue:15:12
    88      ./in.cue:17:5
    89      ./in.cue:20:5
    90      ./in.cue:20:14
    91  o3.a: conflicting values "baz" and "foo":
    92      ./in.cue:15:9
    93      ./in.cue:20:5
    94      ./in.cue:20:14
    95      ./in.cue:20:24
    96  a3.a: invalid value "bar" (out of bound =~"oo"):
    97      ./in.cue:8:5
    98      ./in.cue:12:14
    99  a3.a: invalid value "bar" (out of bound =~"fo"):
   100      ./in.cue:9:5
   101      ./in.cue:12:14
   102  stringListErrors.b.result: invalid list element 0 in argument 0 to call: cannot use value int (int) as string:
   103      ./in.cue:31:17
   104      ./in.cue:30:13
   105  stringListErrors.c.result: cannot use int (type int) as string in argument 2 to strings.Join:
   106      ./in.cue:36:33
   107  decimalListErrors.a.result: invalid list element 0 in argument 0 to call: cannot use value string (string) as number:
   108      ./in.cue:43:17
   109      ./in.cue:42:13
   110  
   111  Result:
   112  (_|_){
   113    // [eval]
   114    a1: (struct){
   115      a: (string){ &(=~"oo", =~"fo") }
   116      b: (string){ =~"oo" }
   117      c: (string){ =~"fo" }
   118    }
   119    a2: (struct){
   120      a: (string){ "foo" }
   121      b: (string){ =~"oo" }
   122      c: (string){ =~"fo" }
   123    }
   124    a3: (_|_){
   125      // [eval]
   126      a: (_|_){
   127        // [eval] a3.a: invalid value "bar" (out of bound =~"oo"):
   128        //     ./in.cue:8:5
   129        //     ./in.cue:12:14
   130        // a3.a: invalid value "bar" (out of bound =~"fo"):
   131        //     ./in.cue:9:5
   132        //     ./in.cue:12:14
   133      }
   134      b: (string){ =~"oo" }
   135      c: (string){ =~"fo" }
   136    }
   137    o1: (struct){
   138      a: (string){ |((string){ string }, (string){ "bar" }) }
   139      b: (string){ string }
   140      c: (string){ "bar" }
   141    }
   142    o2: (struct){
   143      a: (string){ "foo" }
   144      b: (string){ string }
   145      c: (string){ "bar" }
   146    }
   147    o3: (_|_){
   148      // [eval]
   149      a: (_|_){
   150        // [eval] o3.a: 2 errors in empty disjunction:
   151        // o3.a: conflicting values "bar" and "foo":
   152        //     ./in.cue:15:12
   153        //     ./in.cue:17:5
   154        //     ./in.cue:20:5
   155        //     ./in.cue:20:14
   156        // o3.a: conflicting values "baz" and "foo":
   157        //     ./in.cue:15:9
   158        //     ./in.cue:20:5
   159        //     ./in.cue:20:14
   160        //     ./in.cue:20:24
   161      }
   162      b: (string){ "baz" }
   163      c: (string){ "bar" }
   164    }
   165    stringListErrors: (_|_){
   166      // [eval]
   167      a: (struct){
   168        x: (list){
   169          0: (string){ string }
   170        }
   171        result: (_|_){
   172          // [incomplete] stringListErrors.a.result: non-concrete value string for element 0 of string list argument 0:
   173          //     ./in.cue:26:17
   174          //     ./in.cue:25:13
   175        }
   176      }
   177      b: (_|_){
   178        // [eval]
   179        x: (list){
   180          0: (int){ int }
   181        }
   182        result: (_|_){
   183          // [eval] stringListErrors.b.result: invalid list element 0 in argument 0 to call: cannot use value int (int) as string:
   184          //     ./in.cue:31:17
   185          //     ./in.cue:30:13
   186        }
   187      }
   188      c: (_|_){
   189        // [eval]
   190        x: (#list){
   191        }
   192        result: (_|_){
   193          // [eval] stringListErrors.c.result: cannot use int (type int) as string in argument 2 to strings.Join:
   194          //     ./in.cue:36:33
   195        }
   196      }
   197    }
   198    decimalListErrors: (_|_){
   199      // [eval]
   200      a: (_|_){
   201        // [eval]
   202        x: (#list){
   203          0: (string){ string }
   204        }
   205        result: (_|_){
   206          // [eval] decimalListErrors.a.result: invalid list element 0 in argument 0 to call: cannot use value string (string) as number:
   207          //     ./in.cue:43:17
   208          //     ./in.cue:42:13
   209        }
   210      }
   211      b: (struct){
   212        x: (list){
   213          0: (int){ int }
   214        }
   215        result: (_|_){
   216          // [incomplete] decimalListErrors.b.result: non-concrete value int for element 0 of number list argument 0:
   217          //     ./in.cue:48:17
   218          //     ./in.cue:47:13
   219        }
   220      }
   221    }
   222  }
   223  -- out/compile --
   224  --- in.cue
   225  {
   226    a1: {
   227      a: and([
   228        〈0;b〉,
   229        〈0;c〉,
   230      ])
   231      b: =~"oo"
   232      c: =~"fo"
   233    }
   234    a2: (〈0;a1〉 & {
   235      a: "foo"
   236    })
   237    a3: (〈0;a1〉 & {
   238      a: "bar"
   239    })
   240    o1: {
   241      a: or([
   242        〈0;b〉,
   243        〈0;c〉,
   244      ])
   245      b: string
   246      c: "bar"
   247    }
   248    o2: (〈0;o1〉 & {
   249      a: "foo"
   250    })
   251    o3: (〈0;o1〉 & {
   252      a: "foo"
   253      b: "baz"
   254    })
   255    stringListErrors: {
   256      a: {
   257        x: [
   258          string,
   259          ...string,
   260        ]
   261        result: 〈import;strings〉.Join(〈0;x〉, " ")
   262      }
   263      b: {
   264        x: [
   265          int,
   266          ...string,
   267        ]
   268        result: 〈import;strings〉.Join(〈0;x〉, " ")
   269      }
   270      c: {
   271        x: []
   272        result: 〈import;strings〉.Join(〈0;x〉, int)
   273      }
   274    }
   275    decimalListErrors: {
   276      a: {
   277        x: [
   278          string,
   279        ]
   280        result: 〈import;list〉.Avg(〈0;x〉)
   281      }
   282      b: {
   283        x: [
   284          int,
   285          ...string,
   286        ]
   287        result: 〈import;list〉.Avg(〈0;x〉)
   288      }
   289    }
   290  }