fbpx
วิกิพีเดีย

มอดูล:ConvertNumeric/sandbox/testcases

-- Unit tests for [[Module:ConvertNumeric/sandbox]]. Click talk page to run tests. local p = require('Module:UnitTests/sandbox')  local frame = mw.getCurrentFrame() local function get_error_text(wikitext)  local message = frame:preprocess(wikitext):match('<strong class="error"><[^>]+>(.-)<[^>]+></strong>')  message = message:match('at line %d+: (.+)%.$') or message  return message end  function p:test_numeral_to_thai()  self:preprocess_equals_many('{{#invoke:ConvertNumeric/sandbox | numeral_to_thai |', '}}', {  {'0', 'ศูนย์'},  {'1', 'หนึ่ง'},  {' 1 ', 'หนึ่ง'}, -- test whitespace around number  {'1 | case=u', 'หนึ่ง'},  {'1 | case=U', 'หนึ่ง'},  {'-1', 'ลบหนึ่ง'},  {'-1 | negative=minus', 'ลบหนึ่ง'},  {'-1 | negative=ติดลบ', 'ติดลบหนึ่ง'},  {'70', 'เจ็ดสิบ'},  {'42', 'สี่สิบสอง'},  {'61', 'หกสิบเอ็ด'},  {'101', 'หนึ่งร้อยเอ็ด'},  {'123', 'หนึ่งร้อยยี่สิบสาม'},  {'123 | sp=us', 'หนึ่งร้อยยี่สิบสาม'},  {'123 | adj=on', 'หนึ่งร้อยยี่สิบสาม'},  {'1050', 'หนึ่งพันห้าสิบ'},  {'1050 | sp=us', 'หนึ่งพันห้าสิบ'},  {'0.25', 'ศูนย์จุดสองห้า'},  {'.25', 'ศูนย์จุดสองห้า'},  {'0 | ord=on', 'ศูนย์'},  {'33 | ord=on', 'สามสิบสาม'},  {'40 | ord=on', 'สี่สิบ'},  {'5000000000 | ord=on', 'ห้าพันล้าน'},  {'0 | pl=on', 'ศูนย์'},  {'76 | pl=on', 'เจ็ดสิบหก'},  {'1000000000000000000000000000001', 'หนึ่งล้านล้านล้านล้านล้านเอ็ด'},  {'1.23E3', 'หนึ่งพันสองร้อยสามสิบ'},  {'123E-4', 'ศูนย์จุดศูนย์หนึ่งสองสาม'},  {'5E30', 'ห้าล้านล้านล้านล้านล้าน'},  {'-123456789.25', 'ลบหนึ่งร้อยยี่สิบสามล้านสี่แสนห้าหมื่นหกพันเจ็ดร้อยแปดสิบเก้าจุดสองห้า'},  {'0 | zero=foo', 'foo'},  {'0 | ord=on | zero=none', 'none'},  {'0 | ord=on | zero=', ''},  {'1 | numerator=2 | denominator=3', 'หนึ่งเศษสองส่วนสาม'},  {'| numerator=2 | denominator=3', 'เศษสองส่วนสาม'},  {'1 | denominator=2', 'หนึ่งเศษหนึ่งส่วนสอง'},  {'1 | numerator=3 | denominator=2', 'หนึ่งเศษสามส่วนสอง'},  {'1 | numerator=1 | denominator=4', 'หนึ่งเศษหนึ่งส่วนสี่'},  {'9 | numerator=3 | denominator=4', 'เก้าเศษสามส่วนสี่'},  }) end  function p:test_numeral_to_english()  self:preprocess_equals_many('{{#invoke:ConvertNumeric/sandbox | numeral_to_english |', '}}', {  {'0', 'zero'},  {'1', 'one'},  {' 1 ', 'one'}, -- test whitespace around number  {'1 | case=u', 'One'},  {'1 | case=U', 'One'},  {'-1', 'negative one'},  {'-1 | negative=minus', 'minus one'},  {'70', 'seventy'},  {'42', 'forty-two'},  {'123', 'one hundred and twenty-three'},  {'123 | sp=us', 'one hundred twenty-three'},  {'123 | adj=on', 'one-hundred-and-twenty-three'},  {'1050', 'one thousand and fifty'},  {'1050 | sp=us', 'one thousand fifty'},  {'0.25', 'zero point two five'},  {'.25', 'zero point two five'},  {'0 | ord=on', 'zeroth'},  {'33 | ord=on', 'thirty-third'},  {'40 | ord=on', 'fortieth'},  {'5000000000 | ord=on', 'five billionth'},  {'0 | pl=on', 'zeros'},  {'76 | pl=on', 'seventy-sixes'},  {'1000000000000000000000000000001', 'one nonillion and one'},  {'1.23E3', 'one thousand two hundred and thirty'},  {'123E-4', 'zero point zero one two three'},  {'1001001001001000 | lk=on', 'one [[Orders_of_magnitude_(numbers)#1015|quadrillion]] one [[Orders_of_magnitude_(numbers)#1012|trillion]] one [[Orders_of_magnitude_(numbers)#109|billion]] one million one thousand'},  {'1001001001001000 | lk=billion,quadrillion', 'one [[Orders_of_magnitude_(numbers)#1015|quadrillion]] one trillion one [[Orders_of_magnitude_(numbers)#109|billion]] one million one thousand'},  {'5E30', 'five nonillion'},  {'-123456789.25', 'negative one hundred twenty-three million four hundred fifty-six thousand seven hundred and eighty-nine point two five'},  {'0 | zero=foo', 'foo'},  {'0 | ord=on | zero=none', 'none'},  {'1 | numerator=2 | denominator=3', 'one and two-thirds'},  {'| numerator=2 | denominator=3', 'two-thirds'},  {'1 | denominator=2', 'one and a half'},  {'1 | numerator=3 | denominator=2', 'one and three-halves'},  {'1 | numerator=1 | denominator=4', 'one and a quarter'},  {'1 | numerator=1 | denominator=4 | sp=us', 'one and a fourth'},  {'1 | numerator=1 | denominator=4 | one=one', 'one and one-quarter'},  {'1 | numerator=1 | denominator=4 | sp=us | one=one', 'one and one-fourth'},  {'9 | numerator=3 | denominator=4', 'nine and three-quarters'},  {'9 | numerator=3 | denominator=4 | sp=us', 'nine and three-fourths'},  {'23 | numerator=12 | denominator=16', 'twenty-three and twelve-sixteenths'},  }) end   function p:test_numeral_to_english_error()  local cases = {'', 'a', '.', 'e', 'E', 'E1', '.E1', '+', '-', '123a', 'a123', '0.1a', '-a123' }  local nowiki = mw.text.nowiki  for _, case in ipairs(cases) do  local wikitext = '{{#invoke:ConvertNumeric/sandbox | numeral_to_english |' .. case .. '}}'  self:equals(nowiki(wikitext), get_error_text(wikitext), 'Invalid decimal numeral', { toBeError = true })  end end  function p:test_numeral_to_english_round()  self:preprocess_equals_many('{{#invoke:ConvertNumeric/sandbox | numeral_to_english |', '}}', {  {'1 | round=on', 'one'},  {'37 | round=on', 'thirty-seven'},  {'190 | round=on', 'two hundred'},  {'110 | round=up', 'two hundred'},  {'190 | round=down', 'one hundred'},  {'87654321 | round=on', 'ninety million'},  {'12345678 | round=on', 'twelve million'},  {'-190 | round=on', 'negative two hundred'},  {'-190 | round=up', 'negative one hundred'},  {'-110 | round=down', 'negative two hundred'},  {'0.25 | round=on', 'zero'},  {'0.5 | round=on', 'one'},  {'-0.25 | round=on', 'zero'},  {'-0.5 | round=on', 'negative one'},  {'0.01 | round=up', 'one'},  {'0.99 | round=down', 'zero'},  {'-0.01 | round=down', 'negative one'},  {'-0.99 | round=up', 'zero'},  }) end  function p:test_numeral_to_thai_round()  self:preprocess_equals_many('{{#invoke:ConvertNumeric/sandbox | numeral_to_thai |', '}}', {  {'1 | round=on', 'หนึ่ง'},  {'37 | round=on', 'สามสิบเจ็ด'},  {'190 | round=on', 'สองร้อย'},  {'110 | round=up', 'สองร้อย'},  {'190 | round=down', 'หนึ่งร้อย'},  {'87654321 | round=on', 'เก้าสิบล้าน'},  {'12345678 | round=on', 'สิบสองล้าน'},  {'-190 | round=on', 'ลบสองร้อย'},  {'-190 | round=up', 'ลบหนึ่งร้อย'},  {'-110 | round=down', 'ลบสองร้อย'},  {'0.25 | round=on', 'ศูนย์'},  {'0.5 | round=on', 'หนึ่ง'},  {'-0.25 | round=on', 'ศูนย์'},  {'-0.5 | round=on', 'ลบหนึ่ง'},  {'0.01 | round=up', 'หนึ่ง'},  {'0.99 | round=down', 'ศูนย์'},  {'-0.01 | round=down', 'ลบหนึ่ง'},  {'-0.99 | round=up', 'ศูนย์'},  }) end  function p:test_decToHex()  self:preprocess_equals(  '{{#invoke:ConvertNumeric/sandbox |decToHex|10 20 40 1024 78912345|minlength=4}}',  '000A 0014 0028 0400 4B41B59'  ) end  return p 

