# Tests that builtin encoding/template functions (text/template.Execute,
# encoding/json.Marshal, encoding/yaml.Marshal) correctly produce [incomplete]
# errors rather than panicking when called with abstract (non-concrete) values.
# https://cuelang.org/issue/314
-- in.cue --
import (
	"text/template"
	"encoding/yaml"
	"encoding/json"
)

x: {
	s: "myname"
	#T
}

#T: {
	s: string
	out: template.Execute("{{.s}}", {
		"s": s
	})
}

#V: {
	s: string
	out: json.Marshal({"s": s})
}

#U: {
	s: string
	out: yaml.Marshal({"s": s})
}
-- out/compile --
--- in.cue
{
  x: {
    s: "myname"
    〈1;#T〉
  }
  #T: {
    s: string
    out: 〈import;"text/template"〉.Execute("{{.s}}", {
      s: 〈1;s〉
    })
  }
  #V: {
    s: string
    out: 〈import;"encoding/json"〉.Marshal({
      s: 〈1;s〉
    })
  }
  #U: {
    s: string
    out: 〈import;"encoding/yaml"〉.Marshal({
      s: 〈1;s〉
    })
  }
}
