...

Text file src/cuelang.org/go/cue/testdata/eval/conjuncts.txtar

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

     1// These tests are related to issue 2351.
     2
     3-- in.cue --
     4
     5conjunct: t1: {
     6	#early: *"X" | string
     7	#early
     8} & {
     9	#early: *"X" | string
    10	string
    11}
    12
    13conjunct: t2: {
    14	#early: *"X" | string
    15	#early
    16}
    17conjunct: t2: {
    18	#early: *"X" | string
    19	string
    20}
    21
    22// TODO: fix this test
    23conjunct: t3: conjunct.t1 & conjunct.t2
    24
    25handleComprehensions: {
    26	if false {
    27		subs: #sub2 & 2
    28	}
    29	#sub2: 2
    30}
    31
    32-- issue2351.cue --
    33issue2351: let: {
    34	let _param = "foo"
    35	({
    36		param: _param & [{}]
    37		gen: [for p in param {p}]
    38	}).gen
    39}
    40
    41issue2351: hidden: {
    42	_in1: ["foo"]
    43	{
    44		in2: _in1
    45		out: [for x in in2 {x}]
    46	}.out
    47}
    48
    49-- issue2355.cue --
    50issue2355: {
    51	#GetF1: {
    52		in:  _
    53		out: in.f1
    54	}
    55
    56	#PutOut1: {
    57		in: _
    58		out: out1: "\(in)"
    59	}
    60
    61	export: {
    62		let data = {f1: "foo"}
    63		(#PutOut1 & {
    64			in: (#GetF1 & {
    65				in: data
    66			}).out
    67		}).out
    68	}
    69}
    70
    71-- out/eval/stats --
    72Leaks:  9
    73Freed:  68
    74Reused: 59
    75Allocs: 18
    76Retain: 22
    77
    78Unifications: 45
    79Conjuncts:    135
    80Disjuncts:    86
    81-- out/eval --
    82Errors:
    83issue2351.let.param: conflicting values "foo" and [{}] (mismatched types string and list):
    84    ./issue2351.cue:2:15
    85    ./issue2351.cue:3:2
    86    ./issue2351.cue:4:19
    87
    88Result:
    89(_|_){
    90  // [eval]
    91  conjunct: (struct){
    92    t1: (string){ |(*(string){
    93        "X"
    94        #early: (string){ |(*(string){ "X" }, (string){ string }) }
    95      }, (string){
    96        string
    97        #early: (string){ |(*(string){ "X" }, (string){ string }) }
    98      }) }
    99    t2: (string){ |(*(string){
   100        "X"
   101        #early: (string){ |(*(string){ "X" }, (string){ string }) }
   102      }, (string){
   103        string
   104        #early: (string){ |(*(string){ "X" }, (string){ string }) }
   105      }) }
   106    t3: (_|_){
   107      // [incomplete] conjunct.t3: 2 errors in empty disjunction:
   108      // conjunct.t3: cannot add field #early: was already used:
   109      //     ./in.cue:6:2
   110      // conjunct.t3: cannot add field #early: was already used:
   111      //     ./in.cue:15:2
   112      #early: (string){ |(*(string){ "X" }, (string){ string }) }
   113    }
   114  }
   115  handleComprehensions: (struct){
   116    #sub2: (int){ 2 }
   117  }
   118  issue2351: (_|_){
   119    // [eval]
   120    let: (_|_){
   121      // [eval] issue2351.let.param: conflicting values "foo" and [{}] (mismatched types string and list):
   122      //     ./issue2351.cue:2:15
   123      //     ./issue2351.cue:3:2
   124      //     ./issue2351.cue:4:19
   125      let _param#1 = (string){ "foo" }
   126    }
   127    hidden: (#list){
   128      _in1: (#list){
   129        0: (string){ "foo" }
   130      }
   131      0: (string){ "foo" }
   132    }
   133  }
   134  issue2355: (struct){
   135    #GetF1: (#struct){
   136      in: (_){ _ }
   137      out: (_|_){
   138        // [incomplete] issue2355.#GetF1.out: in.f1 undefined as in is incomplete (type _):
   139        //     ./issue2355.cue:4:8
   140      }
   141    }
   142    #PutOut1: (#struct){
   143      in: (_){ _ }
   144      out: (#struct){
   145        out1: (_|_){
   146          // [incomplete] issue2355.#PutOut1.out.out1: invalid interpolation: non-concrete value _ (type _):
   147          //     ./issue2355.cue:9:14
   148        }
   149      }
   150    }
   151    export: (struct){
   152      let data#2 = (struct){
   153        f1: (string){ "foo" }
   154      }
   155      out1: (string){ "foo" }
   156    }
   157  }
   158}
   159-- out/compile --
   160--- in.cue
   161{
   162  conjunct: {
   163    t1: ({
   164      #early: (*"X"|string)
   165      〈0;#early〉
   166    } & {
   167      #early: (*"X"|string)
   168      string
   169    })
   170  }
   171  conjunct: {
   172    t2: {
   173      #early: (*"X"|string)
   174      〈0;#early〉
   175    }
   176  }
   177  conjunct: {
   178    t2: {
   179      #early: (*"X"|string)
   180      string
   181    }
   182  }
   183  conjunct: {
   184    t3: (〈1;conjunct〉.t1 & 〈1;conjunct〉.t2)
   185  }
   186  handleComprehensions: {
   187    if false {
   188      subs: (〈1;#sub2〉 & 2)
   189    }
   190    #sub2: 2
   191  }
   192}
   193--- issue2351.cue
   194{
   195  issue2351: {
   196    let: {
   197      let _param#1 = "foo"
   198      {
   199        param: (〈1;let _param#1〉 & [
   200          {},
   201        ])
   202        gen: [
   203          for _, p in 〈1;param〉 {
   204            〈1;p〉
   205          },
   206        ]
   207      }.gen
   208    }
   209  }
   210  issue2351: {
   211    hidden: {
   212      _in1: [
   213        "foo",
   214      ]
   215      {
   216        in2: 〈1;_in1〉
   217        out: [
   218          for _, x in 〈1;in2〉 {
   219            〈1;x〉
   220          },
   221        ]
   222      }.out
   223    }
   224  }
   225}
   226--- issue2355.cue
   227{
   228  issue2355: {
   229    #GetF1: {
   230      in: _
   231      out: 〈0;in〉.f1
   232    }
   233    #PutOut1: {
   234      in: _
   235      out: {
   236        out1: "\(〈1;in〉)"
   237      }
   238    }
   239    export: {
   240      let data#2 = {
   241        f1: "foo"
   242      }
   243      (〈1;#PutOut1〉 & {
   244        in: (〈2;#GetF1〉 & {
   245          in: 〈2;let data#2〉
   246        }).out
   247      }).out
   248    }
   249  }
   250}

View as plain text