PageRenderTime 31ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/changm/tessa
ActionScript | 263 lines | 80 code | 48 blank | 135 comment | 0 complexity | 9c25f24b780055e705a73c99bc163f5d 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. import InternalClass.*;
  38. var SECTION = "Definitions"; // provide a document reference (ie, ECMA section)
  39. var VERSION = "Clean AS2"; // Version of JavaScript or ECMA
  40. var TITLE = "Extend Default Class"; // Provide ECMA section title or a description
  41. var BUGNUMBER = "";
  42. startTest(); // leave this alone
  43. /**
  44. * Calls to AddTestCase here. AddTestCase is a function that is defined
  45. * in shell.js and takes three arguments:
  46. * - a string representation of what is being tested
  47. * - the expected result
  48. * - the actual result
  49. *
  50. * For example, a test might look like this:
  51. *
  52. * var helloWorld = "Hello World";
  53. *
  54. * AddTestCase(
  55. * "var helloWorld = 'Hello World'", // description of the test
  56. * "Hello World", // expected result
  57. * helloWorld ); // actual result
  58. *
  59. */
  60. // ********************************************
  61. // access default method from a default
  62. // method of a sub class
  63. //
  64. // ********************************************
  65. var arr = new Array(1,2,3);
  66. EXTDCLASS = new ExtInternalClass();
  67. AddTestCase( "access 'default' method from 'default' method of sub class", arr, (EXTDCLASS.testSubGetSetArray(arr)) );
  68. // ********************************************
  69. // access default method from a public
  70. // method of a sub class
  71. // ********************************************
  72. arr = new Array( 4, 5, 6 );
  73. EXTDCLASS = new ExtInternalClass();
  74. AddTestCase( "access 'default' method from 'public' method of sub class", arr,
  75. (EXTDCLASS.pubSubSetArray(arr), EXTDCLASS.pubSubGetArray()) );
  76. // ********************************************
  77. // access default method from a final
  78. // method of a sub class
  79. // ********************************************
  80. arr = new Array( "one", "two", "three" );
  81. EXTDCLASS = new ExtInternalClass();
  82. AddTestCase( "access 'default' method from 'final' method of sub class", arr, (EXTDCLASS.testFinSubArray(arr)) );
  83. // ********************************************
  84. // access default method from a public
  85. // final method of a sub class
  86. // ********************************************
  87. arr = new Array( 8, "two", 9 );
  88. EXTDCLASS = new ExtInternalClass();
  89. AddTestCase( "access 'default' method from 'public final' method of sub class", arr,
  90. (EXTDCLASS.pubFinSubSetArray(arr), EXTDCLASS.pubFinSubGetArray()) );
  91. // ********************************************
  92. // access default method from a final
  93. // private method of a sub class
  94. // ********************************************
  95. arr = new Array( "one", "two", "three" );
  96. EXTDCLASS = new ExtInternalClass();
  97. AddTestCase( "access 'default' method from 'private final' method of sub class", arr, (EXTDCLASS.testPrivFinSubArray(arr)) );
  98. // ********************************************
  99. // access default method from a private
  100. // method of a sub class
  101. // ********************************************
  102. arr = new Array( 5, 6, 7 );
  103. EXTDCLASS = new ExtInternalClass();
  104. AddTestCase( "access 'default' method from 'private' method of sub class", arr, EXTDCLASS.testPrivSubArray(arr) );
  105. // ********************************************
  106. // access default method from a virtual
  107. // method of a sub class
  108. // ********************************************
  109. AddTestCase( "access 'default' method from 'virtual' method of sub class", arr,
  110. EXTDCLASS.testVirtSubArray(arr) );
  111. // ********************************************
  112. // access default method from a virtual
  113. // public method of a sub class
  114. // ********************************************
  115. AddTestCase( "access 'default' method from 'public virtual' method of sub class", arr,
  116. (EXTDCLASS.pubVirtSubSetArray(arr), EXTDCLASS.pubVirtSubGetArray()) );
  117. // ********************************************
  118. // access default method from a virtual
  119. // private method of a sub class
  120. // ********************************************
  121. AddTestCase( "access 'default' method from 'private virtual' method of sub class", arr,
  122. EXTDCLASS.testPrivVirtSubArray(arr) );
  123. // ********************************************
  124. // access default method from static
  125. // method of sub class
  126. // ********************************************
  127. var thisError = "no exception thrown";
  128. try{
  129. ExtInternalClass.pubStatSubGetArray();
  130. } catch (e1) {
  131. thisError = e1.toString();
  132. } finally {
  133. AddTestCase( "access 'default' method from 'static' method of the sub class",
  134. TYPEERROR+1006,
  135. typeError( thisError) );
  136. }
  137. // ********************************************
  138. // access default property from
  139. // default method in sub class
  140. // ********************************************
  141. EXTDCLASS = new ExtInternalClass();
  142. AddTestCase( "access 'default' property from 'default' method of sub class", arr,
  143. (EXTDCLASS.testSubGetSetDPArray(arr)) );
  144. // ********************************************
  145. // access default property from
  146. // final method in sub class
  147. // ********************************************
  148. EXTDCLASS = new ExtInternalClass();
  149. AddTestCase( "access 'default' property from 'final' method of sub class", arr,
  150. (EXTDCLASS.testFinSubDPArray(arr)) );
  151. // ********************************************
  152. // access default property from
  153. // virtual method in sub class
  154. // ********************************************
  155. EXTDCLASS = new ExtInternalClass();
  156. AddTestCase( "access 'default' property from 'virtual' method of sub class", arr,
  157. (EXTDCLASS.testVirtSubDPArray(arr)) );
  158. // ********************************************
  159. // access default property from
  160. // public method in sub class
  161. // ********************************************
  162. EXTDCLASS = new ExtInternalClass();
  163. AddTestCase( "access 'default' property from 'public' method of sub class", arr,
  164. (EXTDCLASS.pubSubSetDPArray(arr), EXTDCLASS.pubSubGetDPArray()) );
  165. // ********************************************
  166. // access default property from
  167. // private method in sub class
  168. // ********************************************
  169. EXTDCLASS = new ExtInternalClass();
  170. AddTestCase( "access 'default' property from 'private' method of sub class", arr,
  171. (EXTDCLASS.testPrivSubDPArray(arr)) );
  172. // ********************************************
  173. // access default property from
  174. // public final method in sub class
  175. // ********************************************
  176. EXTDCLASS = new ExtInternalClass();
  177. AddTestCase( "access 'default' property from 'public final' method of sub class", arr,
  178. (EXTDCLASS.pubFinSubSetDPArray(arr), EXTDCLASS.pubFinSubGetDPArray()) );
  179. // ********************************************
  180. // access default property from
  181. // public virtual method in sub class
  182. // ********************************************
  183. EXTDCLASS = new ExtInternalClass();
  184. AddTestCase( "access 'default' property from 'public virtual' method of sub class", arr,
  185. (EXTDCLASS.pubVirtSubSetDPArray(arr), EXTDCLASS.pubVirtSubGetDPArray()) );
  186. // ********************************************
  187. // access default property from
  188. // private final method in sub class
  189. // ********************************************
  190. EXTDCLASS = new ExtInternalClass();
  191. AddTestCase( "access 'default' property from 'private final' method of sub class", arr,
  192. (EXTDCLASS.testPrivFinSubDPArray(arr)) );
  193. // ********************************************
  194. // access default property from
  195. // private virtual method in sub class
  196. // ********************************************
  197. EXTDCLASS = new ExtInternalClass();
  198. AddTestCase( "access 'default' property from 'private virtual' method of sub class", arr,
  199. (EXTDCLASS.testPrivVirtSubDPArray(arr)) );
  200. // ********************************************
  201. // access default property from
  202. // static public method of sub class
  203. // ********************************************
  204. thisError = "no error thrown";
  205. try{
  206. ExtInternalClass.pubStatSubGetDPArray();
  207. } catch(e3) {
  208. thisError = e3.toString();
  209. } finally {
  210. AddTestCase( "access default property from static public method of sub class",
  211. TYPEERROR+1006,
  212. typeError( thisError ) );
  213. }
  214. test(); // leave this alone. this executes the test cases and
  215. // displays results.