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