Moduldiskussion:Formattal/testcases
Tests
All tests passed.
test_fejlangivelseskode:
| Text | Expected | Actual | |
|---|---|---|---|
| Fejltekst ikke tom, skal vise stjerne | * | * | |
| Fejltekst tom, skal vise stjerne | * | * | |
| Fejltekst ikke tom, skal ikke vise stjerne |
test_formattal:
| Text | Expected | Actual | |
|---|---|---|---|
| {{#invoke:Formattal|formattal|1}} | 1 | 1 | |
| {{#invoke:Formattal|formattal|12}} | 12 | 12 | |
| {{#invoke:Formattal|formattal|123}} | 123 | 123 | |
| {{#invoke:Formattal|formattal|1.234}} | 1.234 | 1.234 | |
| {{#invoke:Formattal|formattal|12.345}} | 12.345 | 12.345 | |
| {{#invoke:Formattal|formattal|123.456}} | 123.456 | 123.456 | |
| {{#invoke:Formattal|formattal|1,0}} | 1,0 | 1,0 | |
| {{#invoke:Formattal|formattal|12,0}} | 12,0 | 12,0 | |
| {{#invoke:Formattal|formattal|123,0}} | 123,0 | 123,0 | |
| {{#invoke:Formattal|formattal|1.234,0}} | 1.234,0 | 1.234,0 | |
| {{#invoke:Formattal|formattal|12.345,0}} | 12.345,0 | 12.345,0 | |
| {{#invoke:Formattal|formattal|123.456,0}} | 123.456,0 | 123.456,0 | |
| {{#invoke:Formattal|formattal|1.0}} | 1,0 | 1,0 | |
| {{#invoke:Formattal|formattal|12.0}} | 12,0 | 12,0 | |
| {{#invoke:Formattal|formattal|123.0}} | 123,0 | 123,0 | |
| {{#invoke:Formattal|formattal|1,234.0}} | 1.234,0 | 1.234,0 | |
| {{#invoke:Formattal|formattal|12,345.0}} | 12.345,0 | 12.345,0 | |
| {{#invoke:Formattal|formattal|123,456.0}} | 123.456,0 | 123.456,0 | |
| {{#invoke:Formattal|formattal|1.00}} | 1,00 | 1,00 | |
| {{#invoke:Formattal|formattal|12.00}} | 12,00 | 12,00 | |
| {{#invoke:Formattal|formattal|123.00}} | 123,00 | 123,00 | |
| {{#invoke:Formattal|formattal|1.234,00}} | 1.234,00 | 1.234,00 | |
| {{#invoke:Formattal|formattal|12.345,00}} | 12.345,00 | 12.345,00 | |
| {{#invoke:Formattal|formattal|123.456,00}} | 123.456,00 | 123.456,00 | |
| {{#invoke:Formattal|formattal|1.00}} | 1,00 | 1,00 | |
| {{#invoke:Formattal|formattal|12.00}} | 12,00 | 12,00 | |
| {{#invoke:Formattal|formattal|123.00}} | 123,00 | 123,00 | |
| {{#invoke:Formattal|formattal|1,234.00}} | 1.234,00 | 1.234,00 | |
| {{#invoke:Formattal|formattal|12,345.00}} | 12.345,00 | 12.345,00 | |
| {{#invoke:Formattal|formattal|123,456.00}} | 123.456,00 | 123.456,00 | |
| {{#invoke:Formattal|formattal|-123}} | -123 | -123 | |
| {{#invoke:Formattal|formattal|+123.00}} | +123,00 | +123,00 | |
| {{#invoke:Formattal|formattal|+ 123.00}} | +123,00 | +123,00 | |
| {{#invoke:Formattal|formattal|- 123.00}} | -123,00 | -123,00 | |
| {{#invoke:Formattal|formattal|- 123.00}} | -123,00 | -123,00 | |
| {{#invoke:Formattal|formattal|+ 123.00}} | +123,00 | +123,00 | |
| {{#invoke:Formattal|formattal|+123.43[ref]hello[/ref] lalalala}} | +123,43[ref]hello[/ref] lalalala | +123,43[ref]hello[/ref] lalalala | |
| {{#invoke:Formattal|formattal|}} | |||
| {{#invoke:Formattal|formattal|nonsens}} | nonsens | nonsens | |
| {{#invoke:Formattal|formattal|1.234.00}} | 1.234.00 | 1.234.00 | |
| {{#invoke:Formattal|formattal|12.345.00}} | 12.345.00 | 12.345.00 | |
| {{#invoke:Formattal|formattal|123.456.00}} | 123.456.00 | 123.456.00 | |
| {{#invoke:Formattal|formattal|1,234,00}} | 1,234,00 | 1,234,00 | |
| {{#invoke:Formattal|formattal|12,345,00}} | 12,345,00 | 12,345,00 | |
| {{#invoke:Formattal|formattal|123,456,00}} | 123,456,00 | 123,456,00 | |
| {{#invoke:Formattal|formattal|.123}} | .123 | .123 | |
| {{#invoke:Formattal|formattal|.1234}} | .1234 | .1234 | |
| {{#invoke:Formattal|formattal|0.1234}} | 0.1234 | 0.1234 | |
| {{#invoke:Formattal|formattal|,123}} | ,123 | ,123 | |
| {{#invoke:Formattal|formattal|0,1234}} | 0,1234 | 0,1234 |
test_isSequenceOfAtLeastOneDigit:
| Text | Expected | Actual | |
|---|---|---|---|
| false | false | ||
| 1 | true | true | |
| a | false | false | |
| 12 | true | true | |
| 123456777 | true | true | |
| 123456777a | false | false |
test_modsatAdskillertegn:
| Text | Expected | Actual | |
|---|---|---|---|
| , | . | . | |
| . | , | , |
test_opdelInputITalOgRest:
| Text | Expected | Actual | |
|---|---|---|---|
| -123.332.332 | {"-123.332.332",""} | {"-123.332.332",""} | |
| -123.332.332! | {"-123.332.332","!"} | {"-123.332.332","!"} | |
| ! | {"","!"} | {"","!"} | |
| +123,43.544[1] | {"+123,43.544","[2]"} | {"+123,43.544","[3]"} |
test_opsplitIFortegnOgRest:
| Text | Expected | Actual | |
|---|---|---|---|
| {"",""} | {"",""} | ||
| 1 | {"","1"} | {"","1"} | |
| -1 | {"-","1"} | {"-","1"} | |
| -12.34 | {"-","12.34"} | {"-","12.34"} | |
| +12,304.34 | {"+","12,304.34"} | {"+","12,304.34"} | |
| 12,304.34 | {"","12,304.34"} | {"","12,304.34"} |
test_removeAll:
| Text | Expected | Actual | |
|---|---|---|---|
| Remove all , from 123,332,332 | 123332332 | 123332332 | |
| Remove all %. from 123,332,332 | 123,332,332 | 123,332,332 | |
| Remove all %. from 123.332.332 | 123332332 | 123332332 | |
| Remove all l from hello | heo | heo |
Referencer fra tests
6 nye tests fejler, hvilket viser fejl i koden
Jeg tilføjede lige 6 nye tests, og de viser, at der er fejl i koden. Medmindre altså at koden kræver, at input altid er gyldigt, men det modbeviser koden jo selv, da den i visse tilfælde melder fejl.
Jeg vil prøve at se på at rette det en af de kommende dage. De nye fejlende tests har jo ikke gjort, at den eksisterende funktionalitet er ændret, så det betyder blot, at den originale kode ikke dækkede alle fejlsituationer. Bemærk at den p.t. uden at melde fejl laver direkte forkerte oversættelser, fx .1234 → 1.234. Det bør den ikke kunne gøre. --Jhertel (diskussion) 25. okt 2017, 15:40 (CEST)
- Jeg har nu slået de pågældende 6 tests til, så det er synligt, at de fejler. Fejlene er ikke løst. --Jhertel (diskussion) 21. nov 2017, 18:22 (CET)
- Det er nu nede på 5 fejlende tests. Jeg er ikke begyndt på at løse fejlene endnu; jeg har i første omgang fokuseret på refaktorisering for at gøre koden mere overskuelig og forståelig. Jeg har dog forbedret en smule, når jeg så noget ikke gav mening (ingen grund til at arbejde hårdt på ligefrem at bevare fejlene under refaktoriseringen). --Jhertel (diskussion) 26. nov 2017, 15:16 (CET)
- Nu er der ikke længere nogen fejlende tests – modulet består alle tests. --Jhertel (diskussion) 30. nov 2017, 04:15 (CET)
- Det er nu nede på 5 fejlende tests. Jeg er ikke begyndt på at løse fejlene endnu; jeg har i første omgang fokuseret på refaktorisering for at gøre koden mere overskuelig og forståelig. Jeg har dog forbedret en smule, når jeg så noget ikke gav mening (ingen grund til at arbejde hårdt på ligefrem at bevare fejlene under refaktoriseringen). --Jhertel (diskussion) 26. nov 2017, 15:16 (CET)
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.
- 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:
- 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.
- 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.
- 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.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.









