polyInliningFixedMethods.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. if (this.WScript && this.WScript.LoadScriptFile) {
  6. this.WScript.LoadScriptFile("../UnitTestFramework/TrimStackTracePath.js");
  7. }
  8. function Dump(output)
  9. {
  10. if (this.WScript)
  11. {
  12. WScript.Echo(output);
  13. }
  14. else
  15. {
  16. alert(output);
  17. }
  18. }
  19. function a() { }
  20. a.prototype.x = function () { WScript.Echo(1); this.y(); };
  21. a.prototype.y = function () { WScript.Echo("a"); };
  22. var a1 = new a();
  23. a1.f = function () { WScript.Echo(1); this.y(); };
  24. function b() { }
  25. b.prototype.p = 1;
  26. b.prototype.x = function () { WScript.Echo("b"); };
  27. b.prototype.f = function () { WScript.Echo("b1"); };
  28. b.prototype.y = function () { WScript.Echo("b"); };
  29. var b1 = new b();
  30. function pr(){};
  31. pr.f = function() {WScript.Echo("pr")};
  32. b.prototype = pr;
  33. b2 = new b();
  34. function Inheriter() {
  35. this.f = function () { WScript.Echo("f"); }
  36. }
  37. function c() { }
  38. c.prototype.x = function () { WScript.Echo(2); };
  39. c.prototype.q = 1;
  40. c.prototype.p = 1;
  41. Inheriter.prototype = a.prototype;
  42. c.prototype = new Inheriter();
  43. var c1 = new c();
  44. function d() { }
  45. d.prototype.x = function () { WScript.Echo(2); };
  46. d.prototype.r = 1;
  47. d.prototype.q = 1;
  48. d.prototype.p = 1;
  49. //Inheriter.prototype = b.prototype;
  50. d.prototype = new Inheriter();
  51. var d1 = new d();
  52. function foo(func) {
  53. func.f();
  54. }
  55. foo(b1);
  56. foo(b2);
  57. foo(b1);
  58. foo(d1);
  59. foo(a1);
  60. foo(b1);
  61. foo(c1);
  62. foo(d1);
  63. var obj1 = {};
  64. var func3 = function () {
  65. function v6() {
  66. }
  67. v6.prototype.method0 = function () {
  68. };
  69. var v7 = new v6();
  70. function v8() {
  71. }
  72. v8.method0 = function () {
  73. };
  74. v6.prototype = v8;
  75. var v9 = new v6();
  76. function v15(v16) {
  77. for (var v18 = 0; v18 < 2; v18++) {
  78. v16.method0();
  79. }
  80. }
  81. v15(v7);
  82. v15(v9);
  83. v15();
  84. };
  85. obj1.method1 = func3;
  86. try {
  87. obj1.method1();
  88. } catch(e) {
  89. Dump(TrimStackTracePath(e.stack));
  90. }