-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'integration-test-recorder-115'. Close #115
- Loading branch information
Showing
2 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(require 'pacmacs) | ||
|
||
(require 'cl-lib) | ||
|
||
(defvar pacmacs--tick-counter 0) | ||
(defvar pacmacs--recorded-actions nil) | ||
|
||
(defun pacmacs--record-action (action-name) | ||
(add-to-list 'pacmacs--recorded-actions | ||
(cons action-name pacmacs--tick-counter))) | ||
|
||
(defun pacmacs--reset-recorder () | ||
(setq pacmacs--tick-counter 0) | ||
(setq pacmacs--recorded-actions nil)) | ||
|
||
(defun pacmacs--save-test-case (filename) | ||
(interactive "FFile to save the test case: ") | ||
(with-temp-buffer | ||
(-> pacmacs--recorded-actions | ||
(reverse) | ||
(pp-to-string) | ||
(insert)) | ||
(write-file filename))) | ||
|
||
(defun pacmacs-record-up () | ||
(interactive) | ||
(pacmacs--record-action 'up) | ||
(pacmacs-up)) | ||
|
||
(defun pacmacs-record-down () | ||
(interactive) | ||
(pacmacs--record-action 'down) | ||
(pacmacs-down)) | ||
|
||
(defun pacmacs-record-left () | ||
(interactive) | ||
(pacmacs--record-action 'left) | ||
(pacmacs-left)) | ||
|
||
(defun pacmacs-record-right () | ||
(interactive) | ||
(pacmacs--record-action 'right) | ||
(pacmacs-right)) | ||
|
||
(defun pacmacs-record-tick () | ||
(interactive) | ||
(cl-incf pacmacs--tick-counter) | ||
(pacmacs-tick)) | ||
|
||
(define-derived-mode pacmacs-it-recorder-mode pacmacs-mode "pacmacs-it-recorder-mode" | ||
(define-key pacmacs-it-recorder-mode-map (kbd "<up>") 'pacmacs-record-up) | ||
(define-key pacmacs-it-recorder-mode-map (kbd "<down>") 'pacmacs-record-down) | ||
(define-key pacmacs-it-recorder-mode-map (kbd "<left>") 'pacmacs-record-left) | ||
(define-key pacmacs-it-recorder-mode-map (kbd "<right>") 'pacmacs-record-right)) | ||
|
||
(defun pacmacs--start-it-recorder () | ||
(interactive) | ||
(pacmacs--initialize-game 'pacmacs-record-tick) | ||
(pacmacs-it-recorder-mode) | ||
(pacmacs--reset-recorder)) |