diff options
| author | Jay Belanger | 2014-11-15 23:27:48 -0600 |
|---|---|---|
| committer | Jay Belanger | 2014-11-15 23:27:48 -0600 |
| commit | bc5d86fe909e2808194bc738c8086599245f22c5 (patch) | |
| tree | 17e6c729ae0dbd6003dd216dfff5f3bf6bff1b25 /test/automated/python-tests.el | |
| parent | 1a30156b984735be444d54e51c40bc3243345110 (diff) | |
| parent | 1a713024a012f574d16084cf42703e6ef49473cf (diff) | |
| download | emacs-bc5d86fe909e2808194bc738c8086599245f22c5.tar.gz emacs-bc5d86fe909e2808194bc738c8086599245f22c5.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Conflicts:
lisp/ChangeLog
Diffstat (limited to 'test/automated/python-tests.el')
| -rw-r--r-- | test/automated/python-tests.el | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index 39195fd7086..f368f995cae 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -711,6 +711,21 @@ if a: | |||
| 711 | (should (= (python-indent-calculate-indentation) 0)) | 711 | (should (= (python-indent-calculate-indentation) 0)) |
| 712 | (should (equal (python-indent-calculate-levels) '(0))))) | 712 | (should (equal (python-indent-calculate-levels) '(0))))) |
| 713 | 713 | ||
| 714 | (ert-deftest python-indent-dedenters-8 () | ||
| 715 | "Test indentation for Bug#18432." | ||
| 716 | (python-tests-with-temp-buffer | ||
| 717 | " | ||
| 718 | if (a == 1 or | ||
| 719 | a == 2): | ||
| 720 | pass | ||
| 721 | elif (a == 3 or | ||
| 722 | a == 4): | ||
| 723 | " | ||
| 724 | (python-tests-look-at "a == 4):\n") | ||
| 725 | (should (eq (car (python-indent-context)) 'inside-paren)) | ||
| 726 | (should (= (python-indent-calculate-indentation) 6)) | ||
| 727 | (should (equal (python-indent-calculate-levels) '(0 4 6))))) | ||
| 728 | |||
| 714 | (ert-deftest python-indent-electric-colon-1 () | 729 | (ert-deftest python-indent-electric-colon-1 () |
| 715 | "Test indentation case from Bug#18228." | 730 | "Test indentation case from Bug#18228." |
| 716 | (python-tests-with-temp-buffer | 731 | (python-tests-with-temp-buffer |
| @@ -725,6 +740,110 @@ def b() | |||
| 725 | (python-tests-self-insert ":") | 740 | (python-tests-self-insert ":") |
| 726 | (should (= (current-indentation) 0)))) | 741 | (should (= (current-indentation) 0)))) |
| 727 | 742 | ||
| 743 | (ert-deftest python-indent-region-1 () | ||
| 744 | "Test indentation case from Bug#18843." | ||
| 745 | (let ((contents " | ||
| 746 | def foo (): | ||
| 747 | try: | ||
| 748 | pass | ||
| 749 | except: | ||
| 750 | pass | ||
| 751 | ")) | ||
| 752 | (python-tests-with-temp-buffer | ||
| 753 | contents | ||
| 754 | (python-indent-region (point-min) (point-max)) | ||
| 755 | (should (string= (buffer-substring-no-properties (point-min) (point-max)) | ||
| 756 | contents))))) | ||
| 757 | |||
| 758 | (ert-deftest python-indent-region-2 () | ||
| 759 | "Test region indentation on comments." | ||
| 760 | (let ((contents " | ||
| 761 | def f(): | ||
| 762 | if True: | ||
| 763 | pass | ||
| 764 | |||
| 765 | # This is | ||
| 766 | # some multiline | ||
| 767 | # comment | ||
| 768 | ")) | ||
| 769 | (python-tests-with-temp-buffer | ||
| 770 | contents | ||
| 771 | (python-indent-region (point-min) (point-max)) | ||
| 772 | (should (string= (buffer-substring-no-properties (point-min) (point-max)) | ||
| 773 | contents))))) | ||
| 774 | |||
| 775 | (ert-deftest python-indent-region-3 () | ||
| 776 | "Test region indentation on comments." | ||
| 777 | (let ((contents " | ||
| 778 | def f(): | ||
| 779 | if True: | ||
| 780 | pass | ||
| 781 | # This is | ||
| 782 | # some multiline | ||
| 783 | # comment | ||
| 784 | ") | ||
| 785 | (expected " | ||
| 786 | def f(): | ||
| 787 | if True: | ||
| 788 | pass | ||
| 789 | # This is | ||
| 790 | # some multiline | ||
| 791 | # comment | ||
| 792 | ")) | ||
| 793 | (python-tests-with-temp-buffer | ||
| 794 | contents | ||
| 795 | (python-indent-region (point-min) (point-max)) | ||
| 796 | (should (string= (buffer-substring-no-properties (point-min) (point-max)) | ||
| 797 | expected))))) | ||
| 798 | |||
| 799 | (ert-deftest python-indent-region-4 () | ||
| 800 | "Test region indentation block starts, dedenders and enders." | ||
| 801 | (let ((contents " | ||
| 802 | def f(): | ||
| 803 | if True: | ||
| 804 | a = 5 | ||
| 805 | else: | ||
| 806 | a = 10 | ||
| 807 | return a | ||
| 808 | ") | ||
| 809 | (expected " | ||
| 810 | def f(): | ||
| 811 | if True: | ||
| 812 | a = 5 | ||
| 813 | else: | ||
| 814 | a = 10 | ||
| 815 | return a | ||
| 816 | ")) | ||
| 817 | (python-tests-with-temp-buffer | ||
| 818 | contents | ||
| 819 | (python-indent-region (point-min) (point-max)) | ||
| 820 | (should (string= (buffer-substring-no-properties (point-min) (point-max)) | ||
| 821 | expected))))) | ||
| 822 | |||
| 823 | (ert-deftest python-indent-region-5 () | ||
| 824 | "Test region indentation leaves strings untouched (start delimiter)." | ||
| 825 | (let ((contents " | ||
| 826 | def f(): | ||
| 827 | ''' | ||
| 828 | this is | ||
| 829 | a multiline | ||
| 830 | string | ||
| 831 | ''' | ||
| 832 | ") | ||
| 833 | (expected " | ||
| 834 | def f(): | ||
| 835 | ''' | ||
| 836 | this is | ||
| 837 | a multiline | ||
| 838 | string | ||
| 839 | ''' | ||
| 840 | ")) | ||
| 841 | (python-tests-with-temp-buffer | ||
| 842 | contents | ||
| 843 | (python-indent-region (point-min) (point-max)) | ||
| 844 | (should (string= (buffer-substring-no-properties (point-min) (point-max)) | ||
| 845 | expected))))) | ||
| 846 | |||
| 728 | 847 | ||
| 729 | ;;; Navigation | 848 | ;;; Navigation |
| 730 | 849 | ||