|
745 | 745 | :inspect "true"
|
746 | 746 | :code "(range 100)"}))))))))
|
747 | 747 |
|
| 748 | +(deftest inspect-print-current-value-test |
| 749 | + (testing "inspect-print-current-value returns the currently inspected value as a printed string" |
| 750 | + (is (= [(str/join "\n" ["{:a -1," |
| 751 | + " :bb \"111\"," |
| 752 | + " :ccc (1)," |
| 753 | + " :d" |
| 754 | + " ({:a 0, :bb \"000\", :ccc ()}" |
| 755 | + " {:a -1, :bb \"111\", :ccc (1)}" |
| 756 | + " {:a -2, :bb \"222\", :ccc (2 1)}" |
| 757 | + " {:a -3, :bb \"333\", :ccc (3 2 1)}" |
| 758 | + " {:a -4, :bb \"444\", :ccc (4 3 2 1)})}"])] |
| 759 | + (:value (do |
| 760 | + (session/message {:op "eval" |
| 761 | + :code "(def test-val |
| 762 | + (for [i (range 2)] |
| 763 | + {:a (- i) |
| 764 | + :bb (str i i i) |
| 765 | + :ccc (range i 0 -1) |
| 766 | + :d (for [i (range 5)] |
| 767 | + {:a (- i) |
| 768 | + :bb (str i i i) |
| 769 | + :ccc (range i 0 -1)})}))"}) |
| 770 | + (session/message {:op "eval" |
| 771 | + :inspect "true" |
| 772 | + :code "test-val"}) |
| 773 | + (session/message {:op "inspect-push" |
| 774 | + :idx 2}) |
| 775 | + (session/message {:op "inspect-print-current-value" |
| 776 | + :nrepl.middleware.print/print "cider.nrepl.pprint/pprint"}))))))) |
| 777 | + |
| 778 | +(deftest inspect-print-current-value-no-value-test |
| 779 | + (testing "inspect-print-current-value returns nil if nothing has been inspected yet" |
| 780 | + (is (= ["nil"] (:value (session/message |
| 781 | + {:op "inspect-print-current-value" |
| 782 | + :nrepl.middleware.print/print "cider.nrepl.pprint/pprint"})))))) |
| 783 | + |
| 784 | +(deftest inspect-print-current-value-default-print-fn-test |
| 785 | + (testing "inspect-print-current-value uses a default print fn when none is provided" |
| 786 | + (is (= ["nil"] (:value (session/message {:op "inspect-print-current-value"})))))) |
| 787 | + |
| 788 | +(deftest inspect-print-current-value-infinite-seq-test |
| 789 | + (testing "inspect-print-current-value works with infinite-seqs" |
| 790 | + (is (str/starts-with? (first (:value (do (session/message {:op "eval" |
| 791 | + :code "(def test-val (repeat :x))"}) |
| 792 | + (session/message {:op "eval" |
| 793 | + :inspect "true" |
| 794 | + :code "test-val"}) |
| 795 | + (session/message {:op "inspect-print-current-value" |
| 796 | + :nrepl.middleware.print/print "cider.nrepl.pprint/pprint"})))) |
| 797 | + "(:x")))) |
| 798 | + |
748 | 799 | (deftest inspect-def-current-value-test
|
749 | 800 | (testing "inspect-def-current-value defines a var with the current inspector value"
|
750 | 801 | (is (= "{3 4}"
|
|
0 commit comments