Advertisement
VladNitu

teste_fp_vlad

Mar 15th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. , testGroup "myTests" [
  2. testProperty "ObjectIterator w/ 1 value existent and one value non-existent" prop_obj_iterator1_null],
  3. testProperty "ObjectIterator w/ 2 values existent, one being an empty ob!" prop_obj_iterator2_ok,
  4.  
  5. testProperty "ArrIterator w/ 1 index out of bounds (i > length xs)" prop_arr_iterator_one_out_of_bound,
  6. testProperty "ArrIterator [] (take all elements)" prop_arr_iterator_take_all,
  7. testProperty "ArrIterator w/ negative index values (i < 0), in bounds (0 <= -i < length xs)" prop_arr_iterator_negative_values,
  8. testProperty "ArrIterator w/ 1 negative value that is out of bounds (-i > length xs)" prop_arr_iterator_negative_out_of_bounds,
  9.  
  10. testProperty "ArrIndex base case (positive, in bounds: 0 <= i < length xs)" prop_arr_index_base_case,
  11. testProperty "ArrIndex positive index out of bounds (i > length xs)" prop_arr_index_out_of_bound_positiv,
  12. testProperty "ArrIndex negative OK case (in bounds: 0 <= -i < length xs)" prop_arr_index_negative_case,
  13. testProperty "ArrInedx negative index out of bounds (-i >= length xs)" prop_arr_index_out_of_bound_negative,
  14. testProperty "ArrInedx negative (-i == length xs) (i.e.: v : [0, 1, 2], v[-3] == v[0])" prop_arr_index_negative_first_element,
  15.  
  16. testProperty "ArrSliceIndex base case (Both left and right positive and in bounds, left <= right); [a:b]" prop_arr_slice_base_case,
  17. testProperty "ArrSliceIndex only Left specified [a:]" prop_arr_slice_only_left_specified,
  18. testProperty "ArrSliceIndex only Right specified [:b]" prop_arr_slice_only_right_specified,
  19. testProperty "ArrSliceIndex both left and right negative, left <= right, both in bounds (0 <= -left, -right < length xs)" prop_arr_slice_both_negative,
  20. testProperty "ArrSliceIndex left >= right => Empty list" prop_arr_slice_left_greater_than_right,
  21. testProperty "ArrSliceIndex Out of bounds both (left, right > length xs) => Empty list" prop_arr_slice_out_of_bounds_both,
  22. testProperty "ArrSliceIndex Out of bound right (right >= length xs => cap it to length xs) => equivalent to [a:]" prop_arr_slice_out_of_bounds_right,
  23. testProperty "ArrSliceIndex Out of bound left (-left >= length xs => cap it to i = (-length xs)) => equivalent to [:b]" prop_arr_slice_out_of_bounds_left
  24.  
  25.  
  26. -- My tests :D
  27. prop_obj_iterator1_null = run (compile $ ObjValueIt ["a", "c"]) (JObject [("a", JArray [JNumber 1])]) == Right [JArray [JNumber 1], JNull]
  28. prop_obj_iterator2_ok = run (compile $ ObjValueIt ["a", "c"]) (JObject [("a", JNumber 1), ("c", JObject [])]) == Right [JNumber 1, JObject []]
  29. prop_arr_iterator_one_out_of_bound = run (compile $ ArrIt [0, 2, 4]) (JArray [JNumber 0, JNumber 1, JNumber 2]) === Right [JNumber 0, JNumber 2, JNull]
  30. prop_arr_iterator_take_all = run (compile $ ArrIt []) (JArray [JNumber 0, JNumber 1, JNumber 2]) === Right [JNumber 0, JNumber 1, JNumber 2]
  31. prop_arr_iterator_negative_values = run (compile $ ArrIt [1, -3, -2, 3]) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 1, JNumber 3, JNumber 4, JNumber 3]
  32. prop_arr_iterator_negative_out_of_bounds = run (compile $ ArrIt [-100]) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNull]
  33. prop_arr_iterator_negative_out_of_bounds_more_it_to_check = run (compile $ ArrIt [1, -100, 1]) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 1, JNull, JNumber 1]
  34.  
  35. prop_arr_index_base_case = run (compile $ ArrIndex 2) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 2]
  36. prop_arr_index_out_of_bound_positiv = run (compile $ ArrIndex 10) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNull]
  37. prop_arr_index_negative_case = run (compile $ ArrIndex (-2)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 4]
  38. prop_arr_index_out_of_bound_negative = run (compile $ ArrIndex (-7)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNull]
  39. prop_arr_index_negative_first_element = run (compile $ ArrIndex (-6)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 0]
  40.  
  41. prop_arr_slice_base_case = run (compile $ ArrIndexSlice (Just 2) (Just 4)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 2, JNumber 3]
  42. prop_arr_slice_only_left_specified = run (compile $ ArrIndexSlice (Just 4) Nothing) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 4, JNumber 5]
  43. prop_arr_slice_only_right_specified = run (compile $ ArrIndexSlice Nothing (Just 2)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 0, JNumber 1]
  44. prop_arr_slice_both_negative = run (compile $ ArrIndexSlice (Just (-3)) (Just (-1))) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 3, JNumber 4]
  45. prop_arr_slice_left_greater_than_right = run (compile $ ArrIndexSlice (Just 3) (Just 1)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [] -- [] empty list
  46. prop_arr_slice_out_of_bounds_both = run (compile $ ArrIndexSlice (Just 6) (Just 8)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [] -- [] empty list
  47. prop_arr_slice_out_of_bounds_right = run (compile $ ArrIndexSlice (Just 4) (Just 8)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 4, JNumber 5]
  48. prop_arr_slice_out_of_bounds_left = run (compile $ ArrIndexSlice (Just (-8)) (Just 2)) (JArray [JNumber 0, JNumber 1, JNumber 2, JNumber 3, JNumber 4, JNumber 5]) === Right [JNumber 0, JNumber 1]
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement