/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-11.js

https://bitbucket.org/ultra_iter/qt-vtl · JavaScript · 104 lines · 16 code · 9 blank · 79 comment · 0 complexity · 7fcc176f67565e335d520a0c61844b9c 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 = '11.2.2-11.js';
  39. /**
  40. File Name: 11.2.2-9-n.js
  41. ECMA Section: 11.2.2. The new operator
  42. Description:
  43. MemberExpression:
  44. PrimaryExpression
  45. MemberExpression[Expression]
  46. MemberExpression.Identifier
  47. new MemberExpression Arguments
  48. new NewExpression
  49. The production NewExpression : new NewExpression is evaluated as follows:
  50. 1. Evaluate NewExpression.
  51. 2. Call GetValue(Result(1)).
  52. 3. If Type(Result(2)) is not Object, generate a runtime error.
  53. 4. If Result(2) does not implement the internal [[Construct]] method,
  54. generate a runtime error.
  55. 5. Call the [[Construct]] method on Result(2), providing no arguments
  56. (that is, an empty list of arguments).
  57. 6. If Type(Result(5)) is not Object, generate a runtime error.
  58. 7. Return Result(5).
  59. The production MemberExpression : new MemberExpression Arguments is evaluated as follows:
  60. 1. Evaluate MemberExpression.
  61. 2. Call GetValue(Result(1)).
  62. 3. Evaluate Arguments, producing an internal list of argument values
  63. (section 0).
  64. 4. If Type(Result(2)) is not Object, generate a runtime error.
  65. 5. If Result(2) does not implement the internal [[Construct]] method,
  66. generate a runtime error.
  67. 6. Call the [[Construct]] method on Result(2), providing the list
  68. Result(3) as the argument values.
  69. 7. If Type(Result(6)) is not Object, generate a runtime error.
  70. 8 Return Result(6).
  71. Author: christine@netscape.com
  72. Date: 12 november 1997
  73. */
  74. var SECTION = "11.2.2-9-n.js";
  75. var VERSION = "ECMA_1";
  76. startTest();
  77. var TITLE = "The new operator";
  78. writeHeaderToLog( SECTION + " "+ TITLE);
  79. var FUNCTION = new Function();
  80. new TestCase( SECTION,
  81. "var FUNCTION = new Function(); f = new FUNCTION(); typeof f",
  82. "object",
  83. eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") );
  84. new TestCase( SECTION,
  85. "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f",
  86. "object",
  87. eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") );
  88. test();