#! /bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

#
# Test file for the POSIX phrase:
# "Commands that store text into buffers shall store the text into the
# unnamed buffer as well as any specified buffer."
#
# Was https://github.com/martinwguy/xvi/issues/123
#

source scripts/term
start_vi

# Tests begin

test 100 "aone\rtwo\rthree[esc]2G"	2 0 [list "one" "two" "three" "~"]

# Yank into a named buffer when the default buffer is empty,
# and check that it's in the default buffer too.
test 101 "1G\"ayyGp"			4 0 [list "one" "two" "three" "one" "~"]

# The same test for "copy".
# The default yank buffer already contains "one" and this yanks "two",
# so this also tests yanking into a non-empty default buffer.
test 102 "1GdGaone\rtwo\rthree[esc]2G"	2 0 [list "one" "two" "three" "~"]
test 103 "yyk:t$\rp"			5 0 [list "one" "two" "three" "one" "two" "~"]

# When appending to a named buffer, the whole result should end up in the
# default buffer.
test 104 "1GdGaone two\rthree four\rabcd[esc]1G" \
				1 0 [list "one two" "three four" "abcd"]
# Check it's yanked the two-line fragment into the default buffer as well
test 105 "4l\"ay/ f\rGlp"	3 2 [list "one two" "three four" "abtwo" "threecd"]
# Restore test pattern and yank "abcd" into the default buffer to dirty it,
# then append "four" to the existing contents of buffer a (two\rthree)
# The default buffer should get the whole new contents of buffer a.
test 106 "1GdGaone two\rthree four\rabcd[esc]0yy" \
				3 0 [list "one two" "three four" "abcd"]
test 107 "2G6l\"Ay\$Glp"	3 2 [list "one two" "three four" "abtwo" "three" "fourcd"]

stop_vi

exit 0

