#  test concatenation under various circumstances

resource concat()

	string[23] s1, s2, s3, s4
	char  c9[1:9] 

	# constant operands, string and char results, various tree shapes
	s1 = "ab" || "cde"
	s2 = "fgh" || "ij" || "" || "klmn" || "*"
	s3 = ("ab" || "cd") || ("ef" || "gh")
	s4 = ("a" || 'b' || "c") || ('d' || "e" || "f") || ("g" || "h" || 'i')
	c9 = chars("fgh" || "ij" || "klmn")
	write (s1, s2, s3, s4, c9)

	# string exprs as initializers
	string[5] s5 = "oz" || "one"
	string[4] s6 = s5[2:*]
	string[4] s7 = s4[3:6]
	write (length(s5), maxlength(s5), s5,
		length(s6), maxlength(s6), s6,
		length(s7), maxlength(s7), s7)

	# initialize a bunch of variables
	char  a[1:1] = ([1] 'a')
	string[3] b = "b"
	char  c = 'c'
	string[1] d = "d"
	char  e = 'e'
	string[4] f = "f"
	char  g[1:1] = chars("g")
	string[2] h = "h"
	char  i[1:1] = chars("i")
	char  tuv[1:3] = chars("tuv")
	char  wxyz[1:4] = chars("wxyz")
	string[17] empty = ""

	# variable operands
	s1 = string(tuv) || string(wxyz)
	s2 = e || s1 || empty || string(i)
	s3 = (string(tuv) || string(wxyz)[2:3]) || (string(g) || h)
	s4 = (string(a) || b || c)
	    || (d || e || f) || (string(g) || h || string(i))
	c9 = chars (string(wxyz) || empty || string(a) || b || c || d || e)
	write (s1, s2, s3, s4, c9)

	# result overlaps operands
	s1 = "s"
	s1 = string(wxyz) || s1
	s2 = string(a) || b || (c || s2 || d) || e
	s3 = string(a) || s3[3:5]
	s4 = string(g) || s4[1:2]
	c9 = chars(string(tuv) || string(c9[2:7]))
	write (s1, s2, s3, s4, c9)

	# result used in something other than variable assignment
	put (string(a) || b || c || d || e || " ")
	write (string(tuv) || string(wxyz),
		length(string(tuv)||string(wxyz)),
		maxlength(string(tuv) || string(wxyz)))
	# concatenate string literals
	write ("abcd"||"efg", (""||"h")||"i", "jk"||"lmnop")

	# augmented concatenation
	s1 = "zyx"
	s1 ||= "wv" || "uts"
	s1 ||= 'r'
	s1 ||= char(81)        # 'Q'
	s1 ||= s1
	write (s1)
end
