-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathponylang-test.el
130 lines (118 loc) · 4.54 KB
/
ponylang-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
;;; ponylang-test.el --- Tests for ponylang-mode
;;
;; Author: Sean T Allen <[email protected]>
;; Version: 0.6.0
;; URL: https://github.com/seantallen/ponylang-mode
;; Keywords: programming
;; Package-Requires: ()
;;
;; This file is not part of GNU Emacs.
;;
;; Copyright (c) 2015 Austin Bingham
;; Copyright (c) 2016 Sean T. Allen
;; Copyright (c) 2020 Damon Kwok
;; Copyright (c) 2021 The Pony Developers
;;
;;; Commentary:
;;
;; Description:
;;
;; Tests for ponylang-mode
;;
;; The tests are built using the standard `ert' module, so you can run
;; them using a number of techniques. For example:
;;
;; (require 'ponylang-test)
;; (ert-run-tests-interactively "ponylang-test")
;;
;;; License:
;;
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Code:
(require 'ert)
(require 'ponylang-mode)
(ert-deftest
ponylang-test-class-indents-to-zero
()
"The class keyword indents to zero when alone in a file."
(dolist (k '(" class" " class" "class " " class "))
(with-temp-buffer (ponylang-mode)
(insert k)
(ponylang-indent-line)
(should (= (current-indentation) 0)))))
(ert-deftest
ponylang-test-class-indents-to-zero-after-actor
()
"The class keyword indents to zero after an actor definition."
(dolist (k '(" class" " class" "class " " class "))
(with-temp-buffer (ponylang-mode)
(insert "actor Test\n")
(insert " var foo: U64 = 0\n")
(insert "\n")
(insert k)
(ponylang-indent-line)
(should (= (current-indentation) 0)))))
(ert-deftest
ponylang-test-actor-indents-to-zero
()
"The actor keyword indents to zero when alone in a file."
(dolist (k '(" actor" " actor" "actor " " actor "))
(with-temp-buffer (ponylang-mode)
(insert k)
(ponylang-indent-line)
(should (= (current-indentation) 0)))))
(ert-deftest
ponylang-test-actor-indents-to-zero-after-actor
()
"The actor keyword indents to zero after an actor definition."
(dolist (k '(" actor" " actor" "actor " " actor "))
(with-temp-buffer (ponylang-mode)
(insert "actor Test\n")
(insert " var foo: U64 = 0\n")
(insert "\n")
(insert k)
(ponylang-indent-line)
(should (= (current-indentation) 0)))))
;; NB: These don't really work right now, but hopefully someday. I've
;; kept them around as a reminder.
;; (defconst ponylang-test-indenting-keywords
;; '("repeat" "until" "while" "for" "be" "new" "use" "try" "else" "if" "ref" "then" "fun" "tag"))
;; (defconst ponylang-test-non-indenting-keywords
;; '("let" "end" "var"))
;; (ert-deftest ponyland-test-keyword-based-indentation ()
;; "Test that some keywords start new indnetation."
;; (dolist (k ponylang-test-indenting-keywords)
;; (with-temp-bufferx
;; (ponylang-mode)
;; (insert k)
;; (newline)
;; (ponylang-indent-line)
;; (should (= (current-indentation) tab-width)))))
;; (ert-deftest ponyland-test-end-maintains-indentation ()
;; "Test that the end keyword sets indentation correctly.."
;; (dolist (k ponylang-test-non-indenting-keywords)
;; (with-temp-buffer
;; (ponylang-mode)
;; (insert "end")
;; (newline)
;; (ponylang-indent-line)
;; (should (= (current-indentation) 0)))))
;;; ponylang-test.el ends here