Wikipedia:Lua/Modul/JSONutil/Test
This is a test of the new MediaWiki:Subjectpageheader.
Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
---|---|---|---|---|---|---|---|
Modul | Deutsch | English
|
Modul: | Dokumentation |
Test cases of Lua functions; version: 2020-11-08
fiat
[Quelltext bearbeiten]Input | Code (fault) | String (trailing) |
---|---|---|
{ "simple": "assignment" } | – | { "simple": "assignment" } |
{ "beg": "\"escaped quote", "mid": "escaped\"quote", "end": "escaped quote\"" } | – | { "beg": "\"escaped quote", "mid": "escaped\"quote", "end": "escaped quote\"" } |
{ "multiline": "Some textLFin several linesLFalso withTabtabulator" } | – | { "multiline": "Some text\nin several lines\nalso with\ttabulator" } |
{ "lineseps": "UxLFstyle andCRApple and MSCRLFDOS" } | – | { "lineseps": "Ux\nstyle and\nApple and MS\nDOS" } |
{ "commented": true } // line at end | – | { "commented": true } |
{ "commented":// line amidLF true// second lineLF } | – | { "commented": true } |
{ "commented": /* middle */true } | – | { "commented": true } |
{ "commented":/* middle */"edge" } | – | { "commented":"edge" } |
{ "NoComment": "An URL http://example.org/ is not a comment" } | – | { "NoComment": "An URL http://example.org/ is not a comment" } |
No JSON | Bracket0 | No JSON |
{ "simple": "assignment" } garbage | Trailing | garbage |
{ "quoting": 'apostrophes' } | Qoute | 'apostrophes' } |
{ "missing": "qoute } | QouteEnd | qoute } |
{ "missing": "qoute (escaped)\" } | QouteEnd | qoute (escaped)\" } |
{ "htab": "h�tab" } | ControlChar | tab" } |
{ "comma": "trailing", } | CommaEnd | , } |
{ "comma": [ "trailing", ] } | CommaEnd | , ] } |
{ "comma": true, } | CommaEnd | : true, } |
{ "unclosed": true | BracketCloseLack | } |
{ "unclosed": "terminating" | BracketCloseLack | } |
{ { "unclosed": 99 | BracketCloseLack | 2 } |
{ "unclosed": [ 42 } | BracketCloseLack | ] |
{ "unclosed": [ 42 ] ] } | BracketClosePlus | ] |
{ "unclosed": [ 42 ] ] ] } | BracketClosePlus | 2 ] |
{ "commented": /* middle true } | CommentEnd | middle true } |
fault
[Quelltext bearbeiten]- Bracket0
- INVALID JSONutil.fault commons:Data: boolean – Trailing1
- BracketCloseLack
- INVALID JSONutil.fault commons:Data: boolean – Trailing2
- BracketClosePlus
- INVALID JSONutil.fault commons:Data: boolean – Trailing3
- CommaEnd
- INVALID JSONutil.fault commons:Data: boolean – Trailing4
- CommentEnd
- INVALID JSONutil.fault commons:Data: boolean – Trailing5
- ControlChar
- INVALID JSONutil.fault commons:Data: boolean – Trailing6
- Qoute
- INVALID JSONutil.fault commons:Data: boolean – Trailing7
- QouteEnd
- INVALID JSONutil.fault commons:Data: boolean – Trailing8
- Trailing
- INVALID JSONutil.fault commons:Data: boolean – Trailing9
fetch
[Quelltext bearbeiten]Same cases as with #fiat.
{
"simple": "assignment"
}
{
"beg": "\"escaped quote",
"mid": "escaped\"quote",
"end": "escaped quote\""
}
{
"multiline": "Some text\nin several lines\nalso with\ttabulator"
}
{
"lineseps": "Ux\nstyle and\nApple and MS\nDOS"
}
{
"commented": true
}
{
"commented": true
}
{
"commented": true
}
{
"commented": "edge"
}
{
"NoComment": "An URL http://example.org/ is not a comment"
}
<span class="error">INVALID JSONutil.fault commons:Data: boolean – No JSON</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – garbage</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – 'apostrophes' }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – qoute }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – qoute (escaped)\" }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – tab" }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – , }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – , ] }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – : true, }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – 2 }</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – ]</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – ]</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – 2 ]</span>
<span class="error">INVALID JSONutil.fault commons:Data: boolean – middle true }</span>