cuelang.org/go@v0.13.0/cue/testdata/builtins/056_issue314.txtar (about)

     1  #name: issue314
     2  #evalFull
     3  -- in.cue --
     4  import (
     5  	"text/template"
     6  	"encoding/yaml"
     7  	"encoding/json"
     8  )
     9  
    10  x: {
    11  	s: "myname"
    12  	#T
    13  }
    14  
    15  #T: {
    16  	s:   string
    17  	out: template.Execute("{{.s}}", {
    18  		"s": s
    19  	})
    20  }
    21  
    22  #V: {
    23  	s:   string
    24  	out: json.Marshal({"s": s})
    25  }
    26  
    27  #U: {
    28  	s:   string
    29  	out: yaml.Marshal({"s": s})
    30  }
    31  -- out/def --
    32  import (
    33  	"encoding/json"
    34  	"encoding/yaml"
    35  	"text/template"
    36  )
    37  
    38  x: {
    39  	s: "myname"
    40  	#T
    41  }
    42  #T: {
    43  	s: string
    44  	S = s
    45  	out: template.Execute("{{.s}}", {
    46  		s: S
    47  	})
    48  }
    49  #V: {
    50  	s: string
    51  	S658221 = s
    52  	out: json.Marshal({
    53  		s: S658221
    54  	})
    55  }
    56  #U: {
    57  	s: string
    58  	S629a0f = s
    59  	out: yaml.Marshal({
    60  		s: S629a0f
    61  	})
    62  }
    63  -- out/export --
    64  x: {
    65  	s:   "myname"
    66  	out: "myname"
    67  }
    68  -- out/yaml --
    69  x:
    70    s: myname
    71    out: myname
    72  -- out/json --
    73  {"x":{"s":"myname","out":"myname"}}
    74  -- out/legacy-debug --
    75  <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})}}
    76  -- out/evalalpha/stats --
    77  Leaks:  21
    78  Freed:  0
    79  Reused: 0
    80  Allocs: 21
    81  Retain: 0
    82  
    83  Unifications: 21
    84  Conjuncts:    24
    85  Disjuncts:    0
    86  
    87  CloseIDElems: 21
    88  NumCloseIDs: 4
    89  -- diff/-out/evalalpha/stats<==>+out/eval/stats --
    90  diff old new
    91  --- old
    92  +++ new
    93  @@ -1,9 +1,12 @@
    94  -Leaks:  0
    95  -Freed:  45
    96  -Reused: 39
    97  -Allocs: 6
    98  -Retain: 17
    99  -
   100  -Unifications: 45
   101  -Conjuncts:    77
   102  -Disjuncts:    62
   103  +Leaks:  21
   104  +Freed:  0
   105  +Reused: 0
   106  +Allocs: 21
   107  +Retain: 0
   108  +
   109  +Unifications: 21
   110  +Conjuncts:    24
   111  +Disjuncts:    0
   112  +
   113  +CloseIDElems: 21
   114  +NumCloseIDs: 4
   115  -- out/eval/stats --
   116  Leaks:  0
   117  Freed:  45
   118  Reused: 39
   119  Allocs: 6
   120  Retain: 17
   121  
   122  Unifications: 45
   123  Conjuncts:    77
   124  Disjuncts:    62
   125  -- out/evalalpha --
   126  (struct){
   127    x: (#struct){
   128      s: (string){ "myname" }
   129      out: (string){ "myname" }
   130    }
   131    #T: (#struct){
   132      s: (string){ string }
   133      out: (_|_){
   134        // [incomplete] #T.out: error in call to text/template.Execute: cannot convert non-concrete value string:
   135        //     ./in.cue:14:7
   136        //     ./in.cue:13:2
   137      }
   138    }
   139    #V: (#struct){
   140      s: (string){ string }
   141      out: (_|_){
   142        // [incomplete] cannot convert incomplete value "string" to JSON:
   143        //     ./in.cue:20:7
   144      }
   145    }
   146    #U: (#struct){
   147      s: (string){ string }
   148      out: (_|_){
   149        // [incomplete] #U.out: error in call to encoding/yaml.Marshal: incomplete value string:
   150        //     ./in.cue:26:7
   151        //     ./in.cue:25:7
   152      }
   153    }
   154  }
   155  -- diff/-out/evalalpha<==>+out/eval --
   156  diff old new
   157  --- old
   158  +++ new
   159  @@ -8,7 +8,7 @@
   160       out: (_|_){
   161         // [incomplete] #T.out: error in call to text/template.Execute: cannot convert non-concrete value string:
   162         //     ./in.cue:14:7
   163  -      //     ./in.cue:15:3
   164  +      //     ./in.cue:13:2
   165       }
   166     }
   167     #V: (#struct){
   168  -- out/eval --
   169  (struct){
   170    x: (#struct){
   171      s: (string){ "myname" }
   172      out: (string){ "myname" }
   173    }
   174    #T: (#struct){
   175      s: (string){ string }
   176      out: (_|_){
   177        // [incomplete] #T.out: error in call to text/template.Execute: cannot convert non-concrete value string:
   178        //     ./in.cue:14:7
   179        //     ./in.cue:15:3
   180      }
   181    }
   182    #V: (#struct){
   183      s: (string){ string }
   184      out: (_|_){
   185        // [incomplete] cannot convert incomplete value "string" to JSON:
   186        //     ./in.cue:20:7
   187      }
   188    }
   189    #U: (#struct){
   190      s: (string){ string }
   191      out: (_|_){
   192        // [incomplete] #U.out: error in call to encoding/yaml.Marshal: incomplete value string:
   193        //     ./in.cue:26:7
   194        //     ./in.cue:25:7
   195      }
   196    }
   197  }
   198  -- out/compile --
   199  --- in.cue
   200  {
   201    x: {
   202      s: "myname"
   203      〈1;#T〉
   204    }
   205    #T: {
   206      s: string
   207      out: 〈import;"text/template"〉.Execute("{{.s}}", {
   208        s: 〈1;s〉
   209      })
   210    }
   211    #V: {
   212      s: string
   213      out: 〈import;"encoding/json"〉.Marshal({
   214        s: 〈1;s〉
   215      })
   216    }
   217    #U: {
   218      s: string
   219      out: 〈import;"encoding/yaml"〉.Marshal({
   220        s: 〈1;s〉
   221      })
   222    }
   223  }