Wikipedia:Lua/Modul/JSONutil/Test

Vorlagenprogrammierung Diskussionen Lua Test Unterseiten
Modul Deutsch English

Modul: Dokumentation
Weiterleitung der Diskussionsseite fehlt

Test cases of Lua functions; version: 2020-11-08

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 }
Bracket0
First visible character must be { – Trailing1
BracketCloseLack
Closing bracket missing for: – Trailing2
BracketClosePlus
Too many closing brackets: – Trailing3
CommaEnd
Trailing comma after last list item – Trailing4
CommentEnd
Comment starting with /* not terminated by */ – Trailing5
ControlChar
Control character detected other than LF Tab CR (ASCII < 32) – Trailing6
Qoute
Found apostrophe instead of quotation mark – Trailing7
QouteEnd
Terminating quotation mark not found – Trailing8
Trailing
Trailing text behind JSON end detected – Trailing9

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">First visible character must be { &#8211; No JSON</span>


<span class="error">Trailing text behind JSON end detected &#8211; garbage</span>


<span class="error">Found apostrophe instead of quotation mark &#8211; &#039;apostrophes&#039; }</span>


<span class="error">Terminating quotation mark not found &#8211; qoute }</span>


<span class="error">Terminating quotation mark not found &#8211; qoute (escaped)\&quot; }</span>


<span class="error">Control character detected other than LF Tab CR (ASCII < 32) &#8211; tab&quot; }</span>


<span class="error">Trailing comma after last list item &#8211; , }</span>


<span class="error">Trailing comma after last list item &#8211; , ] }</span>


<span class="error">Trailing comma after last list item &#8211; : true, }</span>


<span class="error">Closing bracket missing for: &#8211; }</span>


<span class="error">Closing bracket missing for: &#8211; }</span>


<span class="error">Closing bracket missing for: &#8211; 2 }</span>


<span class="error">Closing bracket missing for: &#8211; ]</span>


<span class="error">Too many closing brackets: &#8211; ]</span>


<span class="error">Too many closing brackets: &#8211; 2 ]</span>


<span class="error">Comment starting with /* not terminated by */ &#8211; middle true }</span>