PageRenderTime 47ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/test/acceptance/as3/Definitions/Classes/Ext/FinExtDynamicClass.as

https://github.com/changm/tessa
ActionScript | 250 lines | 66 code | 70 blank | 114 comment | 0 complexity | 4cbf205e01a21bb79d8026e1a93a90b4 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is [Open Source Virtual Machine.].
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Adobe System Incorporated.
  18. * Portions created by the Initial Developer are Copyright (C) 2004-2006
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Adobe AS3 Team
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. package DynamicClass{
  38. /**
  39. * The 'import' statements should be the first
  40. * non-comment line in a file.
  41. *
  42. * These lines have to be commented out.
  43. * The compiler requires only the parent Class to be imported and not the Subclass folder.
  44. * Hence change in the import statements required.
  45. * import Definitions.Classes.Simple;
  46. * import Definitions.Classes.Ext.FinExtDynamicClass;
  47. */
  48. import DynamicClass.*;
  49. var SECTION = "Definitions\Ext"; // provide a document reference (ie, ECMA section)
  50. var VERSION = "AS3"; // Version of JavaScript or ECMA
  51. var TITLE = "Final Class Extends Dynamic Class Default Methods"; // Provide ECMA section title or a description
  52. //var BUGNUMBER = "";
  53. startTest(); // leave this alone
  54. /**
  55. * Calls to AddTestCase here. AddTestCase is a function that is defined
  56. * in shell.js and takes three arguments:
  57. * - a string representation of what is being tested
  58. * - the expected result
  59. * - the actual result
  60. *
  61. * For example, a test might look like this:
  62. *
  63. * var helloWorld = "Hello World";
  64. *
  65. * AddTestCase(
  66. * "var helloWorld = 'Hello World'", // description of the test
  67. * "Hello World", // expected result
  68. * helloWorld ); // actual result
  69. *
  70. */
  71. /**
  72. * The 'import' statements should be the first
  73. * non-comment line in a file.
  74. * import Definitions.Classes.Simple;
  75. * import Definitions.Classes.Ext.FinExtDynamicClass;
  76. *
  77. */
  78. // Can't create an instance because it's not public
  79. // Hence commenting out the lines where the class is initialized.
  80. // var EXTDCLASS = new FinExtDynamicClass();
  81. // Create an array variable which will define the test array to be used
  82. // for the given output.
  83. var arr = new Array(1, 2, 3);
  84. // access default method from outside of the class
  85. AddTestCase( "*** Access the default method from outside of the class ***", 1, 1 );
  86. //AddTestCase( "setArray(arr), getArray()", arr, ( setArray( arr ), getArray() ) );
  87. // access default method from a default method of a sub class
  88. AddTestCase( "*** Access default method from default method of sub class ***", 1, 1 );
  89. AddTestCase( "subSetArray( arr ), subGetArray()", arr, ( subSetArray( arr ), subGetArray() ) );
  90. // access default method from a dynamic method of a sub class
  91. AddTestCase( "*** Acess default method from dynamic method of sub class ***", 1, 1 );
  92. AddTestCase( "dynSubSetArray( arr ), dynSubGetArray()", arr, ( dynSubSetArray( arr ), dynSubGetArray()) );
  93. // access default method from a public method of a sub class
  94. AddTestCase( "*** Access default method from public method of sub class ***", 1, 1 );
  95. AddTestCase( "pubSubSetArray( arr ), pubSubGetArray()", arr, ( pubSubSetArray( arr ), pubSubGetArray()) );
  96. // access default method from a private method of a sub class
  97. AddTestCase( "*** Access default method from private method of sub class ***", 1, 1 );
  98. AddTestCase( "testPrivSubArray( arr )", arr, testPrivSubArray( arr ) );
  99. // access default method from a static method of a sub class
  100. AddTestCase( "*** Access default method from static method of sub class ***", 1, 1 );
  101. AddTestCase( "*** Static Method cannot access any other methods except static methods of the parent class ***", 1, 1 );
  102. // AddTestCase( "statSubSetArray( arr ), statSubGetArray()", arr, ( statSubSetArray( arr ), statSubGetArray() ) );
  103. // access default method from a final method of a sub class
  104. AddTestCase( "*** Access default method from final method of sub class ***", 1, 1 );
  105. AddTestCase( "finSubSetArray( arr ), finSubGetArray()", arr, ( finSubSetArray( arr ), finSubGetArray() ) );
  106. // access default method from a virtual method of a sub class
  107. AddTestCase( "*** Access default method from virtual method of sub class ***", 1, 1 );
  108. AddTestCase( "virSubSetArray( arr ), virSubSetArray()", arr, ( virSubSetArray( arr ), virSubGetArray() ) );
  109. // access default method from a public dynamic method of a sub class
  110. AddTestCase( "*** Acess default method from public dynamic method of sub class ***", 1, 1 );
  111. AddTestCase( "pubDynSubSetArray( arr ), pubDynSubGetArray()", arr, ( pubDynSubSetArray( arr ), pubDynSubGetArray()) );
  112. // access default method from a public static method of a sub class
  113. AddTestCase( "*** Access default method from public static method of sub class ***", 1, 1 );
  114. AddTestCase( "*** Static Method cannot access any other methods except static methods of the parent class ***", 1, 1 );
  115. // AddTestCase( "pubStatSubSetArray( arr ), pubStatSubGetArray()", arr, ( pubStatSubSetArray( arr ), pubStatSubGetArray() ) );
  116. // access default method from a public final method of a sub class
  117. AddTestCase( "*** Access default method from public final method of sub class ***", 1, 1 );
  118. AddTestCase( "pubFinSubSetArray( arr ), pubFinSubGetArray()", arr, ( pubFinSubSetArray( arr ), pubFinSubGetArray() ) );
  119. // access default method from a public virtual method of a sub class
  120. AddTestCase( "*** Access default method from public virtual method of sub class ***", 1, 1 );
  121. AddTestCase( "pubVirSubSetArray( arr ), pubVirSubSetArray()", arr, ( pubVirSubSetArray( arr ), pubVirSubGetArray() ) );
  122. // access default method from a final private method of a sub class
  123. AddTestCase( "*** Access default method from final private method of sub class ***", 1, 1 );
  124. AddTestCase( "testPrivFinSubArray( arr )", arr, testPrivFinSubArray( arr ) );
  125. // access default method from a final static method of a sub class
  126. AddTestCase( "*** Access default method from final static method of sub class ***", 1, 1 );
  127. AddTestCase( "*** Static Method cannot access any other methods except static methods of the parent class ***", 1, 1 );
  128. // AddTestCase( "finStatSubSetArray( arr ), finStatSubGetArray()", arr, ( finStatSubSetArray( arr ), finStatSubGetArray() ) );
  129. // access default method from a private static method of a sub class
  130. AddTestCase( "*** Access default method from private static method of sub class ***", 1, 1 );
  131. AddTestCase( "*** Static Method cannot access any other methods except static methods of the parent class ***", 1, 1 );
  132. // AddTestCase( "testPrivStatSubArray( arr )", arr, testPrivStatSubArray( arr ) );
  133. // access default method from a private virtual method of a sub class
  134. AddTestCase( "*** Access default method from private virtual method of sub class ***", 1, 1 );
  135. AddTestCase( "testPrivVirSubArray( arr )", arr, testPrivVirSubArray( arr ) );
  136. // access default property from outside the class
  137. AddTestCase( "*** Access default property from outside the class ***", 1, 1 );
  138. AddTestCase( "array = arr", arr, (array = arr, array) );
  139. // access default property from a default method of a sub class
  140. AddTestCase( "*** Access default property from default method of sub class ***", 1, 1 );
  141. AddTestCase( "subSetDPArray( arr ), subGetDPArray()", arr, ( subSetDPArray( arr ), subGetDPArray() ) );
  142. // access default property from a dynamic method of a sub class
  143. AddTestCase( "*** Access default property from dynamic method of sub class ***", 1, 1 );
  144. AddTestCase( "dynSubSetDPArray( arr ), dynSubGetDPArray()", arr, ( dynSubSetDPArray( arr ), dynSubGetDPArray() ) );
  145. // access default property from a public method of a sub class
  146. AddTestCase( "*** Access default property from public method of sub class ***", 1, 1 );
  147. AddTestCase( "pubSubSetDPArray( arr ), pubSubGetDPArray()", arr, ( pubSubSetDPArray( arr ), pubSubGetDPArray() ) );
  148. // access default property from a private method of a sub class
  149. AddTestCase( "*** Access default property from private method of sub class ***", 1, 1 );
  150. AddTestCase( "testPrivSubDPArray( arr )", arr, testPrivSubDPArray( arr ) );
  151. // access default property from a static method of a sub class
  152. AddTestCase( "*** Access default property from static method of sub class ***", 1, 1 );
  153. AddTestCase( "statSubSetDPArray( arr ), statSubGetDPArray()", arr, ( statSubSetDPArray( arr ), statSubGetDPArray() ) );
  154. // access default property from a final method of a sub class
  155. AddTestCase( "*** Access default property from final method of sub class ***", 1, 1 );
  156. AddTestCase( "finSubSetDPArray( arr ), finSubGetDPArray()", arr, ( finSubSetDPArray( arr ), finSubGetDPArray() ) );
  157. // access default property from a private virtual method of a sub class
  158. AddTestCase( "*** Access default property from private virtual method of sub class ***", 1, 1 );
  159. AddTestCase( "virSubSetDPArray( arr ), virSubGetDPArray()", arr, ( virSubSetDPArray( arr ), virSubGetDPArray() ) );
  160. // access default property from a public static method of a sub class
  161. AddTestCase( "*** Access default property from public static method of sub class ***", 1, 1 );
  162. AddTestCase( "pubStatSubSetDPArray( arr ), pubStatSubGetDPArray()", arr, ( pubStatSubSetDPArray( arr ), pubStatSubGetDPArray() ) );
  163. // access default property from a private static method of a sub class
  164. AddTestCase( "*** Access default property from private static method of sub class ***", 1, 1 );
  165. AddTestCase( "testPrivStatSubDPArray( arr )", arr, testPrivStatSubDPArray( arr ) );
  166. // ********************************************
  167. // Class Prototype Testing
  168. // ********************************************
  169. //Add new property to parent through prototype object, verify child inherits it
  170. var child = new FinExtDynamicClass();
  171. DynamicClassInner.prototype.fakeProp = 100;
  172. AddTestCase("*** Add new property to parent prototype object, verify child class inherits it ***", 100, child.fakeProp);
  173. //Try overriding parent property through prototype object, verify child object has correct value
  174. DynamicClassInner.prototype.pObj = 2;
  175. child = new FinExtDynamicClass();
  176. AddTestCase("*** Try overriding parent property through prototype object, verify child object has correct value ***", 1, child.pObj);
  177. test(); // Leave this function alone.
  178. // This function is for executing the test case and then
  179. // displaying the result on to the console or the LOG file.
  180. }