Jump to content
Wikipedia The Free Encyclopedia

Module:Check for deprecated parameters/testcases

From Wikipedia, the free encyclopedia
This is the test cases page for the module Module:Check for deprecated parameters. Results of the test cases.
 -- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
 localp=require('Module:UnitTests')
 localwarning=require('Module:If preview')._warning
 localmain=require('Module:Check for deprecated parameters')._check
 localsandbox=require('Module:Check for deprecated parameters/sandbox')._check

 -- Remember to run the tests in preview mode! The test code, below, checks for preview correctness also

 localfunctiontest(tester,fcn)
 tester:equals('Nothing deprecated',fcn({A1='B1',A2='B2',_category='C',preview='W'},
 {A0='val'},'caller'),
 '',{nowiki=1,stripmarkers=1})
 tester:equals('Simple',fcn({A1='B1',A2='B2',_category='C',preview='W'},
 {A2='val'},'caller'),
 'C'..warning({'W'}),{nowiki=1,stripmarkers=1})
 tester:equals('Simple with _VALUE_',fcn({A1='B1',A2='B2',_category='C _VALUE_',preview='W _VALUE_'},
 {A2='val'},'caller'),
 'C A2'..warning({'W "A2". Replace with "B2".'}),{nowiki=1,stripmarkers=1})
 tester:equals('Remove',fcn({A1='B1',A2='B2',_category='C',preview='W',_remove='XX; A3; A4'},
 {A3='val'},'caller'),
 'C'..warning({'W'}),{nowiki=1,stripmarkers=1})
 tester:equals('Remove with _VALUE_',fcn({A1='B1',A2='B2',_category='C _VALUE_',preview='W _VALUE_',_remove='XX; A3; A4'},
 {A3='val'},'caller'),
 'C A3'..warning({'W "A3". It should be removed.'}),{nowiki=1,stripmarkers=1})
 tester:equals('No preview',fcn({A1='B1',A2='B2',_category='C _VALUE_'},
 {A2='val'},'caller'),
 'C A2'..warning({'Page using [[caller]] with deprecated parameter "A2". Replace with "B2".'}),{nowiki=1,stripmarkers=1})
 tester:equals('Blank value',fcn({A1='B1',A2='B2',_category='C _VALUE_',preview='W'},
 {A2=' '},'caller'),
 'C A2'..warning({'W'}),{nowiki=1,stripmarkers=1})
 tester:equals('Blank value with ignoreblank',fcn({A1='B1',A2='B2',_category='C _VALUE_',preview='W',ignoreblank=1},
 {A2=' '},'caller'),
 '',{nowiki=1,stripmarkers=1})
 end

 functionp:test_main()
 ifmainthen
 test(p,main)
 end
 end

 functionp:test_sandbox()
 ifsandboxthen
 test(p,sandbox)
 end
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /