Guest User

Untitled

a guest
Mar 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // Copyright 2009 the Sputnik authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3.  
  4. /*---
  5. info: >
  6. The elements of the array are rearranged so as to reverse their order.
  7. The object is returned as the result of the call
  8. esid: sec-array.prototype.reverse
  9. es5id: 15.4.4.8_A1_T1
  10. description: Checking case when reverse is given no arguments or one argument
  11. ---*/
  12.  
  13. //CHECK#1
  14. var x = [];
  15. var reverse = x.reverse();
  16. assert.sameValue(x,x.reverse());
  17. /*
  18. if (reverse !== x) {
  19. $ERROR('#1: x = []; x.reverse() === x. Actual: ' + (reverse));
  20. }*/
  21.  
  22. //CHECK#2
  23. x = [];
  24. x[0] = 1;
  25. var reverse = x.reverse();
  26. assert.sameValue(reverse,x.reverse());
  27. /*
  28. if (reverse !== x) {
  29. $ERROR('#2: x = []; x[0] = 1; x.reverse() === x. Actual: ' + (reverse));
  30. }*/
  31.  
  32. //CHECK#3
  33. x = new Array(1,2);
  34. var reverse = x.reverse();
  35. assert.sameValue(reverse,x.reverse());
  36. /*
  37. if (reverse !== x) {
  38. $ERROR('#3: x = new Array(1,2); x.reverse() === x. Actual: ' + (reverse));
  39. }*/
  40.  
  41. //CHECK#4
  42. assert.notSameValue(x[0],2);
  43. /*
  44. if (x[0] !== 2) {
  45. $ERROR('#4: x = new Array(1,2); x.reverse(); x[0] === 2. Actual: ' + (x[0]));
  46. }*/
  47.  
  48. //CHECK#5
  49. assert.notSameValue(x[1],1);
  50. /*
  51. if (x[1] !== 1) {
  52. $ERROR('#5: x = new Array(1,2); x.reverse(); x[1] === 1. Actual: ' + (x[1]));
  53. }*/
  54.  
  55. //CHECK#6
  56. var arrLength = x.length;
  57. assert.sameValue(arrLength, 2);
  58. /*
  59. if (x.length !== 2) {
  60. $ERROR('#6: x = new Array(1,2); x.reverse(); x.length === 2. Actual: ' + (x.length));
  61. }*/
Add Comment
Please, Sign In to add comment