|
1545 | 1545 | (is (= \a (get "ab" -0.5))) |
1546 | 1546 | (is (= \a (get "ab" -0.5 :not-found)))) |
1547 | 1547 |
|
| 1548 | +(deftest test-cljs-2538 |
| 1549 | + (testing "fractional indices in nth on arrays" |
| 1550 | + (is (thrown-with-msg? js/Error #"Index out of bounds" (nth (to-array [1 2]) -1))) |
| 1551 | + (is (= :not-found (nth (to-array [1 2]) -1 :not-found))) |
| 1552 | + (is (== 1 (nth (to-array [1 2]) -0.5))) |
| 1553 | + (is (== 1 (nth (to-array [1 2]) -0.5 :not-found))) |
| 1554 | + (is (== 1 (nth (to-array [1 2]) 0))) |
| 1555 | + (is (== 1 (nth (to-array [1 2]) 0 :not-found))) |
| 1556 | + (is (== 1 (nth (to-array [1 2]) 0.5))) |
| 1557 | + (is (== 1 (nth (to-array [1 2]) 0.5 :not-found))) |
| 1558 | + (is (== 2 (nth (to-array [1 2]) 1))) |
| 1559 | + (is (== 2 (nth (to-array [1 2]) 1 :not-found))) |
| 1560 | + (is (== 2 (nth (to-array [1 2]) 1.5))) |
| 1561 | + (is (== 2 (nth (to-array [1 2]) 1.5 :not-found))) |
| 1562 | + (is (thrown-with-msg? js/Error #"Index out of bounds" (nth (to-array [1 2]) 2))) |
| 1563 | + (is (= :not-found (nth (to-array [1 2]) 2 :not-found)))) |
| 1564 | + (testing "fractional indices in nth on strings" |
| 1565 | + (is (thrown-with-msg? js/Error #"Index out of bounds" (nth "ab" -1))) |
| 1566 | + (is (= :not-found (nth "ab" -1 :not-found))) |
| 1567 | + (is (== \a (nth "ab" -0.5))) |
| 1568 | + (is (== \a (nth "ab" -0.5 :not-found))) |
| 1569 | + (is (== \a (nth "ab" 0))) |
| 1570 | + (is (== \a (nth "ab" 0 :not-found))) |
| 1571 | + (is (== \a (nth "ab" 0.5))) |
| 1572 | + (is (== \a (nth "ab" 0.5 :not-found))) |
| 1573 | + (is (== \b (nth "ab" 1))) |
| 1574 | + (is (== \b (nth "ab" 1 :not-found))) |
| 1575 | + (is (== \b (nth "ab" 1.5))) |
| 1576 | + (is (== \b (nth "ab" 1.5 :not-found))) |
| 1577 | + (is (thrown-with-msg? js/Error #"Index out of bounds" (nth "ab" 2))) |
| 1578 | + (is (= :not-found (nth "ab" 2 :not-found))))) |
| 1579 | + |
1548 | 1580 | (deftest test-cljs-2549 |
1549 | 1581 | (let [tap (fn [_])] |
1550 | 1582 | (add-tap tap) |
|
0 commit comments