memop_field.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. const size = 100;
  6. function Foo() {
  7. this.a = new Array(size);
  8. this.b = new Array(size);
  9. this.c = new Array(size);
  10. this.d = new Array(size);
  11. this.e = new Array(size);
  12. this.a.fill(1);
  13. this.b.fill(1);
  14. this.c.fill(1);
  15. this.d.fill(1);
  16. this.e.fill(1);
  17. this.fieldMemop = function() {
  18. let al = this.a.length;
  19. this.total = 0;
  20. // Right now this is invalid
  21. for(let i = 0; i < al; ++i) {
  22. this.a[i] = this.b[i];
  23. this.e[i] = 0;
  24. }
  25. this.validFieldMemop();
  26. this.validObjFieldMemop({c: this.c, d: this.d});
  27. this.invalidObjFieldMemop({c: this.c, d: this.d});
  28. };
  29. this.validFieldMemop = function() {
  30. let cl = this.c.length;
  31. this.total = 0;
  32. let c = this.c, d = this.d;
  33. // This is valid
  34. for(let i = 0; i < cl; ++i) {
  35. c[i] = d[i];
  36. }
  37. };
  38. this.validObjFieldMemop = function(obj) {
  39. let cl = obj.c.length;
  40. let c = obj.c, d = obj.d;
  41. // This is valid
  42. for(let i = 0; i < cl; ++i) {
  43. c[i] = d[i];
  44. }
  45. };
  46. this.invalidObjFieldMemop = function(obj) {
  47. let cl = obj.c.length;
  48. obj.total = 0;
  49. // Right now this is invalid
  50. for(let i = 0; i < cl; ++i) {
  51. obj.c[i] = obj.d[i];
  52. obj.total = 1;
  53. }
  54. };
  55. }
  56. const f = new Foo();
  57. f.fieldMemop();
  58. f.fieldMemop();
  59. print("PASSED");