টেমপ্লেট:Val/testcases

(টেমপ্লেট:Val/test থেকে পুনর্নির্দেশিত)

This is the page of testcases for: Template:Val.

Overview সম্পাদনা

The testcases, listed below, are intended to show the working options for Template:Val, and for its experimental variation Template:Val/sandbox (to develop new options). The variety of testcases is intended to be a broad sample of all possible options, so as to better catch any mistakes introduced during updates.

Live testcases for Template:Val সম্পাদনা

Here are some tests to see if {{val}} works correctly:

  • {{val|1}} =
  • {{val|-1}} = −১
  • {{val|1|2}} = ±
  • {{val|1|(2)}} = ১(২)
  • {{val|1|2|-3}} = +২
    −৩
  • {{val|1|e=1}} = ×১০
  • {{val|1|e=-1}} = ×১০−১
  • {{val|1|u=X}} = ১ X
  • {{val|p=Δ |12.34|s=%}} = Δ ১২.৩৪%
  • {{val|p=Δ |1245.6789|12345|-12345|e=12345|u=kg|s=%}} = Δ ১২৪৫.৬৭৮৯+১২৩৪৫
    −১২৩৪৫
    ×১০১২৩৪৫ কিg%

Various ways of displaying units with/without links:

  • {{val|1|u=m/s}} = ১ m/s
  • {{val|1|u=m*s-1}} = ১ m*s-1
  • {{val|1|u=m|up=s}} = ১ মি/s
  • {{val|1|ul=m/s}} = ১ m/s
  • {{val|1|ul=m*s-1}} = ১ m*s-1
  • {{val|1|ul=m|up=s}} = ১ মি/s
  • {{val|1|u=m|upl=s}} = ১ মি/s
  • {{val|1|ul=m|upl=s}} = ১ মি/s

Tests for grouping digits:

  • {{val|12}} = ১২
  • {{val|123}} = ১২৩
  • {{val|1234}} = ১২৩৪
  • {{val|12345}} = ১২৩৪৫
  • {{val|123456}} = ২৩৪৫৬
  • {{val|1234567}} = ১২৩৪৫৬৭
  • {{val|12345678}} = ২৩৪৫৬৭৮
  • {{val|123456789}} = ১২৩৪৫৬৭৮৯
  • {{val|1234567890}} = ২৩৪৫৬৭৮৯০
  • {{val|12345678901}} = ১২৩৪৫৬৭৮৯০১
  • {{val|123456789012}} = ২৩৪৫৬৭৮৯০১২
  • {{val|1234567890123}} = ১২৩৪৫৬৭৮৯০১২৩
  • {{val|12345678901234}} = ২৩৪৫৬৭৮৯০১২৩৪
  • {{val|123456789012345}} = ১২৩৪৫৬৭৮৯০১২৩৪৫
  • {{val|-12}} = −১২
  • {{val|-123}} = −১২৩
  • {{val|-1234}} = −১২৩৪
  • {{val|-12345}} = −১২৩৪৫
  • {{val|-123456}} = −১২৩৪৫৬
  • {{val|-1234567}} = −১২৩৪৫৬৭
  • {{val|-12345678}} = −১২৩৪৫৬৭৮
  • {{val|-123456789}} = −১২৩৪৫৬৭৮৯
  • {{val|-1234567890}} = −১২৩৪৫৬৭৮৯০
  • {{val|-12345678901}} = −১২৩৪৫৬৭৮৯০১
  • {{val|-123456789012}} = −১২৩৪৫৬৭৮৯০১২
  • {{val|-1234567890123}} = −১২৩৪৫৬৭৮৯০১২৩
  • {{val|-12345678901234}} = −১২৩৪৫৬৭৮৯০১২৩৪
  • {{val|-123456789012345}} = −১২৩৪৫৬৭৮৯০১২৩৪৫
  • {{val|1.2}} = ১.২
  • {{val|1.23}} = ১.২৩
  • {{val|1.234}} = ১.২৩৪
  • {{val|1.2345}} = ১.২৩৪৫
  • {{val|1.23456}} = ১.২৩৪৫৬
  • {{val|1.234567}} = ১.২৩৪৫৬৭
  • {{val|1.2345678}} = ১.২৩৪৫৬৭৮
  • {{val|1.23456789}} = ১.২৩৪৫৬৭৮৯
  • {{val|1.234567890}} = ১.২৩৪৫৬৭৮৯০
  • {{val|1.2345678901}} = ১.২৩৪৫৬৭৮৯০১
  • {{val|1.23456789012}} = ১.২৩৪৫৬৭৮৯০১২
  • {{val|1.234567890123}} = ১.২৩৪৫৬৭৮৯০১২৩
  • {{val|1.2345678901234}} = ১.২৩৪৫৬৭৮৯০১২৩৪
  • {{val|1.23456789012345}} = ১.২৩৪৫৬৭৮৯০১২৩৪৫

