Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Nyoron/anyToString/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local m = require('Module:Sandbox/Nyoron/anyToString') -- Test data local var_nil = nil local var_boolean_true = true local var_boolean_false = false local var_string = "string-text" local var_number = 1234.567 local var_function1 = function() return "return of function1" end local var_function2 = function() return "return of function2" end local var_function3 = function() return "return of function3" end local var_function4 = function() return "return of function4" end local var_table8 = { } local var_table7 = { } local var_table6 = { } local var_table5 = { } local var_table4 = { [1] = true, [2] = false, [3] = "t5 value for key string", [4] = 5678, [5] = var_function1, [6] = var_function2, [7] = var_function3, [8] = var_function4, [9] = var_table6, ["var_table1"] = var_table1, ["var_table2"] = var_table2, ["var_table3"] = var_table3, ["var_table4"] = var_table4, -- var_table4 is not defined at this point. same as nil. ["var_table5"] = var_table5, ["var_table6"] = var_table6, ["var_table7"] = var_table7, ["var_table8"] = var_table8, } local var_table3 = { [true] = true, [false] = false, ["string"] = "t3 value for key string", [3456] = 3456, [var_function2] = var_function2, [var_function3] = var_function3, [var_function4] = var_function4, ["var_function2"] = var_function2, ["var_function3"] = var_function3, ["var_function4"] = var_function4, ["var_table4"] = var_table4, [var_table4] = "t3 value for key table 4", [var_table5] = "t3 value for key table 5", [var_table6] = "t3 value for key table 6", [var_table7] = "t3 value for key table 7", [var_table8] = "t3 value for key table 8", } local var_table2 = { ["var_nil"] = nil, -- setting nil value removes the key ["var_boolean_true"] = true, ["var_boolean_false"] = false, ["var_string"] = "t2 value for key string", ["var_number"] = 2345, ["var_function2"] = var_function2, [var_function2] = var_function2, ["var_table3"] = var_table3, [var_table3] = "t2 value for key table 3", } local var_table1 = { [1] = true, [2] = false, [3] = "t1 value for key string", [4] = 1234, [5] = var_function, [6] = var_table1, -- var_table1 is not defined at this point. same as nil. [7] = var_table2, [8] = var_table3, [9] = var_table4, [10] = var_table5, -- [nil] = "t1 value for key nil", -- nil key is invalid in Lua [true] = "t1 value for key boolean true", [false] = "t1 value for key boolean false", ["string"] = "t1 value for key string", [1234] = "t1 value for key number", [var_function1] = "t1 value for key function1", [var_table2] = "t1 value for key table 2", ["var_table2"] = var_table2, } p.run_tests = function(frame) local result = '' result = "<pre>" result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_nil)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_boolean_true)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_boolean_false)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_string)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_number)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_function)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_table1, false, 0, 4)) result = mw.ustring.format("%s%s<br/>",result,m.anyToString(var_table1, true, 4, 4)) result = mw.ustring.format("%s%s<br/>",result,mw.dumpObject(var_table1)) -- https://en.wikipedia.org/wiki/MediaWiki:Titleblacklist result = mw.ustring.format("%s%s<br/>",result,m.anyToString( mw.ext.TitleBlacklist.test('move','Module:Sandbox/γ«γγγ/REVISIONUSER'))) result = mw.ustring.format("%s%s<br/>",result,m.anyToString( mw.ext.TitleBlacklist.test('move','Module:Sandbox/γ«γγγ/anyToString'))) -- Regarding new-account, see https://meta.wikimedia.org/wiki/Title_blacklist result = mw.ustring.format("%s%s<br/>",result,m.anyToString( mw.ext.TitleBlacklist.test('new-account','AIDS12349876'))) result = result .. "</pre>" return result end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Nyoron/anyToString/testcases/doc
(
edit
)