From 8162f030518a9f2717a0b8ca5dbf180df3b70307 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 20 Aug 2023 16:00:39 -0400 Subject: [PATCH] Put all trailing whitespace ownership test cases into the automated tests. Notes for this investigation moved to https://github.com/tomalexander/org_mode_ast_investigation_tool/blob/cba1d1e988be230f3104f5f63dfaeaaf5cd0d280/notes/plain_list_ownership_notes.org . Mailing list thread on the investigation: https://list.orgmode.org/9372527e-3852-419e-936a-7b4dd38cc847@app.fastmail.com/ . --- build.rs | 4 +- notes/plain_list_ownership_notes.org | 130 ------------------ ...ling_whitespace_ownership_test_case_1.org} | 2 - ...iling_whitespace_ownership_test_case_2.org | 11 ++ ...iling_whitespace_ownership_test_case_3.org | 10 ++ ...iling_whitespace_ownership_test_case_4.org | 12 ++ 6 files changed, 36 insertions(+), 133 deletions(-) delete mode 100644 notes/plain_list_ownership_notes.org rename org_mode_samples/plain_lists/{trailing_whitespace_ownership.org => trailing_whitespace_ownership_test_case_1.org} (95%) create mode 100644 org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_2.org create mode 100644 org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_3.org create mode 100644 org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_4.org diff --git a/build.rs b/build.rs index 68a9b573..5f4a1f2e 100644 --- a/build.rs +++ b/build.rs @@ -75,7 +75,9 @@ fn is_expect_fail(name: &str) -> Option<&str> { "element_container_priority_footnote_definition_dynamic_block" => Some("Apparently broken begin lines become their own paragraph."), "paragraphs_paragraph_with_backslash_line_breaks" => Some("The text we're getting out of the parse tree is already processed to remove line breaks, so our comparison needs to take that into account."), "export_snippet_paragraph_break_precedence" => Some("The latest code for org-mode is matching the export snippet without the closing @@."), // https://list.orgmode.org/orgmode/fb61ea28-f004-4c25-adf7-69fc55683ed4@app.fastmail.com/T/#u - "plain_lists_trailing_whitespace_ownership" => Some("Seeing odd behavior about whitespace ownership."), + "plain_lists_trailing_whitespace_ownership_test_case_1" => Some("Seeing odd behavior about whitespace ownership."), // https://list.orgmode.org/9372527e-3852-419e-936a-7b4dd38cc847@app.fastmail.com/ + "plain_lists_trailing_whitespace_ownership_test_case_3" => Some("Seeing odd behavior about whitespace ownership."), // https://list.orgmode.org/9372527e-3852-419e-936a-7b4dd38cc847@app.fastmail.com/ + "plain_lists_trailing_whitespace_ownership_test_case_4" => Some("Seeing odd behavior about whitespace ownership."), // https://list.orgmode.org/9372527e-3852-419e-936a-7b4dd38cc847@app.fastmail.com/ _ => None, } } diff --git a/notes/plain_list_ownership_notes.org b/notes/plain_list_ownership_notes.org deleted file mode 100644 index 266f9730..00000000 --- a/notes/plain_list_ownership_notes.org +++ /dev/null @@ -1,130 +0,0 @@ -* Test 1 -** Source -#+begin_src org - 1. foo - - 1. bar - - 2. baz - - 2. lorem - - 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 (includes bar baz) | Yes | -| bar | Yes | -| baz | Yes | -| lorem | No | -** Analysis -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 - - 1. bar - - 2. baz - - cat - - 2. lorem - - ipsum -#+end_src -** Ownership -| Plain List *Item* | Owns trailing blank lines | -|-------------------------------+---------------------------| -| foo -> cat (includes bar baz) | Yes | -| bar | Yes | -| baz | No | -| lorem | No | -** Analysis -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. cat - 1. foo - - 1. bar - - 2. baz - - 2. lorem - - ipsum -#+end_src -** Ownership -| Plain List *Item* | Owns trailing blank lines | -|-----------------------------+---------------------------| -| cat (includes foo -> lorem) | No | -| foo (includes bar baz) | Yes | -| bar | Yes | -| baz | Yes | -| lorem | No | -** Analysis -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. cat - 1. foo - - 1. bar - - 2. baz - - 2. lorem - - 2. dog - - ipsum -#+end_src -** Ownership -| 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 -For the first time our expectations were met! - -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 | diff --git a/org_mode_samples/plain_lists/trailing_whitespace_ownership.org b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_1.org similarity index 95% rename from org_mode_samples/plain_lists/trailing_whitespace_ownership.org rename to org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_1.org index a3a4693b..61f90ca2 100644 --- a/org_mode_samples/plain_lists/trailing_whitespace_ownership.org +++ b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_1.org @@ -6,6 +6,4 @@ 2. lorem - - ipsum diff --git a/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_2.org b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_2.org new file mode 100644 index 00000000..b1828355 --- /dev/null +++ b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_2.org @@ -0,0 +1,11 @@ +1. foo + + 1. bar + + 2. baz + + cat + +2. lorem + +ipsum diff --git a/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_3.org b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_3.org new file mode 100644 index 00000000..83abac29 --- /dev/null +++ b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_3.org @@ -0,0 +1,10 @@ +1. cat + 1. foo + + 1. bar + + 2. baz + + 2. lorem + +ipsum diff --git a/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_4.org b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_4.org new file mode 100644 index 00000000..33b8fafe --- /dev/null +++ b/org_mode_samples/plain_lists/trailing_whitespace_ownership_test_case_4.org @@ -0,0 +1,12 @@ +1. cat + 1. foo + + 1. bar + + 2. baz + + 2. lorem + +2. dog + +ipsum