Formatting large numbers:

  • {{val|12345}} = ১২৩৪৫
  • {{val|12345|12345}} = ১২৩৪৫±১২৩৪৫
  • {{val|12345|(12345)}} = ১২৩৪৫(১২৩৪৫)
  • {{val|12345|12345|-12345}} = ১২৩৪৫+১২৩৪৫
    −১২৩৪৫
  • {{val|12345|e=12345}} = ১২৩৪৫×১০১২৩৪৫
  • {{val|12345|e=-12345}} = ১২৩৪৫×১০−১২৩৪৫
  • {{val|12345|u=Non-existing unit}} = ১২৩৪৫ Non-existing unit
  • {{val|p=prefix|12345|s=suffix}} = prefix১২৩৪৫suffix

Error messages:

  • {{val}} =
  • {{val|A|B|C}} = {{val}} টেমপ্লেটে ত্রুটি: প্যারামিটার 1 একটি বৈধ সংখ্যা নয়.
  • {{val|1|B|C}} = {{val}} টেমপ্লেটে ত্রুটি: প্যারামিটার 2 একটি বৈধ সংখ্যা নয়.
  • {{val|1|1|C}} = {{val}} টেমপ্লেটে ত্রুটি: প্যারামিটার 3 একটি বৈধ সংখ্যা নয়.
  • {{val|1|1|1}} = +১
    −১
  • {{val|1|e=A}} = {{val}} টেমপ্লেটে ত্রুটি: এক্সপোনেন্ট প্যারামিটার (e) একটি বৈধ সংখ্যা নয়.
  • {{val|1|up=s}} = ১/s
  • {{val|1|upl=s}} = ১/s
  • {{val|1|u=|up=}} =
  • {{val|1|u=m|ul=m}} = {{val}} টেমপ্লেটে ত্রুটি: একক (u) এবং এককসহ লিঙ্ক (ul) উভয় দেওয়া হয়েছে, শুধুমাত্র একটি অনুমোদিত।
  • {{val|1|u=m|up=m|upl=m}} = {{val}} টেমপ্লেটে ত্রুটি: একক প্রতি (up) এবং একক প্রতি লিঙ্ক (upl) উভয় দেওয়া হয়েছে, শুধুমাত্র একটি অনুমোদিত।

Testcases for /sandbox version সম্পাদনা

The following testcases show how {{val/sandbox}} works:

Various ways of displaying units with/without links:

Tests for grouping digits:

Formatting large numbers:

Error messages:

Multiple error messages সম্পাদনা

10-Dec-2010: The Template:Val has been performing too many nested if-else-if-else checks on parameters, and has been nested over 20 deep (of the tiny 40-level "Expansion depth limit" in MediaWiki 1.6), before Val processes all decimal digits, nesting 1 level deeper for each digit after 4. This nesting is reduced by checking each validation of parameters as non-nested simple if-then logic (not if-else logic). By contrast, Template:Gaps nests only 2 levels deep (for {gaps|0.123|456|789|u=m} → 0.123456789 m or such). During 2008-2010, the MediaWiki 1.6 software has been using a 40-nest limit to stop "runaway" formatting of pages, when 60 (or 200) levels would be more practical (and stop any looping templates soon enough).

Meawhile, by changing the if-else validation checks to non-nested if-then logic, all error conditions are reported as a sequence of messages, and then the output will still be attempted. However, that is a good tactic because if 2 parameters are wrong, then getting a message for each of them is better (at one time), and then seeing a partial result can help to spot which instance of {Val} has those invalid parameters. Template {Val} had been reporting 1 error and stopping:

  • For {val|0.1234S6|0.L} using 5=S, 1=L gives: {{val}} টেমপ্লেটে ত্রুটি: প্যারামিটার 1 একটি বৈধ সংখ্যা নয়.

With the internal nesting reduced, then Val also reports "0.L" as an invalid number.

These results were confirmed using the sandbox variation of Val to show the proposed changes. -Wikid77 (talk) 21:00, 10 December 2010 (UTC)

Using multi-nested templates সম্পাদনা

10-Dec-2010: The Template:Val/sandbox variation was used to develop non-nested validation of parameters. It continues to show messages for each invalid parameter, then always attempts the output, rather than nest the logic when checking for errors, else nest for further processing.

The problems with nesting beyond the tiny 40-level limit (in MediaWiki 1.6 during 2009-2010), which restricts the nesting of templates and if-else logic, is shown in the following examples.

* Nest 27 deep & try {Val/sandbox|9888.12345}: <!--
-->{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x|{{1x
|→ {{Val/sandbox|9888.12345}}
}}}} }}}} }}}} }}}} }}}}  }}}} }}}} }}}} }}}} }}}}
}}}} }}}} }}}} }}


  • Nest 20 deep & try {Val|9888.12345}: → ৮৮৮.১২৩৪৫
  • Nest 16 deep & try {Val|9888.123456789}: → ৮৮৮.১২৩৪৫৬৭৮৯

Because {Val} had been coded with nested if-else-if-else-if-else, to check for 8 error conditions, it could not run within other templates nested to 20 deep, during 2009-2010, but the sandbox version could run even when nested 27 deep. When Val processes the decimal digits, it nests 1 level deeper for each decimal digit after 4 (beyond 0.0001). -Wikid77 (talk) 21:00, 10 December 2010 (UTC)