File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 131131(macro unpackPair (pair outx outy) {
132132 (let outx ($as-is (@ pair 0)))
133133 (let outy ($as-is (@ pair 1))) })
134+
135+ # @brief Increment a variable, by generating a `set`
136+ # @param value symbol to increment
137+ # =begin
138+ # (mut n 0)
139+ # (++ n)
140+ # (print n) # 1
141+ # (++ n)
142+ # (print n) # 2
143+ # =end
144+ # @author https://github.com/SuperFola
145+ (macro ++ (value) (set value (+ 1 value)))
146+
147+ # @brief Decrement a variable, by generating a `set`
148+ # @param value symbol to decrement
149+ # =begin
150+ # (mut n 0)
151+ # (-- n)
152+ # (print n) # -1
153+ # (-- n)
154+ # (print n) # -2
155+ # =end
156+ # @author https://github.com/SuperFola
157+ (macro -- (value) (set value (- value 1)))
Original file line number Diff line number Diff line change 4949 (test:eq i 10)
5050
5151 (until true
52- (test:expect false "this shouldn't trigger")) })})
52+ (test:expect false "this shouldn't trigger")) })
53+
54+ (test:case "++ and --" {
55+ (mut i 0)
56+ (test:eq (++ i) 1)
57+ (test:eq (++ i) 2)
58+ (test:eq (++ i) 3)
59+ (test:eq (-- i) 2)
60+ (test:eq (-- i) 1)
61+ (test:eq (-- i) 0)
62+ (test:eq (-- i) -1) }) })
You can’t perform that action at this time.
0 commit comments