#
#  PRE: update
#

# Define initial test strings
update control {
	Filter-Id := 'foo'
	Filter-Id += 'baz'
}

# Reset the request list and add the test strings
# FIXME:
# Temporary way to add multiple copies of an attribute - this should become
# Filter-Id += control.Filter-Id when multi copies of attributes
# are copied again.  Currently the desired syntax won't work due to tmpl_t only holding
# a single value_box - so when mapt_to_list_mod() builds the list of value for the rhs
# of the expression only the first one is copied to the tmpl_t.  See around line 780
# of map_async.c
update {
	Filter-Id !* ANY
	Filter-Id += control.Filter-Id[0]
	Filter-Id += control.Filter-Id[1]
}

# Prepend a single value
update request {
	Filter-Id ^= 'boink'
}

# The prepended value should be first followed by the other two
if (!((Filter-Id[0] == 'boink')) || (!(Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz'))) {
	test_fail
}

if (!(%{Filter-Id[#]} == 3)) {
	test_fail
}

# Add an extra element to the start of control
update control {
	Filter-Id ^= 'wibble'
}

# Prepend control to request
update {
	request ^= control
}

# The attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz"
if (!((Filter-Id[0] == 'wibble')) || (!(Filter-Id[1] == 'foo')) || (!(%{Filter-Id[2]} == 'baz')) || (!(Filter-Id[3] == 'boink')) || (!(Filter-Id[4] == 'foo')) || (!(Filter-Id[5] == 'baz'))) {
	test_fail
}

if (!(%{Filter-Id[#]} == 6)) {
	test_fail
}

# Set up an attribute in control with a single value
update control {
	Filter-Id := 'initial'
}

# Prepend the list of Filter-Id from request to the new attribute
#update {
#	control.Filter-Id ^= Filter-Id
#}

# (Temporary method to achieve the same - as per issue noted above)
update {
	control ^= request
}

# The control attributes should now be "wibble", "foo", "baz", "boink", "foo", "baz", "initial"
if (!((control.Filter-Id[0] == 'wibble')) || (!(control.Filter-Id[1] == 'foo')) || (!(control.Filter-Id[2] == 'baz')) || (!(control.Filter-Id[3] == 'boink')) || (!(control.Filter-Id[4] == 'foo')) || (!(control.Filter-Id[5] == 'baz')) || (!(control.Filter-Id[6] == 'initial'))) {
	test_fail
}

if (!(%{control.Filter-Id[#]} == 7)) {
	test_fail
}


success
