Advertisement
Double_X

DoubleX RMMV Skill Hotkeys Unit Test v100a

Sep 8th, 2017 (edited)
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Skill Hotkeys Unit Test                                  
  6.  *----------------------------------------------------------------------------
  7.  *    # Introduction                                                          
  8.  *    1. This plugin performs some rudimetary invariants checking for the    
  9.  *       implementations of DoubleX RMMV Skill Hotkeys, and some elementary  
  10.  *       value validity checking for the parameters/configurations/notetags of
  11.  *       DoubleX RMMV Skill Hotkeys                                          
  12.  *    2. When a unit test failed, its error messages along with the stack    
  13.  *       trace leading to the failed test will be displayed as errors in the  
  14.  *       console                                                              
  15.  *----------------------------------------------------------------------------
  16.  *    # Terms Of Use                                                          
  17.  *      1. Commercial use's always allowed and crediting me's always optional.
  18.  *      2. You shall keep this plugin's Plugin Info part's contents intact.  
  19.  *      3. You shalln't claim that this plugin's written by anyone other than
  20.  *         DoubleX or my aliases. I always reserve the right to deny you from
  21.  *         using any of my plugins anymore if you've violated this.          
  22.  *      4. CC BY 4.0, except those conflicting with any of the above, applies
  23.  *         to this plugin, unless you've my permissions not needing follow so.
  24.  *      5. I always reserve the right to deny you from using this plugin      
  25.  *         anymore if you've violated any of the above.                      
  26.  *----------------------------------------------------------------------------
  27.  *    # Prerequisites                                                        
  28.  *      Plugins:                                                              
  29.  *      1. DoubleX RMMV Skill Hotkeys                                        
  30.  *      Abilities:                                                            
  31.  *      1. Nothing special for most ordinary cases                            
  32.  *      2. Little RMMV plugin development proficiency to fully utilize this  
  33.  *----------------------------------------------------------------------------
  34.  *    # Author Notes                                                          
  35.  *      1. Using this plugin might lead to noticeable performance penalties  
  36.  *----------------------------------------------------------------------------
  37.  *    # Links                                                                
  38.  *      DoubleX RMMV Skill Hotkeys:                                          
  39.  *      1. https://pastebin.com/iEfRMhf3                                      
  40.  *      This plugin:                                                          
  41.  *      1. https://pastebin.com/iHh5frL3                                      
  42.  *      Mentioned Patreon Supporters:
  43.  *      https://www.patreon.com/posts/71738797
  44.  *----------------------------------------------------------------------------
  45.  *    # Instructions                                                          
  46.  *      1. Place this plugin right below DoubleX RMMV Skill Hotkeys          
  47.  *      2. The default plugin file name is                                    
  48.  *         DoubleX RMMV Skill Hotkeys Unit Test v100a                        
  49.  *         If you want to change that, you must edit the value of            
  50.  *         DoubleX_RMMV.Skill_Hotkeys_Unit_Test_File, which must be done via  
  51.  *         opening this plugin js file directly                              
  52.  *----------------------------------------------------------------------------
  53.  *    # Author                                                                
  54.  *      DoubleX                                                              
  55.  *----------------------------------------------------------------------------
  56.  *    # Changelog                                                            
  57.  *      v1.00a(GMT 1000 8-9-2017):                                            
  58.  *      1. 1st version of this plugin finished                                
  59.  *============================================================================*/
  60. /*:
  61.  * @plugindesc Lets you run some unit tests for DoubleX RMMV Skill Hotkeys
  62.  * This plugin's entirely optional and is mainly for debuggers/developers    
  63.  * @author DoubleX
  64.  *
  65.  * @param isAlert
  66.  * @desc Sets whether the alert dialog will be shown when a unit test failed
  67.  * @default false
  68.  *
  69.  *============================================================================
  70.  */
  71.  
  72. var DoubleX_RMMV = DoubleX_RMMV || {};
  73. DoubleX_RMMV["Skill Hotkeys Unit Test"] = "v1.00a";
  74.  
  75. // The plugin file name must be the same as
  76. // DoubleX_RMMV.Skill_Hotkeys_Unit_Test_File
  77. DoubleX_RMMV.Skill_Hotkeys_Unit_Test_File =
  78.         "DoubleX RMMV Skill Hotkeys Unit Test v100a";
  79. //
  80.  
  81. /*============================================================================
  82.  *    ## Plugin Implementations                                              
  83.  *       You need not edit this part as it's about how this plugin works      
  84.  *----------------------------------------------------------------------------
  85.  *    # Plugin Support Info:                                                  
  86.  *      1. Prerequisites                                                      
  87.  *         - Basic knowledge on what unit tests do                            
  88.  *         - Some RMMV plugin development proficiency to fully comprehend this
  89.  *----------------------------------------------------------------------------*/
  90.  
  91. if (DoubleX_RMMV["Skill Hotkeys"]) {
  92.  
  93. /*----------------------------------------------------------------------------*/
  94.  
  95. /*----------------------------------------------------------------------------
  96.  *    # Edit class: Game_Actor                                                
  97.  *      - Uses all parameters/configurations/notetags to run plugin functions
  98.  *----------------------------------------------------------------------------*/
  99.  
  100. DoubleX_RMMV.Skill_Hotkeys_Unit_Test = {
  101.  
  102.     // Stores all the original parameter/configuration/notetag functions
  103.     orig: { params: {}, cfgs: {}, notes: {} },
  104.     //
  105.  
  106.     // Stores all the parameter/configuration/notetag function unit tests
  107.     unitTest: {
  108.  
  109.         // Stores all the parameter function unit tests
  110.         params: {
  111.  
  112.             /**
  113.              * Hotspot/No-op
  114.              * @author DoubleX
  115.              * @param {} result - The result returned by the original function
  116.              * @since v1.00a
  117.              * @version v1.00a
  118.              */
  119.             isEnabled: function(result) {
  120.                 // There's no need to test this parameter as it returns Boolean
  121.                 //
  122.             },
  123.  
  124.             /**
  125.              * Potential Hotspot/No-op
  126.              * @author DoubleX
  127.              * @param {} result - The result returned by the original function
  128.              * @since v1.00a
  129.              * @version v1.00a
  130.              */
  131.             bindNotePriority: function(result) {
  132.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  133.                         checkArrayString.call(this, result, "bindNotePriority");
  134.             }, // bindNotePriority
  135.  
  136.             /**
  137.              * Potential Hotspot/No-op
  138.              * @author DoubleX
  139.              * @param {} result - The result returned by the original function
  140.              * @since v1.00a
  141.              * @version v1.00a
  142.              */
  143.             useNotePriority: function(result) {
  144.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  145.                         checkArrayString.call(this, result, "useNotePriority");
  146.             }, // useNotePriority
  147.  
  148.             /**
  149.              * Potential Hotspot/No-op
  150.              * @author DoubleX
  151.              * @param {} result - The result returned by the original function
  152.              * @since v1.00a
  153.              * @version v1.00a
  154.              */
  155.             bindNoteChainingRule: function(result) {
  156.                 // There's no need to test this parameter as it's always valid
  157.                 //
  158.             }, // bindNoteChainingRule
  159.  
  160.             /**
  161.              * Potential Hotspot/No-op
  162.              * @author DoubleX
  163.              * @param {} result - The result returned by the original function
  164.              * @since v1.00a
  165.              * @version v1.00a
  166.              */
  167.             useNoteChainingRule: function(result) {
  168.                 // There's no need to test this parameter as it's always valid
  169.                 //
  170.             }, // useNoteChainingRule
  171.  
  172.             /**
  173.              * No-op
  174.              * @author DoubleX
  175.              * @param {} result - The result returned by the original function
  176.              * @since v1.00a
  177.              * @version v1.00a
  178.              */
  179.             bindHotkeyText: function(result) {
  180.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  181.                         checkString.call(this, result, "bindHotkeyText");
  182.             }, // bindHotkeyText
  183.  
  184.             /**
  185.              * No-op
  186.              * @author DoubleX
  187.              * @param {} result - The result returned by the original function
  188.              * @since v1.00a
  189.              * @version v1.00a
  190.              */
  191.             useSkillText: function(result) {
  192.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  193.                         checkString.call(this, result, "useSkillText");
  194.             }, // useSkillText
  195.  
  196.             /**
  197.              * Hotspot/No-op
  198.              * @author DoubleX
  199.              * @param {} result - The result returned by the original function
  200.              * @since v1.00a
  201.              * @version v1.00a
  202.              */
  203.             unusableSkillCoverIconPath: function(result) {
  204.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  205.                         checkAtLeastString.call(
  206.                         this, result, "unusableSkillCoverIconPath");
  207.            }, // unusableSkillCoverIconPath
  208.  
  209.             /**
  210.              * Hotspot/No-op
  211.              * @author DoubleX
  212.              * @param {} result - The result returned by the original function
  213.              * @since v1.00a
  214.              * @version v1.00a
  215.              */
  216.             unusableSkillCoverIconName: function(result) {
  217.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  218.                         checkAtLeastString.call(
  219.                         this, result, "unusableSkillCoverIconName");
  220.             }, // unusableSkillCoverIconName
  221.  
  222.             /**
  223.              * Hotspot/No-op
  224.              * @author DoubleX
  225.              * @param {} result - The result returned by the original function
  226.              * @since v1.00a
  227.              * @version v1.00a
  228.              */
  229.             unusableSkillCoverIconHue: function(result) {
  230.                 var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params.unusableSkillCoverIconHue\nresult: " + result;
  231.                 var isFailed = false;
  232.                 if (isNaN(result)) {
  233.                     isFailed = true;
  234.                     msg += "\nFailed! unusableSkillCoverIconHue should return a Number!";
  235.                 } else if (result < -360 || result > 360) {
  236.                     isFailed = true;
  237.                     msg += "\nFailed! unusableSkillCoverIconHue should return a Number ranging from -360 to 360!";
  238.                 }
  239.                 if (!isFailed) return;
  240.                 console.error(msg);
  241.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.
  242.                         call(this);
  243.             }, // unusableSkillCoverIconName
  244.  
  245.             /**
  246.              * Hotspot/No-op
  247.              * @author DoubleX
  248.              * @param {} result - The result returned by the original function
  249.              * @since v1.00a
  250.              * @version v1.00a
  251.              */
  252.             unusableSkillCoverIconSmooth: function(result) {
  253.                 // There's no need to test this parameter as it's always valid
  254.                 //
  255.             }, // unusableSkillCoverIconSmooth
  256.  
  257.             /**
  258.              * Hotspot/No-op
  259.              * @author DoubleX
  260.              * @param {} result - The result returned by the original function
  261.              * @since v1.00a
  262.              * @version v1.00a
  263.              */
  264.             hotkeyCmdWindowW: function(result) {
  265.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  266.                         checkPositiveNum.call(this, result, "hotkeyCmdWindowW");
  267.             }, // hotkeyCmdWindowW
  268.  
  269.             /**
  270.              * Hotspot/No-op
  271.              * @author DoubleX
  272.              * @param {} result - The result returned by the original function
  273.              * @since v1.00a
  274.              * @version v1.00a
  275.              */
  276.             hotkeyCmdWindowH: function(result) {
  277.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  278.                         checkPositiveNum.call(this, result, "hotkeyCmdWindowH");
  279.             }, // hotkeyCmdWindowH
  280.  
  281.             /**
  282.              * Hotspot/No-op
  283.              * @author DoubleX
  284.              * @param {} result - The result returned by the original function
  285.              * @since v1.00a
  286.              * @version v1.00a
  287.              */
  288.             hotkeyCmdWindowX: function(result) {
  289.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  290.                         checkNonNegativeNum.call(
  291.                         this, result, "hotkeyCmdWindowX");
  292.             }, // hotkeyCmdWindowX
  293.  
  294.             /**
  295.              * Hotspot/No-op
  296.              * @author DoubleX
  297.              * @param {} result - The result returned by the original function
  298.              * @since v1.00a
  299.              * @version v1.00a
  300.              */
  301.             hotkeyCmdWindowY: function(result) {
  302.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  303.                         checkNonNegativeNum.call(
  304.                         this, result, "hotkeyCmdWindowY");
  305.             }, // hotkeyCmdWindowY
  306.  
  307.             /**
  308.              * Hotspot/No-op
  309.              * @author DoubleX
  310.              * @param {} result - The result returned by the original function
  311.              * @since v1.00a
  312.              * @version v1.00a
  313.              */
  314.             hotkeyCmdLineH: function(result) {
  315.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  316.                         checkPositiveNum.call(this, result, "hotkeyCmdLineH");
  317.             }, // hotkeyCmdLineH
  318.  
  319.             /**
  320.              * Hotspot/No-op
  321.              * @author DoubleX
  322.              * @param {} result - The result returned by the original function
  323.              * @since v1.00a
  324.              * @version v1.00a
  325.              */
  326.             hotkeyCmdFontSize: function(result) {
  327.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  328.                         checkPositiveNum.call(
  329.                         this, result, "hotkeyCmdFontSize");
  330.             }, // hotkeyCmdFontSize
  331.  
  332.             /**
  333.              * Hotspot/No-op
  334.              * @author DoubleX
  335.              * @param {} result - The result returned by the original function
  336.              * @since v1.00a
  337.              * @version v1.00a
  338.              */
  339.             hotkeyCmdPadding: function(result) {
  340.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  341.                         checkNonNegativeNum.call(
  342.                         this, result, "hotkeyCmdPadding");
  343.             }, // hotkeyCmdPadding
  344.  
  345.             /**
  346.              * Hotspot/No-op
  347.              * @author DoubleX
  348.              * @param {} result - The result returned by the original function
  349.              * @since v1.00a
  350.              * @version v1.00a
  351.              */
  352.             hotkeyCmdTextPadding: function(result) {
  353.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  354.                         checkNonNegativeNum.call(
  355.                         this, result, "hotkeyCmdTextPadding");
  356.             }, // hotkeyCmdTextPadding
  357.  
  358.             /**
  359.              * Hotspot/No-op
  360.              * @author DoubleX
  361.              * @param {} result - The result returned by the original function
  362.              * @since v1.00a
  363.              * @version v1.00a
  364.              */
  365.             hotkeyCmdBackOpacity: function(result) {
  366.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  367.                         checkOpacityNum.call(
  368.                         this, result, "hotkeyCmdBackOpacity");
  369.             }, // hotkeyCmdBackOpacity
  370.  
  371.             /**
  372.              * Hotspot/No-op
  373.              * @author DoubleX
  374.              * @param {} result - The result returned by the original function
  375.              * @since v1.00a
  376.              * @version v1.00a
  377.              */
  378.             hotkeyCmdTranslucentOpacity: function(result) {
  379.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  380.                         checkOpacityNum.call(
  381.                         this, result, "hotkeyCmdTranslucentOpacity");
  382.             }, // hotkeyCmdTranslucentOpacity
  383.  
  384.             /**
  385.              * Hotspot/No-op
  386.              * @author DoubleX
  387.              * @param {} result - The result returned by the original function
  388.              * @since v1.00a
  389.              * @version v1.00a
  390.              */
  391.             hotkeyCmdSpacing: function(result) {
  392.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  393.                         checkNonNegativeNum.call(
  394.                         this, result, "hotkeyCmdSpacing");
  395.             }, // hotkeyCmdSpacing
  396.  
  397.             /**
  398.              * Hotspot/No-op
  399.              * @author DoubleX
  400.              * @param {} result - The result returned by the original function
  401.              * @since v1.00a
  402.              * @version v1.00a
  403.              */
  404.             hotkeyListWindowW: function(result) {
  405.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  406.                         checkPositiveNum.call(
  407.                         this, result, "hotkeyListWindowW");
  408.             }, // hotkeyListWindowW
  409.  
  410.             /**
  411.              * Hotspot/No-op
  412.              * @author DoubleX
  413.              * @param {} result - The result returned by the original function
  414.              * @since v1.00a
  415.              * @version v1.00a
  416.              */
  417.             hotkeyListWindowH: function(result) {
  418.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  419.                         checkPositiveNum.call(
  420.                         this, result, "hotkeyListWindowH");
  421.             }, // hotkeyListWindowH
  422.  
  423.             /**
  424.              * Hotspot/No-op
  425.              * @author DoubleX
  426.              * @param {} result - The result returned by the original function
  427.              * @since v1.00a
  428.              * @version v1.00a
  429.              */
  430.             hotkeyListWindowX: function(result) {
  431.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  432.                         checkNonNegativeNum.call(
  433.                         this, result, "hotkeyListWindowX");
  434.             }, // hotkeyListWindowX
  435.  
  436.             /**
  437.              * Hotspot/No-op
  438.              * @author DoubleX
  439.              * @param {} result - The result returned by the original function
  440.              * @since v1.00a
  441.              * @version v1.00a
  442.              */
  443.             hotkeyListWindowY: function(result) {
  444.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  445.                         checkNonNegativeNum.call(
  446.                         this, result, "hotkeyListWindowY");
  447.             }, // hotkeyListWindowY
  448.  
  449.             /**
  450.              * Hotspot/No-op
  451.              * @author DoubleX
  452.              * @param {} result - The result returned by the original function
  453.              * @since v1.00a
  454.              * @version v1.00a
  455.              */
  456.             hotkeyListLineH: function(result) {
  457.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  458.                         checkPositiveNum.call(this, result, "hotkeyListLineH");
  459.             }, // hotkeyListLineH
  460.  
  461.             /**
  462.              * Hotspot/No-op
  463.              * @author DoubleX
  464.              * @param {} result - The result returned by the original function
  465.              * @since v1.00a
  466.              * @version v1.00a
  467.              */
  468.             hotkeyListFontSize: function(result) {
  469.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  470.                         checkPositiveNum.call(
  471.                         this, result, "hotkeyListFontSize");
  472.             }, // hotkeyListFontSize
  473.  
  474.             /**
  475.              * Hotspot/No-op
  476.              * @author DoubleX
  477.              * @param {} result - The result returned by the original function
  478.              * @since v1.00a
  479.              * @version v1.00a
  480.              */
  481.             hotkeyListPadding: function(result) {
  482.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  483.                         checkNonNegativeNum.call(
  484.                         this, result, "hotkeyListPadding");
  485.             }, // hotkeyListPadding
  486.  
  487.             /**
  488.              * Hotspot/No-op
  489.              * @author DoubleX
  490.              * @param {} result - The result returned by the original function
  491.              * @since v1.00a
  492.              * @version v1.00a
  493.              */
  494.             hotkeyListTextPadding: function(result) {
  495.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  496.                         checkNonNegativeNum.call(
  497.                         this, result, "hotkeyListTextPadding");
  498.             }, // hotkeyListTextPadding
  499.  
  500.             /**
  501.              * Hotspot/No-op
  502.              * @author DoubleX
  503.              * @param {} result - The result returned by the original function
  504.              * @since v1.00a
  505.              * @version v1.00a
  506.              */
  507.             hotkeyListBackOpacity: function(result) {
  508.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  509.                         checkOpacityNum.call(
  510.                         this, result, "hotkeyListBackOpacity");
  511.             }, // hotkeyListBackOpacity
  512.  
  513.             /**
  514.              * Hotspot/No-op
  515.              * @author DoubleX
  516.              * @param {} result - The result returned by the original function
  517.              * @since v1.00a
  518.              * @version v1.00a
  519.              */
  520.             hotkeyListTranslucentOpacity: function(result) {
  521.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  522.                         checkOpacityNum.call(
  523.                         this, result, "hotkeyListTranslucentOpacity");
  524.             }, // hotkeyListTranslucentOpacity
  525.  
  526.             /**
  527.              * Hotspot/No-op
  528.              * @author DoubleX
  529.              * @param {} result - The result returned by the original function
  530.              * @since v1.00a
  531.              * @version v1.00a
  532.              */
  533.             hotkeyListSpacing: function(result) {
  534.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  535.                         checkNonNegativeNum.call(
  536.                         this, result, "hotkeyListSpacing");
  537.             }, // hotkeyListSpacing
  538.  
  539.             /**
  540.              * Hotspot/No-op
  541.              * @author DoubleX
  542.              * @param {} result - The result returned by the original function
  543.              * @since v1.00a
  544.              * @version v1.00a
  545.              */
  546.             hotkeyCmdListWindowW: function(result) {
  547.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  548.                         checkPositiveNum.call(
  549.                         this, result, "hotkeyCmdListWindowW");
  550.             }, // hotkeyCmdListWindowW
  551.  
  552.             /**
  553.              * Hotspot/No-op
  554.              * @author DoubleX
  555.              * @param {} result - The result returned by the original function
  556.              * @since v1.00a
  557.              * @version v1.00a
  558.              */
  559.             hotkeyCmdListWindowH: function(result) {
  560.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  561.                         checkPositiveNum.call(
  562.                         this, result, "hotkeyCmdListWindowH");
  563.             }, // hotkeyCmdListWindowH
  564.  
  565.             /**
  566.              * Hotspot/No-op
  567.              * @author DoubleX
  568.              * @param {} result - The result returned by the original function
  569.              * @since v1.00a
  570.              * @version v1.00a
  571.              */
  572.             hotkeyCmdListWindowX: function(result) {
  573.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  574.                         checkNonNegativeNum.call(
  575.                         this, result, "hotkeyCmdListWindowX");
  576.             }, // hotkeyCmdListWindowX
  577.  
  578.             /**
  579.              * Hotspot/No-op
  580.              * @author DoubleX
  581.              * @param {} result - The result returned by the original function
  582.              * @since v1.00a
  583.              * @version v1.00a
  584.              */
  585.             hotkeyCmdListWindowY: function(result) {
  586.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  587.                         checkNonNegativeNum.call(
  588.                         this, result, "hotkeyCmdListWindowY");
  589.             }, // hotkeyCmdListWindowY
  590.  
  591.             /**
  592.              * Hotspot/No-op
  593.              * @author DoubleX
  594.              * @param {} result - The result returned by the original function
  595.              * @since v1.00a
  596.              * @version v1.00a
  597.              */
  598.             hotkeyCmdListLineH: function(result) {
  599.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  600.                         checkPositiveNum.call(
  601.                         this, result, "hotkeyCmdListLineH");
  602.             }, // hotkeyCmdListLineH
  603.  
  604.             /**
  605.              * Hotspot/No-op
  606.              * @author DoubleX
  607.              * @param {} result - The result returned by the original function
  608.              * @since v1.00a
  609.              * @version v1.00a
  610.              */
  611.             hotkeyCmdListFontSize: function(result) {
  612.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  613.                         checkPositiveNum.call(
  614.                         this, result, "hotkeyCmdListFontSize");
  615.             }, // hotkeyCmdListFontSize
  616.  
  617.             /**
  618.              * Hotspot/No-op
  619.              * @author DoubleX
  620.              * @param {} result - The result returned by the original function
  621.              * @since v1.00a
  622.              * @version v1.00a
  623.              */
  624.             hotkeyCmdListPadding: function(result) {
  625.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  626.                         checkNonNegativeNum.call(
  627.                         this, result, "hotkeyCmdListPadding");
  628.             }, // hotkeyCmdListPadding
  629.  
  630.             /**
  631.              * Hotspot/No-op
  632.              * @author DoubleX
  633.              * @param {} result - The result returned by the original function
  634.              * @since v1.00a
  635.              * @version v1.00a
  636.              */
  637.             hotkeyCmdListTextPadding: function(result) {
  638.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  639.                         checkNonNegativeNum.call(
  640.                         this, result, "hotkeyCmdListTextPadding");
  641.             }, // hotkeyCmdListTextPadding
  642.  
  643.             /**
  644.              * Hotspot/No-op
  645.              * @author DoubleX
  646.              * @param {} result - The result returned by the original function
  647.              * @since v1.00a
  648.              * @version v1.00a
  649.              */
  650.             hotkeyCmdListBackOpacity: function(result) {
  651.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  652.                         checkOpacityNum.call(
  653.                         this, result, "hotkeyCmdListBackOpacity");
  654.             }, // hotkeyCmdListBackOpacity
  655.  
  656.             /**
  657.              * Hotspot/No-op
  658.              * @author DoubleX
  659.              * @param {} result - The result returned by the original function
  660.              * @since v1.00a
  661.              * @version v1.00a
  662.              */
  663.             hotkeyCmdListTranslucentOpacity: function(result) {
  664.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  665.                         checkOpacityNum.call(
  666.                         this, result, "hotkeyCmdListTranslucentOpacity");
  667.             }, // hotkeyCmdListTranslucentOpacity
  668.  
  669.             /**
  670.              * Hotspot/No-op
  671.              * @author DoubleX
  672.              * @param {} result - The result returned by the original function
  673.              * @since v1.00a
  674.              * @version v1.00a
  675.              */
  676.             hotkeyCmdListSpacing: function(result) {
  677.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.checkFuncs.
  678.                         checkNonNegativeNum.call(
  679.                         this, result, "hotkeyCmdListSpacing");
  680.             } // hotkeyCmdListSpacing
  681.  
  682.         }, // params
  683.         //
  684.  
  685.         // Stores all the configuration function unit tests
  686.         cfgs: {
  687.  
  688.             /**
  689.              * Potential Hotspot/No-op
  690.              * @author DoubleX
  691.              * @param {} result - The result returned by the original function
  692.              * @since v1.00a
  693.              * @version v1.00a
  694.              */
  695.             hotkeyNames: function(result) {
  696.                 var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params.hotkeyNames";
  697.                 msg += "\nresult: " + result;
  698.                 var isFailed = false;
  699.                 if (result !== Object(result)) {
  700.                     isFailed = true;
  701.                     msg += "\nFailed! hotkeyNames should return an Object!";
  702.                 } else {
  703.                     var hotkeys = Object.keys(result), length = hotkeys.length;
  704.                     for (var index = 0; index < length; index++) {
  705.                         var val = result[hotkeys[index]];
  706.                         if (typeof val === 'string' || val instanceof String) {
  707.                             continue;
  708.                         }
  709.                         isFailed = true;
  710.                         msg += "\nFailed! The name " + val +
  711.                                 " whose key having index " + index +
  712.                                 " should be a String!";
  713.                     }
  714.                 }
  715.                 if (!isFailed) return;
  716.                 console.error(msg);
  717.                 DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.
  718.                         call(this);
  719.             } // hotkeyNames
  720.  
  721.         }, // cfgs
  722.         //
  723.  
  724.         notes: {} // Stores all the notetag function unit tests
  725.  
  726.     }, // unitTest
  727.     //
  728.  
  729.     checkFuncs: {
  730.  
  731.         /**
  732.          * Hotspot/No-op
  733.          * @author DoubleX
  734.          * @param {} result - The result returned by the original function
  735.          * @param {String} funcName - The name of the original function
  736.          * @since v1.00a
  737.          * @version v1.00a
  738.          */
  739.         checkArrayString: function(result, funcName) {
  740.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  741.                     funcName + "\nresult: " + result;
  742.             var isFailed = false;
  743.             if (!Array.isArray(result)) {
  744.                 isFailed = true;
  745.                 msg += "\nFailed! " + funcName + " should return an Array!";
  746.             } else {
  747.                 var length = result.length;
  748.                 var validVals = [
  749.                     "states",
  750.                     "armors",
  751.                     "weapons",
  752.                     "classes",
  753.                     "actors"
  754.                 ];
  755.                 msg += "\nvalidVals: " + validVals;
  756.                 for (var index = 0; index < length; index++) {
  757.                     var val = result[index];
  758.                     if (validVals.indexOf(val) >= 0) continue;
  759.                     isFailed = true;
  760.                     msg += "\nFailed! The element " + val + " having index " +
  761.                             index + " should be within validVals!";
  762.                 }
  763.             }
  764.             if (!isFailed) return;
  765.             console.error(msg);
  766.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  767.                     this);
  768.         }, // checkArrayString
  769.  
  770.         /**
  771.          * Hotspot/No-op
  772.          * @author DoubleX
  773.          * @param {} result - The result returned by the original function
  774.          * @param {String} funcName - The name of the original function
  775.          * @since v1.00a
  776.          * @version v1.00a
  777.          */
  778.         checkString: function(result, funcName) {
  779.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  780.                     funcName + "\nresult: " + result;
  781.             if (typeof result === 'string' || result instanceof String) return;
  782.             msg += "\nFailed! " + funcName + " should return a String!";
  783.             console.error(msg);
  784.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  785.                     this);
  786.         }, // checkString
  787.  
  788.         /**
  789.          * Hotspot/No-op
  790.          * @author DoubleX
  791.          * @param {} result - The result returned by the original function
  792.          * @param {String} funcName - The name of the original function
  793.          * @since v1.00a
  794.          * @version v1.00a
  795.          */
  796.         checkAtLeastString: function(result, funcName) {
  797.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  798.                     funcName + "\nresult: " + result;
  799.             if (typeof result === 'string' || result instanceof String) return;
  800.             msg += "\nFailed! " + funcName +
  801.                     " should at least return a String!";
  802.             console.error(msg);
  803.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  804.                     this);
  805.         }, // checkAtLeastString
  806.  
  807.         /**
  808.          * Hotspot/No-op
  809.          * @author DoubleX
  810.          * @param {} result - The result returned by the original function
  811.          * @param {String} funcName - The name of the original function
  812.          * @since v1.00a
  813.          * @version v1.00a
  814.          */
  815.         checkPositiveNum: function(result, funcName) {
  816.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  817.                     funcName + "\nresult: " + result;
  818.             var isFailed = false;
  819.             if (isNaN(result)) {
  820.                 isFailed = true;
  821.                 msg += "\nFailed! " + funcName + " should return a Number!";
  822.             } else if (result <= 0) {
  823.                 isFailed = true;
  824.                 msg += "\nFailed! " + funcName +
  825.                         " should return a positive Number!";
  826.             }
  827.             if (!isFailed) return;
  828.             console.error(msg);
  829.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  830.                     this);
  831.         }, // checkPositiveNum
  832.  
  833.         /**
  834.          * Hotspot/No-op
  835.          * @author DoubleX
  836.          * @param {} result - The result returned by the original function
  837.          * @param {String} funcName - The name of the original function
  838.          * @since v1.00a
  839.          * @version v1.00a
  840.          */
  841.         checkNonNegativeNum: function(result, funcName) {
  842.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  843.                     funcName + "\nresult: " + result;
  844.             var isFailed = false;
  845.             if (isNaN(result)) {
  846.                 isFailed = true;
  847.                 msg += "\nFailed! " + funcName + " should return a Number!";
  848.             } else if (result < 0) {
  849.                 isFailed = true;
  850.                 msg += "\nFailed! " + funcName +
  851.                         " should return a nonnegative Number!";
  852.             }
  853.             if (!isFailed) return;
  854.             console.error(msg);
  855.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  856.                     this);
  857.         }, // checkNonNegativeNum
  858.  
  859.         /**
  860.          * Hotspot/No-op
  861.          * @author DoubleX
  862.          * @param {} result - The result returned by the original function
  863.          * @param {String} funcName - The name of the original function
  864.          * @since v1.00a
  865.          * @version v1.00a
  866.          */
  867.         checkOpacityNum: function(result, funcName) {
  868.             var msg = "DoubleX_RMMV.Skill_Hotkeys_Unit_Test.unitTest.params." +
  869.                     funcName + "\nresult: " + result;
  870.             var isFailed = false;
  871.             if (isNaN(result)) {
  872.                 isFailed = true;
  873.                 msg += "\nFailed! " + funcName + " should return a Number!";
  874.             } else if (result < 0 || result > 255) {
  875.                     isFailed = true;
  876.                     msg += "\nFailed! " + funcName +
  877.                             " should return a Number ranging from 0 to 255!";
  878.                 }
  879.             if (!isFailed) return;
  880.             console.error(msg);
  881.             DoubleX_RMMV.Skill_Hotkeys_Unit_Test.printFailedTestStackTrace.call(
  882.                     this);
  883.         } // checkOpacityNum
  884.  
  885.     }, // checkFuncs
  886.  
  887.     /**
  888.      * Pure function
  889.      * @author DoubleX
  890.      * @param {String} type - The parameter/configuration/notetag indicator
  891.      * @param {String} name - The parameter/configuration/notetag name
  892.      * @returns {Function(Number/Nullable, Object/Nullable)} The function with
  893.      *                                                      unit tests
  894.      * @since v1.00a
  895.      * @version v1.00a
  896.      */
  897.     unitTestFunc: function(type, name) {
  898.         /**
  899.          * Nullipotent
  900.          * @author DoubleX
  901.          * @returns {} The requested result
  902.          * @since v1.00a
  903.          * @version v1.00a
  904.          */
  905.         return function() { // v1.00a - v1.00a; Extended
  906.             var SHUT = DoubleX_RMMV.Skill_Hotkeys_Unit_Test;
  907.             var result = SHUT.orig[type][name].apply(this, arguments);
  908.             // Added to test the parameter/configuration/notetag value validity
  909.             SHUT.unitTest[type][name].call(this, result);
  910.             return result;
  911.             //
  912.         };
  913.     }, // unitTestFunc
  914.  
  915.     /**
  916.      * No-op
  917.      * @author DoubleX
  918.      * @since v1.00a
  919.      * @version v1.00a
  920.      */
  921.     printFailedTestStackTrace: function() {
  922.         // Deliberately make an error that's catched to get the stack trace
  923.         try {
  924.             x;
  925.         } catch (err) {
  926.             console.error("The stacktrace leading to this failed test:");
  927.             console.error(err);
  928.             if (DoubleX_RMMV.Skill_Hotkeys_Unit_Test.isAlert.call(this)) {
  929.                 alert("A unit test in DoubleX RMMV Skill Hotkeys has failed. Please check the console for details.");
  930.             }
  931.         }
  932.         //
  933.     }, // printFailedTestStackTrace
  934.  
  935.     /**
  936.      * Nullipotent
  937.      * @author DoubleX
  938.      * @returns {Boolean} The check result
  939.      * @since v1.00a
  940.      * @version v1.00a
  941.      */
  942.     isAlert: function() {
  943.         return PluginManager.parameters(DoubleX_RMMV.Skill_Hotkeys_File).
  944.                 isAlert === "true";
  945.     } // isAlert
  946.  
  947. }; // DoubleX_RMMV.Skill_Hotkeys_Unit_Test
  948.  
  949. (function(SH, SHUT) {
  950.  
  951.     "use strict";
  952.  
  953.     // There's no need to test this parameter as it's always valid
  954.     var notes = SHUT.unitTest.notes, checkFunc = new Function("result", "");
  955.     //
  956.     Object.keys(SH.notes).forEach(function(note) { notes[note] = checkFunc; });
  957.  
  958. })(DoubleX_RMMV.Skill_Hotkeys, DoubleX_RMMV.Skill_Hotkeys_Unit_Test);
  959.  
  960. /*----------------------------------------------------------------------------
  961.  *    # Edit class: DataManager                                              
  962.  *      - Extends all parameter/configuration/notetag functions upon load game
  963.  *----------------------------------------------------------------------------*/
  964.  
  965. (function(SH, SHUT) {
  966.  
  967.     "use strict";
  968.  
  969.     SH.DataManager.unitTest = { orig: {}, new: {} };
  970.     var _SH = SH.DataManager.new;
  971.     var _DM = SH.DataManager.unitTest.orig, _UT = SH.DataManager.unitTest.new;
  972.  
  973.     /**
  974.      * The this pointer is DataManager
  975.      * Idempotent
  976.      * @author DoubleX
  977.      * @param {String} funcType - The parameter/configuration/notetag label
  978.      * @param {String} content - The name of the stored function content
  979.      * @since v1.00a
  980.      * @version v1.00a
  981.      */
  982.     _DM._extractFuncContent = _SH._extractFuncContent;
  983.     _SH._extractFuncContent = function(funcType, content) {
  984.     // v1.00a - v1.00a; Extended
  985.         _DM._extractFuncContent.apply(this, arguments);
  986.         // Added to unit test the value validity of param/cfg/note functions
  987.         _UT._extractFuncContent.call(this, funcType, content);
  988.         //
  989.     }; // _SH._extractFuncContent
  990.  
  991.     /**
  992.      * The this pointer is DataManager
  993.      * @author DoubleX
  994.      * @param {String} funcType - The parameter/configuration/notetag label
  995.      * @param {String} content - The name of the stored function content
  996.      * @since v1.00a
  997.      * @version v1.00a
  998.      */
  999.     _UT._extractFuncContent = function(funcType, content) {
  1000.         SHUT.orig[funcType][content] = SH[funcType][content];
  1001.         SH[funcType][content] = SHUT.unitTestFunc.call(this, funcType, content);
  1002.     }; // _UT._extractFuncContent
  1003.  
  1004. })(DoubleX_RMMV.Skill_Hotkeys, DoubleX_RMMV.Skill_Hotkeys_Unit_Test);
  1005.  
  1006. /*----------------------------------------------------------------------------
  1007.  *    # Edit class: Game_System                                              
  1008.  *      - Extends all parameter/configuration/notetag functions upon load game
  1009.  *----------------------------------------------------------------------------*/
  1010.  
  1011. (function(SH, SHUT) {
  1012.  
  1013.     "use strict";
  1014.  
  1015.     SH.Game_System.unitTest = { orig: {}, new: {} };
  1016.     var _SH = SH.Game_System.new;
  1017.     var _GS = SH.Game_System.unitTest.orig, _UT = SH.Game_System.unitTest.new;
  1018.  
  1019.     /**
  1020.      * The this pointer is Game_System.prototype
  1021.      * Idempotent
  1022.      * @author DoubleX
  1023.      * @param {Object[String, String]} params - The params/cfgs name-value map
  1024.      * @param {String} param - The name of the parameter/configuration
  1025.      * @since v1.00a
  1026.      * @version v1.00a
  1027.      */
  1028.     _GS._storeParam = _SH._storeParam;
  1029.     _SH._storeParam = function(params, param) { // v1.00a - v1.00a; Extended
  1030.         // Added to prevent storing the extended parameter function contents
  1031.         if (SHUT.orig.params[param]) return;
  1032.         //
  1033.         _GS._storeParam.apply(this, arguments);
  1034.         // Added to unit test the value validity of all parameter functions
  1035.         _UT._storeParam.call(this, param);
  1036.         //
  1037.     }; // _SH._storeParam
  1038.  
  1039.     /**
  1040.      * The this pointer is Game_System.prototype
  1041.      * Idempotent
  1042.      * @author DoubleX
  1043.      * @param {String} cfgType - The configuration type label
  1044.      * @param {String} cfg - The name of the configuration
  1045.      * @since v1.00a
  1046.      * @version v1.00a
  1047.      */
  1048.     _GS._storeCfg = _SH._storeCfg;
  1049.     _SH._storeCfg = function(cfgType, cfg) {
  1050.         // Edited to prevent storing the extended cfg/note function contents
  1051.         if (SHUT.orig[cfgType][cfg]) return;
  1052.         //
  1053.         _GS._storeCfg.apply(this, arguments);
  1054.         // Added to unit test the value validity of all cfg/note functions
  1055.         _UT._storeCfg.call(this, cfgType, cfg);
  1056.         //
  1057.     }; // _SH._storeCfg
  1058.  
  1059.     /**
  1060.      * The this pointer is Game_Actor.prototype
  1061.      * @author DoubleX
  1062.      * @param {String} param - The name of the parameter/configuration
  1063.      * @since v1.00a
  1064.      * @version v1.00a
  1065.      */
  1066.     _UT._storeParam = function(param) {
  1067.         _UT._storeCfg.call(this, "params", param);
  1068.     }; // _UT._storeParam
  1069.  
  1070.     /**
  1071.      * The this pointer is Game_Actor.prototype
  1072.      * @author DoubleX
  1073.      * @param {String} cfgType - The configuration type label
  1074.      * @param {String} cfg - The name of the configuration
  1075.      * @since v1.00a
  1076.      * @version v1.00a
  1077.      */
  1078.     _UT._storeCfg = function(cfgType, cfg) {
  1079.         SHUT.orig[cfgType][cfg] = SH[cfgType][cfg];
  1080.         SH[cfgType][cfg] = SHUT.unitTestFunc.call(this, cfgType, cfg);
  1081.     }; // _UT._storeCfg
  1082.  
  1083. })(DoubleX_RMMV.Skill_Hotkeys, DoubleX_RMMV.Skill_Hotkeys_Unit_Test);
  1084.  
  1085. /*----------------------------------------------------------------------------
  1086.  *    # Edit class: Game_Actor                                                
  1087.  *      - Unit tests all the nontrivial non-tautological class invariants    
  1088.  *----------------------------------------------------------------------------*/
  1089.  
  1090. (function(SH, SHUT) {
  1091.  
  1092.     "use strict";
  1093.  
  1094.     SH.Game_Actor.unitTest = { orig: {}, new: {} };
  1095.     var _SH = SH.Game_Actor.new;
  1096.     var _GA = SH.Game_Actor.unitTest.orig, _UT = SH.Game_Actor.unitTest.new;
  1097.  
  1098.     _GA.bindSkillHotkey = _SH._bind;
  1099.     _SH._bind = function(skillId, hotkey) { // v1.00a - v1.00a; Extended
  1100.         _GA.bindSkillHotkey.apply(this, arguments);
  1101.         // Added to unit test class invariants involving this function
  1102.         _UT._bind.call(this, skillId, hotkey);
  1103.         //
  1104.     }; // _SH._bind
  1105.  
  1106.     /**
  1107.      * The this pointer is Game_Actor.prototype
  1108.      * No-op
  1109.      * @author DoubleX
  1110.      * @param {Number} skillId - The id of the skill to have its hotkey bound
  1111.      * @param {String} hotkey - The symbol of the hotkey to be bound
  1112.      * @since v1.00a
  1113.      * @version v1.00a
  1114.      */
  1115.     _UT._bind = function(skillId, hotkey) {
  1116.         var isBound = this.isSkillHotkeysBound(skillId);
  1117.         if (isBound) return;
  1118.         var msg = "DoubleX_RMMV.Skill_Hotkeys.Game_Actor.unitTest.new._bind";
  1119.         msg += "\nskillId: " + skillId + "\nhotkey: " + hotkey;
  1120.         msg += "\nisBound: " + isBound + "\nFailed! isBound should be truthy!";
  1121.         console.error(msg);
  1122.         SHUT.printFailedTestStackTrace.call(this);
  1123.     }; // _UT._bind
  1124.  
  1125. })(DoubleX_RMMV.Skill_Hotkeys, DoubleX_RMMV.Skill_Hotkeys_Unit_Test);
  1126.  
  1127. /*----------------------------------------------------------------------------*/
  1128.  
  1129. } else {
  1130.     alert("To use Skill Hotkeys Unit Test, place it below Skill Hotkeys.");
  1131. } // if (DoubleX_RMMV["Skill Hotkeys"])
  1132.  
  1133. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement