github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/builtins/056_issue314.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: issue314
     4  #evalFull
     5  -- in.cue --
     6  import (
     7  	"text/template"
     8  	"encoding/yaml"
     9  	"encoding/json"
    10  )
    11  
    12  x: {
    13  	s: "myname"
    14  	#T
    15  }
    16  
    17  #T: {
    18  	s:   string
    19  	out: template.Execute("{{.s}}", {
    20  		"s": s
    21  	})
    22  }
    23  
    24  #V: {
    25  	s:   string
    26  	out: json.Marshal({"s": s})
    27  }
    28  
    29  #U: {
    30  	s:   string
    31  	out: yaml.Marshal({"s": s})
    32  }
    33  -- out/def --
    34  import (
    35  	"encoding/json"
    36  	"encoding/yaml"
    37  	"text/template"
    38  )
    39  
    40  x: {
    41  	s: "myname"
    42  	#T
    43  }
    44  #T: {
    45  	s: string
    46  	S = s
    47  	out: template.Execute("{{.s}}", {
    48  		s: S
    49  	})
    50  }
    51  #V: {
    52  	s: string
    53  	S658221 = s
    54  	out: json.Marshal({
    55  		s: S658221
    56  	})
    57  }
    58  #U: {
    59  	s: string
    60  	S629a0f = s
    61  	out: yaml.Marshal({
    62  		s: S629a0f
    63  	})
    64  }
    65  -- out/export --
    66  x: {
    67  	s:   "myname"
    68  	out: "myname"
    69  }
    70  -- out/yaml --
    71  x:
    72    s: myname
    73    out: myname
    74  -- out/json --
    75  {"x":{"s":"myname","out":"myname"}}
    76  -- out/legacy-debug --
    77  <0>{x: <1>C{s: "myname", out: "myname"}, #T: <2>C{s: string, out: <3>.Execute ("{{.s}}",<4>C{s: <5>.s})}, #V: <6>C{s: string, out: <7>.Marshal (<8>C{s: <9>.s})}, #U: <10>C{s: string, out: <11>.Marshal (<12>C{s: <13>.s})}}
    78  -- out/eval --
    79  (struct){
    80    x: (#struct){
    81      s: (string){ "myname" }
    82      out: (string){ "myname" }
    83    }
    84    #T: (#struct){
    85      s: (string){ string }
    86      out: (_|_){
    87        // [incomplete] error in call to text/template.Execute: cannot convert non-concrete value string:
    88        //     ./in.cue:14:7
    89        //     ./in.cue:15:3
    90      }
    91    }
    92    #V: (#struct){
    93      s: (string){ string }
    94      out: (_|_){
    95        // [incomplete] cannot convert incomplete value "string" to JSON:
    96        //     ./in.cue:20:7
    97      }
    98    }
    99    #U: (#struct){
   100      s: (string){ string }
   101      out: (_|_){
   102        // [incomplete] #U.out: incomplete value:
   103        //     ./in.cue:26:7
   104      }
   105    }
   106  }
   107  -- out/compile --
   108  --- in.cue
   109  {
   110    x: {
   111      s: "myname"
   112      〈1;#T〉
   113    }
   114    #T: {
   115      s: string
   116      out: 〈import;"text/template"〉.Execute("{{.s}}", {
   117        s: 〈1;s〉
   118      })
   119    }
   120    #V: {
   121      s: string
   122      out: 〈import;"encoding/json"〉.Marshal({
   123        s: 〈1;s〉
   124      })
   125    }
   126    #U: {
   127      s: string
   128      out: 〈import;"encoding/yaml"〉.Marshal({
   129        s: 〈1;s〉
   130      })
   131    }
   132  }