[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 64/255: passing all tests
From: |
Eric Schulte |
Subject: |
[elpa] 64/255: passing all tests |
Date: |
Sun, 16 Mar 2014 01:02:20 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 0580b00a3d1228d9b48e22789f20cc5b86c7123b
Author: Eric Schulte <address@hidden>
Date: Tue May 22 11:05:31 2012 -0400
passing all tests
---
sgf-board.el | 6 +++-
sgf-tests.el | 82 +++++++++++++++++++++++++++-------------------------------
2 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/sgf-board.el b/sgf-board.el
index a8d639e..caf6360 100644
--- a/sgf-board.el
+++ b/sgf-board.el
@@ -140,11 +140,15 @@
(set (make-local-variable 'sgf-sgf) game)
(set (make-local-variable 'sgf-index) '(0))
;; TODO: this shouldn't be required
- (unless (tree-equal sgf-index '(0)) (setq sgf-index '(0)))
+ (unless (tree-equal sgf-index '(0))
+ (setq sgf-index '(0))
+ (setf (car sgf-index) 0))
(let* ((root (sgf-ref sgf-sgf sgf-index))
(name (or (aget root :GN)
(aget root :EV)))
(size (or (aget root :S) (aget root :SZ)
+ (unless (tree-equal sgf-index '(0))
+ (error "sgf: bad index %S" sgf-index))
(error "sgf: game has no associated size"))))
(when name (rename-buffer name 'unique))
(set (make-local-variable 'sgf-board) (make-board size))
diff --git a/sgf-tests.el b/sgf-tests.el
index 47a48d3..d1e3a8c 100644
--- a/sgf-tests.el
+++ b/sgf-tests.el
@@ -122,6 +122,7 @@
`(let* ((sgf (sgf2el-file-to-el ,file))
(buffer (display-sgf sgf)))
(unwind-protect (with-current-buffer buffer ,@body)
+ (set-default 'sgf-index '(0))
(should (kill-buffer buffer)))))
(def-edebug-spec parse-many (file body))
@@ -138,47 +139,40 @@
(should (= points-length
(length (assoc :points (sgf-ref sgf '(0)))))))))
-;; (ert-deftest sgf-neighbors ()
-;; (let ((board (make-board 19)))
-;; (should (= 2 (length (neighbors board 0))))
-;; (should (= 2 (length (neighbors board (length board)))))
-;; (should (= 4 (length (neighbors board (/ (length board) 2)))))
-;; (should (= 3 (length (neighbors board 1))))))
-
-;; (ert-deftest sgf-singl-stone-capture ()
-;; (flet ((counts () (cons (stones-for local-board :b)
-;; (stones-for local-board :w))))
-;; (with-sgf-file "sgf-files/1-capture.sgf"
-;; (right 3) (should (tree-equal (counts) '(2 . 0))))))
-
-;; (ert-deftest sgf-remove-dead-stone-ko ()
-;; (flet ((counts () (cons (stones-for local-board :b)
-;; (stones-for local-board :w))))
-;; (with-sgf-file "sgf-files/ko.sgf"
-;; (should (tree-equal (counts) '(0 . 0))) (right 1)
-;; (should (tree-equal (counts) '(1 . 0))) (right 1)
-;; (should (tree-equal (counts) '(1 . 1))) (right 1)
-;; (should (tree-equal (counts) '(2 . 1))) (right 1)
-;; (should (tree-equal (counts) '(2 . 2))) (right 1)
-;; (should (tree-equal (counts) '(3 . 2))) (right 1)
-;; (should (tree-equal (counts) '(2 . 3))) (right 1)
-;; (should (tree-equal (counts) '(3 . 2))) (right 1)
-;; (should (tree-equal (counts) '(2 . 3))))))
-
-;; (ert-deftest sgf-two-stone-capture ()
-;; (flet ((counts () (cons (stones-for local-board :b)
-;; (stones-for local-board :w))))
-;; (with-sgf-file "sgf-files/2-capture.sgf"
-;; (right 8) (should (tree-equal (counts) '(6 . 0))))))
-
-;; (ert-deftest sgf-parse-empty-properties ()
-;; (with-sgf-file "sgf-files/w-empty-properties.sgf"
-;; (should (remove-if-not (lambda (prop)
-;; (let ((val (cdr prop)))
-;; (and (sequencep val) (= 0 (length val)))))
-;; (car sgf)))))
-
-;; (ert-deftest sgf-paren-matching ()
-;; (let ((str "(a (b) [c \\] ) ] d)"))
-;; (should (= (closing-paren str) (length str)))
-;; (should (= (closing-paren str 3) 6))))
+(ert-deftest sgf-neighbors ()
+ (let ((board (make-board 19)))
+ (should (= 2 (length (neighbors board 0))))
+ (should (= 2 (length (neighbors board (length board)))))
+ (should (= 4 (length (neighbors board (/ (length board) 2)))))
+ (should (= 3 (length (neighbors board 1))))))
+
+(defun stone-counts ()
+ (cons (stones-for sgf-board :B)
+ (stones-for sgf-board :W)))
+
+(ert-deftest sgf-singl-stone-capture ()
+ (with-sgf-file "sgf-files/1-capture.sgf"
+ (right 3) (should (tree-equal (stone-counts) '(2 . 0)))))
+
+(ert-deftest sgf-remove-dead-stone-ko ()
+ (with-sgf-file "sgf-files/ko.sgf"
+ (should (tree-equal (stone-counts) '(0 . 0))) (right 1)
+ (should (tree-equal (stone-counts) '(1 . 0))) (right 1)
+ (should (tree-equal (stone-counts) '(1 . 1))) (right 1)
+ (should (tree-equal (stone-counts) '(2 . 1))) (right 1)
+ (should (tree-equal (stone-counts) '(2 . 2))) (right 1)
+ (should (tree-equal (stone-counts) '(3 . 2))) (right 1)
+ (should (tree-equal (stone-counts) '(2 . 3))) (right 1)
+ (should (tree-equal (stone-counts) '(3 . 2))) (right 1)
+ (should (tree-equal (stone-counts) '(2 . 3)))))
+
+(ert-deftest sgf-two-stone-capture ()
+ (with-sgf-file "sgf-files/2-capture.sgf"
+ (right 8) (should (tree-equal (stone-counts) '(6 . 0)))))
+
+(ert-deftest sgf-parse-empty-properties ()
+ (with-sgf-file "sgf-files/w-empty-properties.sgf"
+ (should (remove-if-not (lambda (prop)
+ (let ((val (cdr prop)))
+ (and (sequencep val) (= 0 (length val)))))
+ (car sgf)))))
- [elpa] 41/255: simplified parse-tree, but not done, (continued)
- [elpa] 41/255: simplified parse-tree, but not done, Eric Schulte, 2014/03/15
- [elpa] 53/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 54/255: more parsing/syntax tweaks, Eric Schulte, 2014/03/15
- [elpa] 56/255: some utility functions, Eric Schulte, 2014/03/15
- [elpa] 55/255: new approach to parsing sgf files into elisp, Eric Schulte, 2014/03/15
- [elpa] 61/255: passing first 6 tests, Eric Schulte, 2014/03/15
- [elpa] 59/255: passing first two tests, Eric Schulte, 2014/03/15
- [elpa] 62/255: automatically normalize elisp sgf buffers, Eric Schulte, 2014/03/15
- [elpa] 58/255: able to load and play through games w/sgf2el, Eric Schulte, 2014/03/15
- [elpa] 60/255: passing first five tests, Eric Schulte, 2014/03/15
- [elpa] 64/255: passing all tests,
Eric Schulte <=
- [elpa] 67/255: support for converting *very* large files, Eric Schulte, 2014/03/15
- [elpa] 63/255: consistently passing first 7 tests, Eric Schulte, 2014/03/15
- [elpa] 73/255: indentation, Eric Schulte, 2014/03/15
- [elpa] 66/255: parsing weird comments, Eric Schulte, 2014/03/15
- [elpa] 72/255: tweak header, Eric Schulte, 2014/03/15
- [elpa] 68/255: misc, Eric Schulte, 2014/03/15
- [elpa] 65/255: cleanup and straightening, Eric Schulte, 2014/03/15
- [elpa] 71/255: other new files, Eric Schulte, 2014/03/15
- [elpa] 69/255: better names for dynamic local variables, Eric Schulte, 2014/03/15
- [elpa] 70/255: bringing in some files from my old go-mode, Eric Schulte, 2014/03/15