User:Polygnotus/Scripts/DeduplicateReferencesTest3



This page tests DeduplicateReferences.

When this page is loaded with the script active, a test panel appears in the top-right corner showing pass/fail for each unit test. The tests run against synthetic inputs inside the script itself and are independent of the wikicode below.

When this page is opened in the editor, the script also deduplicates the ref tags below, so you can verify the live wikicode behaviour.

How to read the test cases

Each section describes one scenario. The Expected line states what the script should do. Reset the page to its saved state between test runs by using Ctrl+Z in the editor or by closing and reopening it.


TC-1: Simple unnamed duplicate — should be deduped

First citation.[1] Second citation, same source.[2]

Expected: Both refs share a name derived from the title (e.g. bbc_test_article). The second becomes <ref name="bbc_test_article" />.


TC-2: Named ref — must not be modified

First use.[3] Second use (back-reference).[3]

Expected: No change. Both tags remain exactly as written.


TC-3: Triple unnamed duplicate — 1 named + 2 self-closing

Claim A.[4] Claim B.[5] Claim C.[6]

Expected: The first ref becomes <ref name="reuters_report_on">…</ref>; the second and third become <ref name="reuters_report_on" />. Deduplication count = 2.


TC-4: Two different unnamed refs — must not be deduped

First source.[7] Second source, different content.[8]

Expected: No change. The refs have different content and must stay separate.


TC-5: Ref with group attribute — group must be preserved

Body text.[note 1] More body text.[note 2]

Expected: After deduplication both refs still carry group="note".

Alternatively, with raw ref tags:

Body text.[note 3] More body text.[note 4]

Expected: Same — group="note" preserved on both the named and self-closing ref.


TC-6: URL-only ref (no cite template) — name from domain

Source.[9] Same source again.[10]

Expected: Name derived from the domain: theguardian_com.


TC-7: Blacklisted domain — falls through to title-based name

DOI ref one.[11] DOI ref two.[12]

Expected: doi.org is blacklisted, so the name falls through to the title: some_journal_article. The name must not start with doi.


TC-8: Pre-existing name must not be overwritten by a generated name

This ref already uses the name that the generator would pick.[13] This unnamed duplicate would normally get the name "example_com".[14] Second unnamed duplicate.[15]

Expected: The two unnamed refs get a variant name such as example_site_2 (not example_com, which is already taken). The pre-existing named ref is untouched.


References

  1. ^ "BBC Test Article". 1 January 2024. Retrieved 1 January 2024.
  2. ^ "BBC Test Article". 1 January 2024. Retrieved 1 January 2024.
  3. ^ a b Smith, J. (2024). Smith's Comprehensive Guide. Academic Press.
  4. ^ "Reuters Report on Topic". 2 February 2024.
  5. ^ "Reuters Report on Topic". 2 February 2024.
  6. ^ "Reuters Report on Topic". 2 February 2024.
  7. ^ "NYT Article One". 3 March 2024.
  8. ^ "NYT Article Two". 4 March 2024.
  9. ^ https://theguardian.com/world/2024/article-abc
  10. ^ https://theguardian.com/world/2024/article-abc
  11. ^ Doe, J. (2020). "Some Journal Article". Nature. doi:10.1000/xyz123.
  12. ^ Doe, J. (2020). "Some Journal Article". Nature. doi:10.1000/xyz123.
  13. ^ "Example Site".
  14. ^ "Example Site".
  15. ^ "Example Site".

Notes

  1. ^ This is a footnote that appears twice.
  2. ^ This is a footnote that appears twice.
  3. ^ This is a raw footnote that appears twice.
  4. ^ This is a raw footnote that appears twice.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.