Advertisement
Guest User

Untitled

a guest
Dec 26th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. exec function TestSorting()
  2. {
  3. local array<int> TestArray;
  4. local int i, j, last;
  5.  
  6. local bool escaped;
  7.  
  8. j = 0;
  9. escaped = false;
  10. while (!escaped)
  11. {
  12. TestArray.Length = 0;
  13. for (i = 0; i < j; i++)
  14. {
  15. TestArray.AddItem(i);
  16. }
  17. TestArray.Sort(SortDesc);
  18. // validate that the array is descending now
  19. last = MaxInt;
  20. for (i = 0; i < TestArray.Length && !escaped; i++)
  21. {
  22. escaped = escaped || TestArray[i] > last;
  23. last = TestArray[i];
  24. }
  25. j++;
  26. }
  27. `log("It all went bad at length" @ j);
  28.  
  29. }
  30.  
  31. function int SortDesc(int A, int B)
  32. {
  33. `log("A:" @ A $ ", B:" @ B);
  34. return A - B;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement