Improve test cases for plain list ownership.

This commit is contained in:
Tom Alexander 2023-08-19 00:59:45 -04:00
parent 4cd3697fb0
commit 5db6cd617e
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -21,108 +21,110 @@ This table is just showing ownership for the plain list items, not the containin
| baz | Yes |
| lorem | No |
** Analysis
This seems to imply that plain list items own their trailing blank lines except for the final plain list item in the top-most plain list which does not own its trailing blank lines.
In this test case, we see that the only list item that doesn't own its trailing blank lines is "lorem", the final list item of the outer-most list.
* Test 2
We add "cat" as a paragraph at the end of foo which makes "baz" lose its trailing blank lines.
** Source
#+begin_src org
1. foo
bar
1. bar
1. baz
2. baz
lorem
cat
ipsum
2. lorem
dolar
ipsum
#+end_src
** Ownership
This table is just showing ownership for the plain list items, not the containing plain list nor the elements inside each item.
| Plain List *Item* | Owns trailing blank lines |
|--------------------------+---------------------------|
| foo -> ipsum (inclusive) | No |
| baz lorem | No |
| Plain List *Item* | Owns trailing blank lines |
|-------------------------------+---------------------------|
| foo -> cat (includes bar baz) | Yes |
| bar | Yes |
| baz | No |
| lorem | No |
** Analysis
This shows that the final plain list item in a nested plain list (baz lorem) does not own its trailing blank lines which conflicts with "baz" from Test 1.
In isolation, this implies that the final plain list item does not own its trailing blank lines, which conflicts with "baz" from test 1.
New theory: List items own their trailing blank lines unless they are both the final list item and not the final element of a list item.
| Plain List *Item* | Owns trailing blank lines | Why |
|-------------------------------+---------------------------+-----------------------------------------------------------|
| foo -> cat (includes bar baz) | Yes | Not the final list item |
| bar | Yes | Not the final list item |
| baz | No | Final item of bar->baz and not the final element of "foo" |
| lorem | No | Final item of foo->lorem and not contained in a list item |
* Test 3
So if that theory is true, taking the entire (foo -> lorem) list from test 1 and nesting it inside a list should coerce "lorem" to own its trailing blank lines since it would then be a final list item (of foo -> lorem) and the final element of the new list.
** Source
#+begin_src org
1. foo
1. cat
1. foo
1. bar
1. bar
baz
2. baz
2. lorem
2. lorem
ipsum
#+end_src
** Ownership
| Plain List *Item* | Owns trailing blank lines |
|------------------------+---------------------------|
| foo (includes bar baz) | Yes |
| bar baz | Yes |
| lorem | No |
| Plain List *Item* | Owns trailing blank lines |
|-----------------------------+---------------------------|
| cat (includes foo -> lorem) | No |
| foo (includes bar baz) | Yes |
| bar | Yes |
| baz | Yes |
| lorem | No |
** Analysis
This was to test if having an extra paragraph in the final list item in the nested list changes the behavior. The behavior is consistent with Test 1, so the extra paragraph is not the cause of the discrepancy.
Against expectations, we did not coerce lorem to consume its trailing blank lines. What is different between "baz" and "lorem"? Well, "baz" is contained within "foo" which has a "lorem" after it, whereas "lorem" is contained within "cat" which does not have any list items after it.
New theory: List items own their trailing blank lines unless they are both the final list item and not the final element of a non-final list item.
| Plain List *Item* | Owns trailing blank lines | Why |
|-----------------------------+---------------------------+------------------------------------------------------|
| cat (includes foo -> lorem) | No | Final list item and not contained in a list item |
| foo (includes bar baz) | Yes | Not the final list item |
| bar | Yes | Not the final list item |
| baz | Yes | Final element of non-final list item |
| lorem | No | Final list item and final element of final list item |
* Test 4
So if that theory is true, then we should be able to coerce lorem to consume its trailing blank lines by adding a second item to the cat list.
** Source
#+begin_src org
1. foo
1. cat
1. foo
1. bar
1. bar
2. baz
2. baz
candy
2. lorem
2. lorem
2. dog
ipsum
#+end_src
** Ownership
| Plain List *Item* | Owns trailing blank lines |
|----------------------------------+---------------------------|
| foo (includes bar baz and candy) | Yes |
| bar | Yes |
| baz | No |
| lorem | No |
| Plain List *Item* | Owns trailing blank lines |
|-----------------------------+---------------------------|
| cat (includes foo -> lorem) | Yes |
| foo (includes bar baz) | Yes |
| bar | Yes |
| baz | Yes |
| lorem | Yes |
| dog | No |
** Analysis
This was to test if putting a non-plain-list element at the end of foo changes the ownership of blank lines. baz changed to no longer owning its trailing whitespace.
For the first time our expectations were met!
This seems to imply that list items own their trailing whitespace except for the final item unless that list item is at the end of a list item.
* Test 5
** Source
#+begin_src org
1. foo
1. bar
2. baz
candy
2. lorem
1. cat
2. dog
ipsum
#+end_src
** Ownership
| Plain List *Item* | Owns trailing blank lines |
|----------------------------------+---------------------------|
| foo (includes bar baz and candy) | Yes |
| bar | Yes |
| baz | No |
| lorem (includes cat and dog) | No |
| cat | Yes |
| dog | No |
** Analysis
This breaks the theory that the final list item nested at the end of a list item gets to own its trailing blank lines since dog does not own its blank lines despite Test 1's baz owning its blank lines.
New Theory: final list items only own their blank lines if they are nested at the end of a non-final list item.
Enduring theory: List items own their trailing blank lines unless they are both the final list item and not the final element of a non-final list item.
| Plain List *Item* | Owns trailing blank lines | Why |
|-----------------------------+---------------------------+--------------------------------------------------|
| cat (includes foo -> lorem) | Yes | Not the final list item |
| foo (includes bar baz) | Yes | Not the final list item |
| bar | Yes | Not the final list item |
| baz | Yes | Final element of non-final list item |
| lorem | Yes | Final element of non-final list item |
| dog | No | Final list item and not contained in a list item |