|
1 | 1 | # These tests are auto-generated with test data from: |
2 | 2 | # https://github.com/exercism/problem-specifications/tree/main/exercises/binary-search/canonical-data.json |
3 | | -# File last updated on 2026-06-13 |
| 3 | +# File last updated on 2026-06-21 |
4 | 4 |
|
5 | 5 | import BinarySearch exposing [find] |
6 | 6 |
|
7 | 7 | # finds a value in an array with one element |
8 | 8 | expect { |
9 | | - result = [6]->find(6) |
| 9 | + result = find([6], 6) |
10 | 10 | result == Ok(0) |
11 | 11 | } |
12 | 12 |
|
13 | 13 | # finds a value in the middle of an array |
14 | 14 | expect { |
15 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(6) |
| 15 | + result = find([1, 3, 4, 6, 8, 9, 11], 6) |
16 | 16 | result == Ok(3) |
17 | 17 | } |
18 | 18 |
|
19 | 19 | # finds a value at the beginning of an array |
20 | 20 | expect { |
21 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(1) |
| 21 | + result = find([1, 3, 4, 6, 8, 9, 11], 1) |
22 | 22 | result == Ok(0) |
23 | 23 | } |
24 | 24 |
|
25 | 25 | # finds a value at the end of an array |
26 | 26 | expect { |
27 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(11) |
| 27 | + result = find([1, 3, 4, 6, 8, 9, 11], 11) |
28 | 28 | result == Ok(6) |
29 | 29 | } |
30 | 30 |
|
31 | 31 | # finds a value in an array of odd length |
32 | 32 | expect { |
33 | | - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]->find(144) |
| 33 | + result = find([1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634], 144) |
34 | 34 | result == Ok(9) |
35 | 35 | } |
36 | 36 |
|
37 | 37 | # finds a value in an array of even length |
38 | 38 | expect { |
39 | | - result = [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]->find(21) |
| 39 | + result = find([1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377], 21) |
40 | 40 | result == Ok(5) |
41 | 41 | } |
42 | 42 |
|
43 | 43 | # identifies that a value is not included in the array |
44 | 44 | expect { |
45 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(7) |
| 45 | + result = find([1, 3, 4, 6, 8, 9, 11], 7) |
46 | 46 | result.is_err() |
47 | 47 | } |
48 | 48 |
|
49 | 49 | # a value smaller than the array's smallest value is not found |
50 | 50 | expect { |
51 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(0) |
| 51 | + result = find([1, 3, 4, 6, 8, 9, 11], 0) |
52 | 52 | result.is_err() |
53 | 53 | } |
54 | 54 |
|
55 | 55 | # a value larger than the array's largest value is not found |
56 | 56 | expect { |
57 | | - result = [1, 3, 4, 6, 8, 9, 11]->find(13) |
| 57 | + result = find([1, 3, 4, 6, 8, 9, 11], 13) |
58 | 58 | result.is_err() |
59 | 59 | } |
60 | 60 |
|
61 | 61 | # nothing is found in an empty array |
62 | 62 | expect { |
63 | | - result = []->find(1) |
| 63 | + result = find([], 1) |
64 | 64 | result.is_err() |
65 | 65 | } |
66 | 66 |
|
67 | 67 | # nothing is found when the left and right bounds cross |
68 | 68 | expect { |
69 | | - result = [1, 2]->find(0) |
| 69 | + result = find([1, 2], 0) |
70 | 70 | result.is_err() |
71 | 71 | } |
72 | 72 |
|
|
0 commit comments