inliningApplyTarget.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. var Class = {
  6. create: function() {
  7. return function bar() {
  8. this.initialize.apply(this, arguments);
  9. }
  10. }
  11. };
  12. var object = {};
  13. object.obj1 = Class.create();
  14. object.obj1.prototype = {
  15. r : 0,
  16. initialize : function(r) {
  17. this.r = r;
  18. }
  19. }
  20. object.obj2 = Class.create();
  21. object.obj2.prototype = {
  22. x : 0,
  23. y : 0,
  24. initialize : function(x,y) {
  25. this.x = x;
  26. this.y = y;
  27. }
  28. }
  29. object.obj3 = Class.create();
  30. object.obj3.prototype = {
  31. prop1 : {},
  32. initialize : function(a) {
  33. this.prop1 = new object.obj1(a);
  34. }
  35. }
  36. object.obj4 = Class.create();
  37. object.obj4.prototype = {
  38. prop1 : {},
  39. prop2 : {},
  40. initialize : function(r,s,t) {
  41. this.prop1 = new object.obj1(r);
  42. this.prop2 = new object.obj2(s,t);
  43. }
  44. }
  45. function foo()
  46. {
  47. var v00 = new object.obj1();
  48. var v01 = new object.obj1(1);
  49. var v02 = new object.obj1(1,2);
  50. var v03 = new object.obj1(1,2,3);
  51. WScript.Echo(v03.r);
  52. var v4 = new object.obj2(1);
  53. var v5 = new object.obj2(1,2);
  54. var v6 = new object.obj2(1,2,3);
  55. WScript.Echo(v6.y);
  56. var v7 = new object.obj3(1);
  57. var v8 = new object.obj3(1,2);
  58. var v9 = new object.obj3(1,2,3);
  59. WScript.Echo(v9.prop1.r);
  60. var v10 = new object.obj4(1);
  61. var v11 = new object.obj4(1,2);
  62. var v12 = new object.obj4(1,2,3);
  63. WScript.Echo(v12.prop1.r);
  64. WScript.Echo(v12.prop2.y);
  65. }
  66. foo();
  67. foo();
  68. //override apply
  69. Function.prototype.apply = function(){};
  70. foo();
  71. WScript.Echo("Passed");