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

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

https://github.com/changm/tessa
ActionScript | 217 lines | 39 code | 36 blank | 142 comment | 0 complexity | 653a25db5eff0a00603254fdee01fc05 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. var SECTION = "Definitions"; // provide a document reference (ie, ECMA section)
  38. var VERSION = "Clean AS2"; // Version of JavaScript or ECMA
  39. var TITLE = "Extend Dynamic Class"; // Provide ECMA section title or a description
  40. var BUGNUMBER = "";
  41. startTest(); // leave this alone
  42. /**
  43. * Calls to AddTestCase here. AddTestCase is a function that is defined
  44. * in shell.js and takes three arguments:
  45. * - a string representation of what is being tested
  46. * - the expected result
  47. * - the actual result
  48. *
  49. * For example, a test might look like this:
  50. *
  51. * var helloWorld = "Hello World";
  52. *
  53. * AddTestCase(
  54. * "var helloWorld = 'Hello World'", // description of the test
  55. * "Hello World", // expected result
  56. * helloWorld ); // actual result
  57. *
  58. */
  59. import DynamicClass.*;
  60. //**********************************************
  61. // Default Methods and Default properties
  62. //
  63. // call a default Method of an object that
  64. // inherited it from it's dynamic parent class
  65. //**********************************************
  66. //Cannot access default properties/methods outside the package
  67. /*
  68. var EXTDCLASS = new ExtDynamicClass();
  69. var arr = new Array(1, 2, 3);
  70. var date = new Date(0);
  71. var func = new Function();
  72. var math = new Math();
  73. var num = new Number();
  74. var obj = new Object();
  75. var str = new String("test");
  76. var sim = new Simple();
  77. AddTestCase( "*** Default Methods and Default properites ***", 1, 1 );
  78. AddTestCase( "EXTDCLASS.setArray(arr), EXTDCLASS.getArray()", arr, (EXTDCLASS.setArray(arr), EXTDCLASS.getArray()) );
  79. AddTestCase( "EXTDCLASS.setBoolean(true), EXTDCLASS.getBoolean()", true, (EXTDCLASS.setBoolean(true), EXTDCLASS.getBoolean()) );
  80. AddTestCase( "EXTDCLASS.setDate(date), EXTDCLASS.getDate()", date, (EXTDCLASS.setDate(date), EXTDCLASS.getDate()) );
  81. AddTestCase( "EXTDCLASS.setFunction(func), EXTDCLASS.getFunction()", func, (EXTDCLASS.setFunction(func), EXTDCLASS.getFunction()) );
  82. AddTestCase( "EXTDCLASS.setMath(math), EXTDCLASS.getMath()", math, (EXTDCLASS.setMath(math), EXTDCLASS.getMath()) );
  83. AddTestCase( "EXTDCLASS.setNumber(num), EXTDCLASS.getNumber()", num, (EXTDCLASS.setNumber(num), EXTDCLASS.getNumber()) );
  84. AddTestCase( "EXTDCLASS.setObject(obj), EXTDCLASS.getObject()", obj, (EXTDCLASS.setObject(obj), EXTDCLASS.getObject()) );
  85. AddTestCase( "EXTDCLASS.setString(str), EXTDCLASS.getString()", str, (EXTDCLASS.setString(str), EXTDCLASS.getString()) );
  86. AddTestCase( "EXTDCLASS.setSimple(sim), EXTDCLASS.getSimple()", sim, (EXTDCLASS.setSimple(sim), EXTDCLASS.getSimple()) );
  87. // call setAll
  88. arr = new Array( 3, 4, 5 );
  89. date = new Date( 999999999999 );
  90. func = undefined;
  91. math = undefined;
  92. num = new Number( 100 );
  93. obj = undefined;
  94. str = "new test";
  95. sim = undefined;
  96. AddTestCase( "EXTDCLASS.setAll(arr, false, date, func, math, num, obj, str, sim), EXTDCLASS.getBoolean()",
  97. false,
  98. (EXTDCLASS.setAll(arr, false, date, func, math, num, obj, str, sim), EXTDCLASS.getBoolean()) );
  99. */
  100. //*******************************************
  101. // public Methods and public properties
  102. //
  103. // call a public Method of an object that
  104. // inherited it from it's parent class
  105. //*******************************************
  106. var EXTDCLASS = new ExtDynamicClass();
  107. arr = new Array(1, 2, 3);
  108. date = new Date(0);
  109. func = new Function();
  110. //math = new Math();
  111. num = new Number();
  112. obj = new Object();
  113. str = new String("test");
  114. //sim = new Simple();
  115. AddTestCase( "*** Public Methods and Public properites ***", 1, 1 );
  116. AddTestCase( "EXTDCLASS.setPubArray(arr), EXTDCLASS.pubArray", arr, (EXTDCLASS.setPubArray(arr), EXTDCLASS.pubArray) );
  117. AddTestCase( "EXTDCLASS.setPubBoolean(true), EXTDCLASS.pubBoolean", true, (EXTDCLASS.setPubBoolean(true), EXTDCLASS.pubBoolean) );
  118. //AddTestCase( "EXTDCLASS.setPubDate(date), EXTDCLASS.pubDate", date, (EXTDCLASS.setPubDate(date), EXTDCLASS.pubDate) );
  119. AddTestCase( "EXTDCLASS.setPubFunction(func), EXTDCLASS.pubFunction", func, (EXTDCLASS.setPubFunction(func), EXTDCLASS.pubFunction) );
  120. //AddTestCase( "EXTDCLASS.setPubMath(math), EXTDCLASS.pubMath", math, (EXTDCLASS.setPubMath(math), EXTDCLASS.pubMath) );
  121. AddTestCase( "EXTDCLASS.setPubNumber(num), EXTDCLASS.pubNumber", num, (EXTDCLASS.setPubNumber(num), EXTDCLASS.pubNumber) );
  122. AddTestCase( "EXTDCLASS.setPubObject(obj), EXTDCLASS.pubObject", obj, (EXTDCLASS.setPubObject(obj), EXTDCLASS.pubObject) );
  123. AddTestCase( "EXTDCLASS.setPubString(str), EXTDCLASS.pubString", str, (EXTDCLASS.setPubString(str), EXTDCLASS.pubString) );
  124. //AddTestCase( "EXTDCLASS.setPubSimple(sim), EXTDCLASS.pubSimple", sim, (EXTDCLASS.setPubSimple(sim), EXTDCLASS.pubSimple) );
  125. // ********************************************
  126. // access default method from a default
  127. // method of a sub class
  128. //
  129. // ********************************************
  130. EXTDCLASS = new ExtDynamicClass();
  131. AddTestCase( "*** Access default method from default method of sub class ***", 1, 1 );
  132. AddTestCase( "EXTDCLASS.testSubSetArray(arr)", arr, EXTDCLASS.testSubSetArray(arr) );
  133. // <TODO> fill in the rest of the cases here
  134. // ********************************************
  135. // access default method from a public
  136. // method of a sub class
  137. //
  138. // ********************************************
  139. EXTDCLASS = new ExtDynamicClass();
  140. AddTestCase( "*** Access default method from public method of sub class ***", 1, 1 );
  141. AddTestCase( "EXTDCLASS.pubSubSetArray(arr), EXTDCLASS.pubSubGetArray()", arr, (EXTDCLASS.pubSubSetArray(arr), EXTDCLASS.pubSubGetArray()) );
  142. // <TODO> fill in the rest of the cases here
  143. // ********************************************
  144. // access default method from a private
  145. // method of a sub class
  146. //
  147. // ********************************************
  148. EXTDCLASS = new ExtDynamicClass();
  149. AddTestCase( "*** Access default method from private method of sub class ***", 1, 1 );
  150. AddTestCase( "EXTDCLASS.testPrivSubArray(arr)", arr, EXTDCLASS.testPrivSubArray(arr) );
  151. // <TODO> fill in the rest of the cases here
  152. // ********************************************
  153. // access default property from
  154. // default method in sub class
  155. // ********************************************
  156. EXTDCLASS = new ExtDynamicClass();
  157. AddTestCase( "*** Access default property from method in sub class ***", 1, 1 );
  158. AddTestCase( "EXTDCLASS.testSubSetDPArray(arr)", arr, EXTDCLASS.testSubSetDPArray(arr) );
  159. // <TODO> fill in the rest of the cases here
  160. // ********************************************
  161. // access default property from
  162. // public method in sub class
  163. // ********************************************
  164. EXTDCLASS = new ExtDynamicClass();
  165. AddTestCase( "*** Access default property from public method in sub class ***", 1, 1 );
  166. AddTestCase( "EXTDCLASS.pubSubSetDPArray(arr), EXTDCLASS.pubSubGetDPArray()", arr, (EXTDCLASS.pubSubSetDPArray(arr), EXTDCLASS.pubSubGetDPArray()) );
  167. // <TODO> fill in the rest of the cases here
  168. // ********************************************
  169. // access default property from
  170. // private method in sub class
  171. // ********************************************
  172. EXTDCLASS = new ExtDynamicClass();
  173. AddTestCase( "*** Access default property from private method in sub class ***", 1, 1 );
  174. AddTestCase( "EXTDCLASS.testPrivSubSetDPArray(arr)", arr, EXTDCLASS.testPrivSubSetDPArray(arr) );
  175. // <TODO> fill in the rest of the cases here
  176. test(); // leave this alone. this executes the test cases and
  177. // displays results.