/tests/auto/qscriptjstestsuite/tests/ecma/extensions/10.1.6.js

https://bitbucket.org/ultra_iter/qt-vtl · JavaScript · 127 lines · 46 code · 19 blank · 62 comment · 1 complexity · 282656451e9cf5f024652cb4c594aecb MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Mozilla Communicator client code, released
  16. * March 31, 1998.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. gTestfile = '10.1.6.js';
  39. /**
  40. File Name: 10.1.6
  41. ECMA Section: Activation Object
  42. Description:
  43. If the function object being invoked has an arguments property, let x be
  44. the value of that property; the activation object is also given an internal
  45. property [[OldArguments]] whose initial value is x; otherwise, an arguments
  46. property is created for the function object but the activation object is
  47. not given an [[OldArguments]] property. Next, arguments object described
  48. below (the same one stored in the arguments property of the activation
  49. object) is used as the new value of the arguments property of the function
  50. object. This new value is installed even if the arguments property already
  51. exists and has the ReadOnly attribute (as it will for native Function
  52. objects). (These actions are taken to provide compatibility with a form of
  53. program syntax that is now discouraged: to access the arguments object for
  54. function f within the body of f by using the expression f.arguments.
  55. The recommended way to access the arguments object for function f within
  56. the body of f is simply to refer to the variable arguments.)
  57. Author: christine@netscape.com
  58. Date: 12 november 1997
  59. */
  60. var SECTION = "10.1.6";
  61. var VERSION = "ECMA_1";
  62. startTest();
  63. var TITLE = "Activation Object";
  64. writeHeaderToLog( SECTION + " "+ TITLE);
  65. var arguments = "FAILED!";
  66. var ARG_STRING = "value of the argument property";
  67. new TestCase( SECTION,
  68. "(new TestObject(0,1,2,3,4,5)).length",
  69. 6,
  70. (new TestObject(0,1,2,3,4,5)).length );
  71. for ( i = 0; i < 6; i++ ) {
  72. new TestCase( SECTION,
  73. "(new TestObject(0,1,2,3,4,5))["+i+"]",
  74. i,
  75. (new TestObject(0,1,2,3,4,5))[i]);
  76. }
  77. // The current object already has an arguments property.
  78. new TestCase( SECTION,
  79. "(new AnotherTestObject(1,2,3)).arguments",
  80. ARG_STRING,
  81. (new AnotherTestObject(1,2,3)).arguments );
  82. // The function invoked with [[Call]]
  83. new TestCase( SECTION,
  84. "TestFunction(1,2,3)",
  85. ARG_STRING,
  86. TestFunction() + '' );
  87. test();
  88. function Prototype() {
  89. this.arguments = ARG_STRING;
  90. }
  91. function TestObject() {
  92. this.__proto__ = new Prototype();
  93. return arguments;
  94. }
  95. function AnotherTestObject() {
  96. this.__proto__ = new Prototype();
  97. return this;
  98. }
  99. function TestFunction() {
  100. arguments = ARG_STRING;
  101. return arguments;
  102. }
  103. function AnotherTestFunction() {
  104. this.__proto__ = new Prototype();
  105. return this;
  106. }