มอด, convertnumeric, sandbox, testcases, อหน, าช, ดทดสอบของมอด, มอด, convertnumeric, sandbox, ผลล, พธ, ของช, ดทดสอบ, unit, tests, module, convertnumeric, sandbox, click, talk, page, tests, local, require, module, unittests, sandbox, local, frame, getcurrentfra. nikhuxhnachudthdsxbkhxngmxdul mxdul ConvertNumeric sandbox phllphthkhxngchudthdsxb Unit tests for Module ConvertNumeric sandbox Click talk page to run tests local p require Module UnitTests sandbox local frame mw getCurrentFrame local function get error text wikitext local message frame preprocess wikitext match lt strong class error gt lt gt gt lt gt gt lt strong gt message message match at line d or message return message end function p test numeral to thai self preprocess equals many invoke ConvertNumeric sandbox numeral to thai 0 suny 1 hnung 1 hnung test whitespace around number 1 case u hnung 1 case U hnung 1 lbhnung 1 negative minus lbhnung 1 negative tidlb tidlbhnung 70 ecdsib 42 sisibsxng 61 hksibexd 101 hnungrxyexd 123 hnungrxyyisibsam 123 sp us hnungrxyyisibsam 123 adj on hnungrxyyisibsam 1050 hnungphnhasib 1050 sp us hnungphnhasib 0 25 sunycudsxngha 25 sunycudsxngha 0 ord on suny 33 ord on samsibsam 40 ord on sisib 5000000000 ord on haphnlan 0 pl on suny 76 pl on ecdsibhk 1000000000000000000000000000001 hnunglanlanlanlanlanexd 1 23E3 hnungphnsxngrxysamsib 123E 4 sunycudsunyhnungsxngsam 5E30 halanlanlanlanlan 123456789 25 lbhnungrxyyisibsamlansiaesnhahmunhkphnecdrxyaepdsibekacudsxngha 0 zero foo foo 0 ord on zero none none 0 ord on zero 1 numerator 2 denominator 3 hnungesssxngswnsam numerator 2 denominator 3 esssxngswnsam 1 denominator 2 hnungesshnungswnsxng 1 numerator 3 denominator 2 hnungesssamswnsxng 1 numerator 1 denominator 4 hnungesshnungswnsi 9 numerator 3 denominator 4 ekaesssamswnsi end function p test numeral to english self preprocess equals many invoke ConvertNumeric sandbox numeral to english 0 zero 1 one 1 one test whitespace around number 1 case u One 1 case U One 1 negative one 1 negative minus minus one 70 seventy 42 forty two 123 one hundred and twenty three 123 sp us one hundred twenty three 123 adj on one hundred and twenty three 1050 one thousand and fifty 1050 sp us one thousand fifty 0 25 zero point two five 25 zero point two five 0 ord on zeroth 33 ord on thirty third 40 ord on fortieth 5000000000 ord on five billionth 0 pl on zeros 76 pl on seventy sixes 1000000000000000000000000000001 one nonillion and one 1 23E3 one thousand two hundred and thirty 123E 4 zero point zero one two three 1001001001001000 lk on one Orders of magnitude numbers 1015 quadrillion one Orders of magnitude numbers 1012 trillion one Orders of magnitude numbers 109 billion one million one thousand 1001001001001000 lk billion quadrillion one Orders of magnitude numbers 1015 quadrillion one trillion one Orders of magnitude numbers 109 billion one million one thousand 5E30 five nonillion 123456789 25 negative one hundred twenty three million four hundred fifty six thousand seven hundred and eighty nine point two five 0 zero foo foo 0 ord on zero none none 1 numerator 2 denominator 3 one and two thirds numerator 2 denominator 3 two thirds 1 denominator 2 one and a half 1 numerator 3 denominator 2 one and three halves 1 numerator 1 denominator 4 one and a quarter 1 numerator 1 denominator 4 sp us one and a fourth 1 numerator 1 denominator 4 one one one and one quarter 1 numerator 1 denominator 4 sp us one one one and one fourth 9 numerator 3 denominator 4 nine and three quarters 9 numerator 3 denominator 4 sp us nine and three fourths 23 numerator 12 denominator 16 twenty three and twelve sixteenths end function p test numeral to english error local cases a e E E1 E1 123a a123 0 1a a123 local nowiki mw text nowiki for case in ipairs cases do local wikitext invoke ConvertNumeric sandbox numeral to english case self equals nowiki wikitext get error text wikitext Invalid decimal numeral toBeError true end end function p test numeral to english round self preprocess equals many invoke ConvertNumeric sandbox numeral to english 1 round on one 37 round on thirty seven 190 round on two hundred 110 round up two hundred 190 round down one hundred 87654321 round on ninety million 12345678 round on twelve million 190 round on negative two hundred 190 round up negative one hundred 110 round down negative two hundred 0 25 round on zero 0 5 round on one 0 25 round on zero 0 5 round on negative one 0 01 round up one 0 99 round down zero 0 01 round down negative one 0 99 round up zero end function p test numeral to thai round self preprocess equals many invoke ConvertNumeric sandbox numeral to thai 1 round on hnung 37 round on samsibecd 190 round on sxngrxy 110 round up sxngrxy 190 round down hnungrxy 87654321 round on ekasiblan 12345678 round on sibsxnglan 190 round on lbsxngrxy 190 round up lbhnungrxy 110 round down lbsxngrxy 0 25 round on suny 0 5 round on hnung 0 25 round on suny 0 5 round on lbhnung 0 01 round up hnung 0 99 round down suny 0 01 round down lbhnung 0 99 round up suny end function p test decToHex self preprocess equals invoke ConvertNumeric sandbox decToHex 10 20 40 1024 78912345 minlength 4 000A 0014 0028 0400 4B41B59 end return p ekhathungcak https th wikipedia org w index php title mxdul ConvertNumeric sandbox testcases amp oldid 9450333, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม