/test/acceptance/as3/Definitions/Classes/ExtImpl/ExtDefaultImplDefDefPub.as

https://github.com/bsdf/trx · ActionScript · 130 lines · 26 code · 24 blank · 80 comment · 0 complexity · 15d4f89d8c6dac4fbd385cb86131744b 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 Default Class Implement Default interface"; // 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 DefaultClass.*;
  60. var THISTEST = new ExtDefaultImplDefDefPub();
  61. // *******************************************
  62. // define public method from interface as a
  63. // public method in the sub class
  64. // *******************************************
  65. AddTestCase( "*** public method implemented interface ***", 1, 1 );
  66. AddTestCase( "THISTEST.setPubBoolean(false), THISTEST.iGetPubBoolean()", false, (THISTEST.setPubBoolean(false), THISTEST.iGetPubBoolean()) );
  67. AddTestCase( "THISTEST.setPubBoolean(true), THISTEST.iGetPubBoolean()", true, (THISTEST.setPubBoolean(true), THISTEST.iGetPubBoolean()) );
  68. // *******************************************
  69. // define public method from interface 2 as a
  70. // public method in the sub class
  71. // *******************************************
  72. AddTestCase( "*** public method implemented interface 2 ***", 1, 1 );
  73. AddTestCase( "THISTEST.setPubNumber(14), THISTEST.iGetPubNumber()", 14, (THISTEST.setPubNumber(14), THISTEST.iGetPubNumber()) );
  74. //*******************************************
  75. // access from outside of class
  76. //*******************************************
  77. var EXTDCLASS = new ExtDefaultImplDefDefPub();
  78. arr = new Array(1, 2, 3);
  79. AddTestCase( "*** access public methods and properties from outside of class ***", 1, 1 );
  80. AddTestCase( "EXTDCLASS.setPubArray(arr), EXTDCLASS.pubArray", arr, (EXTDCLASS.setPubArray(arr), EXTDCLASS.pubArray) );
  81. // ********************************************
  82. // access public method from a default
  83. // method of a sub class
  84. //
  85. // ********************************************
  86. EXTDCLASS = new ExtDefaultImplDefDefPub();
  87. AddTestCase( "*** Access public method from default method of sub class ***", 1, 1 );
  88. AddTestCase( "EXTDCLASS.testGetSubArray(arr)", arr, EXTDCLASS.testGetSubArray(arr) );
  89. // ********************************************
  90. // access public method from a public
  91. // method of a sub class
  92. //
  93. // ********************************************
  94. EXTDCLASS = new ExtDefaultImplDefDefPub();
  95. AddTestCase( "*** Access public method from public method of sub class ***", 1, 1 );
  96. AddTestCase( "EXTDCLASS.pubSubSetArray(arr), EXTDCLASS.pubSubGetArray()", arr, (EXTDCLASS.pubSubSetArray(arr), EXTDCLASS.pubSubGetArray()) );
  97. // ********************************************
  98. // access public method from a private
  99. // method of a sub class
  100. //
  101. // ********************************************
  102. EXTDCLASS = new ExtDefaultImplDefDefPub();
  103. AddTestCase( "*** Access public method from private method of sub class ***", 1, 1 );
  104. AddTestCase( "EXTDCLASS.testPrivSubArray(arr)", arr, EXTDCLASS.testPrivSubArray(arr) );
  105. test(); // leave this alone. this executes the test cases and
  106. // displays results.