Created
September 14, 2010 23:58
-
-
Save clairvy/579992 to your computer and use it in GitHub Desktop.
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
EMACS = emacs | |
OUTPUT = out | |
TARGET = qsort.el | |
default : test | |
test : | |
$(EMACS) -q --no-site-file --batch -L . -L $$HOME/.emacs.d/auto-install -l el-expectations -f batch-expectations $(OUTPUT) $(TARGET); echo $?; cat $(OUTPUT); $(RM) $(OUTPUT) |
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
;;; how to run | |
;; #!/bin/sh | |
;; EMACS=emacs | |
;; OPTIONS="-L . -L $HOME/emacs/lisp" | |
;; OUTPUT=/tmp/.el-expectations | |
;; $EMACS -q --no-site-file --batch $OPTIONS -l el-expectations -f batch-expectations $OUTPUT "$@" | |
;; ret=$? | |
;; cat $OUTPUT | |
;; rm $OUTPUT | |
;; exit $ret | |
(require 'el-expectations) | |
; 次の関数は何をするか答えてください | |
(defun qsort (lst) | |
(if (cdr lst) | |
(let ((pivot (car lst)) (lst (cdr lst)) right left) | |
(while lst | |
(if (> (car lst) pivot) | |
(setq right (cons (car lst) right)) | |
(setq left (cons (car lst) left))) | |
(setq lst (cdr lst))) | |
(append (qsort left) (list pivot) (qsort right))) | |
lst)) | |
(expectations | |
(desc "qsort defun charactorized test") | |
(expect nil | |
(qsort nil)) | |
(expect nil | |
(qsort '())) | |
(expect '(1) | |
(qsort '(1))) | |
(expect '(1 2 3) | |
(qsort '(1 2 3))) | |
(expect '(1 2 3 4 5) | |
(qsort '(5 4 3 2 1))) | |
(expect '(1 2 3 4 5) | |
(qsort '(5 3 1 4 2))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment