emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 01/01: Convert remaining `assert' to `cl-assert'.


From: Mario Lang
Subject: [elpa] 01/01: Convert remaining `assert' to `cl-assert'.
Date: Sat, 24 May 2014 01:15:52 +0000

mlang pushed a commit to branch externals/chess
in repository elpa.

commit ae907cb0adfbacb381a06ad2c7770f5a28dba15c
Author: Mario Lang <address@hidden>
Date:   Sat May 24 03:15:19 2014 +0200

    Convert remaining `assert' to `cl-assert'.
---
 chess-algebraic.el |    6 +-
 chess-crafty.el    |    4 +-
 chess-epd.el       |    6 +-
 chess-game.el      |  104 +++++++++++++++++++++++++--------------------------
 chess-module.el    |    2 +-
 chess-pgn.el       |    2 +-
 chess-ply.el       |   42 ++++++++++----------
 chess-var.el       |   24 ++++++------
 8 files changed, 94 insertions(+), 96 deletions(-)

diff --git a/chess-algebraic.el b/chess-algebraic.el
index d90bc11..4a5e11c 100644
--- a/chess-algebraic.el
+++ b/chess-algebraic.el
@@ -90,8 +90,8 @@ This regexp handles both long and short form.")
 
 (defun chess-algebraic-to-ply (position move &optional trust)
   "Convert the algebraic notation MOVE for POSITION to a ply."
-  (assert (vectorp position))
-  (assert (stringp move))
+  (cl-assert (vectorp position))
+  (cl-assert (stringp move))
   (let ((case-fold-search nil))
     (when (string-match chess-algebraic-regexp-entire move)
       (let ((color (chess-pos-side-to-move position))
@@ -213,7 +213,7 @@ This regexp handles both long and short form.")
 (defun chess-ply-to-algebraic (ply &optional long)
   "Convert the given PLY to algebraic notation.
 If LONG is non-nil, render the move into long notation."
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (or (and (not long) (chess-ply-keyword ply :san))
       (and (null (chess-ply-source ply)) "")
       (let ((move (chess-ply--move-text ply long)))
diff --git a/chess-crafty.el b/chess-crafty.el
index 11245b6..53ff416 100644
--- a/chess-crafty.el
+++ b/chess-crafty.el
@@ -164,10 +164,10 @@
            (chess-engine-send nil "hard\n")
          (chess-engine-send nil "easy\n")))
        ((eq (car args) 'search-depth)
-       (assert (and (integerp (cadr args)) (>= (cadr args) 0)))
+       (cl-assert (and (integerp (cadr args)) (>= (cadr args) 0)))
        (chess-engine-send nil (format "sd %d\n" (cadr args))))
        ((eq (car args) 'search-time)
-       (assert (and (integerp (cadr args)) (> (cadr args) 0)))
+       (cl-assert (and (integerp (cadr args)) (> (cadr args) 0)))
        (chess-engine-send nil (format "st %d\n" (cadr args))))))
 
      (t
diff --git a/chess-epd.el b/chess-epd.el
index ac2c0b8..12b4eda 100644
--- a/chess-epd.el
+++ b/chess-epd.el
@@ -44,11 +44,11 @@
        (value (cdr annotation)))
     (cond
      ((or (eq opcode 'am) (eq opcode 'bm))
-      (assert (consp value))
+      (cl-assert (consp value))
       (format "%S %s;"
              opcode (mapconcat #'chess-ply-to-string value " ")))
      ((eq opcode 'ce)
-      (assert (integerp value))
+      (cl-assert (integerp value))
       (format "%S %d;" opcode value))
      ((or (eq opcode 'pv) (eq opcode 'sv))
       (format "%S %s;"
@@ -59,7 +59,7 @@
 (defun chess-pos-to-epd (position)
   "Convert a chess POSITION to a string representation in extended
 position description format."
-  (assert position)
+  (cl-assert position)
   (concat (chess-pos-to-fen position)
          (when (consp (chess-pos-annotations position))
            (concat " "
diff --git a/chess-game.el b/chess-game.el
index 741f664..334ec70 100644
--- a/chess-game.el
+++ b/chess-game.el
@@ -44,19 +44,19 @@
 
 (defsubst chess-game-hooks (game)
   "Return the event hooks associated with GAME."
-  (assert game)
+  (cl-assert game)
   (car game))
 
 (defsubst chess-game-set-hooks (game hooks)
   "Set the event hooks associated with GAME."
-  (assert game)
-  (assert (or hooks (eq hooks nil)))
+  (cl-assert game)
+  (cl-assert (or hooks (eq hooks nil)))
   (setcar game hooks))
 
 (defun chess-game-add-hook (game function &optional data prepend)
   "Add to GAME an event hook FUNCTION."
-  (assert game)
-  (assert function)
+  (cl-assert game)
+  (cl-assert function)
   (let ((hooks (chess-game-hooks game)))
     (if (null hooks)
        (chess-game-set-hooks game (list (cons function data)))
@@ -68,8 +68,8 @@
   "Remove from GAME all event hooks that match FUNCTION.
 If DATA is specified, only remove those hooks whose associated data
 matches."
-  (assert game)
-  (assert function)
+  (cl-assert game)
+  (cl-assert function)
   (let* ((hooks (chess-game-hooks game))
         (h hooks) last-hook)
     (while h
@@ -85,7 +85,7 @@ matches."
 
 (defsubst chess-game-run-hooks (game &rest args)
   "Run the event hooks of GAME and pass ARGS."
-  (assert game)
+  (cl-assert game)
   (unless chess-game-inhibit-events
     (let (result)
       (dolist (hook (chess-game-hooks game) result)
@@ -93,29 +93,29 @@ matches."
 
 (defsubst chess-game-tags (game)
   "Return the tags alist associated with GAME."
-  (assert game)
+  (cl-assert game)
   (cadr game))
 
 (defsubst chess-game-set-tags (game tags)
   "Set the tags alist associated with GAME.
 After the TAGS alist was set the 'set-tags event is triggered."
-  (assert game)
-  (assert (or tags (eq tags nil)))
+  (cl-assert game)
+  (cl-assert (or tags (eq tags nil)))
   (setcar (cdr game) tags)
   (chess-game-run-hooks game 'set-tags))
 
 (defsubst chess-game-tag (game tag)
   "Return the value for TAG in GAME."
-  (assert game)
-  (assert tag)
+  (cl-assert game)
+  (cl-assert tag)
   (let ((tags (chess-game-tags game)))
     (and tags (cdr (assoc tag tags)))))
 
 (defun chess-game-set-tag (game tag value)
   "Set TAG for GAME to VALUE."
-  (assert game)
-  (assert tag)
-  (assert value)
+  (cl-assert game)
+  (cl-assert tag)
+  (cl-assert value)
   (let ((tags (chess-game-tags game)))
     (if (null tags)
        (chess-game-set-tags game (list (cons tag value)))
@@ -127,26 +127,26 @@ After the TAGS alist was set the 'set-tags event is 
triggered."
 
 (defsubst chess-game-del-tag (game tag)
   "Delete TAG from GAME."
-  (assert game)
-  (assert tag)
+  (cl-assert game)
+  (cl-assert tag)
   (chess-game-set-tags game (assq-delete-all tag (chess-game-tags game)))
   (chess-game-run-hooks game 'delete-tag tag))
 
 
 (defsubst chess-game-data-alist (game)
   "Return the data alist associated with GAME."
-  (assert game)
+  (cl-assert game)
   (nth 2 game))
 
 (defsubst chess-game-set-data-alist (game value)
   "Set the data alist associated with GAME."
-  (assert game)
+  (cl-assert game)
   (setcar (nthcdr 2 game) value))
 
 (defun chess-game-set-data (game key value)
   "Set GAME data KEY to VALUE."
-  (assert game)
-  (assert (symbolp key))
+  (cl-assert game)
+  (cl-check-type key symbol)
   (let* ((alist (chess-game-data-alist game))
         (cell (assq key alist)))
     (if cell
@@ -160,16 +160,16 @@ After the TAGS alist was set the 'set-tags event is 
triggered."
 
 (defun chess-game-data (game key)
   "Return the value of GAME data KEY."
-  (assert game)
-  (assert (symbolp key))
+  (cl-assert game)
+  (cl-check-type key symbol)
   (let ((alist (chess-game-data-alist game)))
     (if alist
        (cdr (assq key alist)))))
 
 (defun chess-game-del-data (game key)
   "Delete KEY from GAME's data alist."
-  (assert game)
-  (assert (symbolp key))
+  (cl-assert game)
+  (cl-check-type key symbol)
   (let ((alist (chess-game-data-alist game)))
     (if alist
        (assq-delete-all key alist))))
@@ -177,63 +177,63 @@ After the TAGS alist was set the 'set-tags event is 
triggered."
 
 (defsubst chess-game-plies (game)
   "Return the main variation of GAME as a list of plies."
-  (assert game)
+  (cl-assert game)
   (nth 3 game))
 
 (defalias 'chess-game-main-var 'chess-game-plies)
 
 (defsubst chess-game-set-plies (game plies)
   "Set the list of plies which represents the main variation of GAME."
-  (assert game)
+  (cl-assert game)
   (setcdr (nthcdr 2 game) (if plies (list plies) nil))
   (chess-game-run-hooks game 'setup-game game))
 
 (defsubst chess-game-set-start-position (game position)
   "Set the initial POSITION of GAME."
-  (assert game)
-  (assert (vectorp position))
+  (cl-assert game)
+  (cl-assert (vectorp position))
   (chess-game-set-plies game (list (chess-ply-create* position))))
 
 (defsubst chess-game-pos (game &optional index)
   "Return the current position of GAME or a position of a given INDEX."
-  (assert game)
+  (cl-assert game)
   (chess-ply-pos (chess-game-ply game index)))
 
 (defun chess-game-status (game &optional index)
   "Return a symbol, such as :checkmate, :resign, etc.
 This conveys the status of the game at the given INDEX."
-  (assert game)
+  (cl-assert game)
   (or (chess-pos-status (chess-game-pos game index))
       (chess-ply-final-p (chess-game-ply game index))))
 
 (defsubst chess-game-index (game)
   "Return the GAME's current position index."
-  (assert game)
+  (cl-assert game)
   (1- (length (chess-game-plies game))))
 
 (defsubst chess-game-seq (game)
   "Return the current GAME sequence."
-  (assert game)
+  (cl-assert game)
   (/ (+ 2 (chess-game-index game)) 2))
 
 (defsubst chess-game-side-to-move (game &optional index)
   "Return the color whose move it is in GAME at INDEX (or at the last position
 if INDEX is nil)."
-  (assert game)
+  (cl-assert game)
   (chess-pos-side-to-move (chess-game-pos game index)))
 
 (defun chess-game-ply (game &optional index)
   "Return a ply of GAME.
 If INDEX is non-nil, the last played ply is returned."
-  (assert game)
+  (cl-assert game)
   (if index
       (nth index (chess-game-plies game))
     (car (last (chess-game-plies game)))))
 
 (defun chess-game-add-ply (game ply)
   "Return the position related to GAME's INDEX position."
-  (assert game)
-  (assert (listp ply))
+  (cl-assert game)
+  (cl-check-type ply listp)
   (let ((plies (chess-game-plies game)))
     (if plies
        (nconc plies (list ply))
@@ -246,9 +246,8 @@ If INDEX is non-nil, the last played ply is returned."
 
 (defun chess-game-undo (game count)
   "Undo the last COUNT plies of GAME."
-  (assert game)
-  (assert (integerp count))
-  (assert (> count 0))
+  (cl-assert game)
+  (cl-check-type count (integer 0))
   (if (> count (chess-game-index game))
       (chess-error 'undo-limit-reached))
   (let ((chess-game-inhibit-events t))
@@ -258,7 +257,7 @@ If INDEX is non-nil, the last played ply is returned."
 
 (defun chess-game-strip-annotations (game)
   "Strip all annotations from the given GAME."
-  (assert game)
+  (cl-assert game)
   (dotimes (i (chess-game-index game))
     (let ((position (chess-game-pos game i)))
       (chess-pos-set-annotations position nil))))
@@ -266,25 +265,24 @@ If INDEX is non-nil, the last played ply is returned."
 
 (defsubst chess-game-over-p (game)
   "Return non-nil if GAME is at a final positionn."
-  (assert game)
+  (cl-assert game)
   (let ((last-ply (car (last (nth 3 game) 2))))
     (and last-ply (chess-ply-final-p last-ply))))
 
 
 (defsubst chess-game-to-string (game &optional indented)
   "Convert GAME to a string in PGN format."
-  (assert game)
+  (cl-assert game)
   (chess-game-to-pgn game indented t))
 
 (defsubst chess-game-from-string (pgn)
   "Convert a PGN format string to a chess game object."
-  (assert (stringp pgn))
+  (cl-check-type pgn string)
   (chess-pgn-to-game pgn))
 
-
 (defsubst chess-game-copy-game (game new-game)
-  (assert game)
-  (assert new-game)
+  (cl-assert game)
+  (cl-assert new-game)
   (chess-game-set-tags game (chess-game-tags new-game))
   (chess-game-set-plies game (chess-game-plies new-game)))
 
@@ -308,15 +306,15 @@ later using the various tag-related methods)."
 This creates a new position and adds it to the main variation.
 The 'changes' of the last ply reflect whether the game is currently in
 progress (nil), if it is drawn, resigned, mate, etc."
-  (assert game)
-  (assert (listp ply))
+  (cl-assert game)
+  (cl-assert (listp ply))
   (let ((current-ply (chess-game-ply game))
        (position (chess-ply-pos ply))
        (changes (chess-ply-changes ply)))
 
-    (assert current-ply)
-    (assert (and position (eq position (chess-ply-pos current-ply))))
-    (assert changes)
+    (cl-assert current-ply)
+    (cl-assert (and position (eq position (chess-ply-pos current-ply))))
+    (cl-assert changes)
 
     (if (chess-ply-final-p current-ply)
        (chess-error 'add-to-completed))
diff --git a/chess-module.el b/chess-module.el
index 0a9abf4..01feffc 100644
--- a/chess-module.el
+++ b/chess-module.el
@@ -87,7 +87,7 @@
 
 (defun chess-module-set-game* (module game)
   (chess-with-current-buffer module
-    (assert game)
+    (cl-assert game)
     (if chess-module-game
        (chess-module-detach-game nil))
     (setq chess-module-game game)
diff --git a/chess-pgn.el b/chess-pgn.el
index 5233d7b..7b8322f 100644
--- a/chess-pgn.el
+++ b/chess-pgn.el
@@ -169,7 +169,7 @@ Optionally use the supplied STRING instead of the current 
buffer."
   (dolist (ann (chess-pos-annotations (chess-ply-pos ply)))
     (if (stringp ann)
        (insert "\n{" ann "}")
-      (assert (listp ann))
+      (cl-assert (listp ann))
       (chess-pgn-insert-plies game index ann))))
 
 (defun chess-pgn-insert-plies (game index plies &optional
diff --git a/chess-ply.el b/chess-ply.el
index efc26b5..726b2e7 100644
--- a/chess-ply.el
+++ b/chess-ply.el
@@ -71,34 +71,34 @@
 
 (defsubst chess-ply-pos (ply)
   "Returns the base position associated with PLY."
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (car ply))
 
 (defsubst chess-ply-set-pos (ply position)
   "Set the base position of PLY."
-  (assert (listp ply))
-  (assert (vectorp position))
+  (cl-assert (listp ply))
+  (cl-assert (vectorp position))
   (setcar ply position))
 
 (defsubst chess-ply-changes (ply)
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (cdr ply))
 
 (defsubst chess-ply-set-changes (ply changes)
-  (assert (listp ply))
-  (assert (listp changes))
+  (cl-assert (listp ply))
+  (cl-assert (listp changes))
   (setcdr ply changes))
 
 (defun chess-ply-any-keyword (ply &rest keywords)
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (catch 'found
     (dolist (keyword keywords)
       (if (memq keyword (chess-ply-changes ply))
          (throw 'found keyword)))))
 
 (defun chess-ply-keyword (ply keyword)
-  (assert (listp ply))
-  (assert (symbolp keyword))
+  (cl-assert (listp ply))
+  (cl-assert (symbolp keyword))
   (let ((item (memq keyword (chess-ply-changes ply))))
     (if item
        (if (eq item (last (chess-ply-changes ply)))
@@ -106,8 +106,8 @@
          (cadr item)))))
 
 (defun chess-ply-set-keyword (ply keyword &optional value)
-  (assert (listp ply))
-  (assert (symbolp keyword))
+  (cl-assert (listp ply))
+  (cl-assert (symbolp keyword))
   (let* ((changes (chess-ply-changes ply))
         (item (memq keyword changes)))
     (if item
@@ -120,20 +120,20 @@
 
 (defsubst chess-ply-source (ply)
   "Returns the source square index value of PLY."
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (let ((changes (chess-ply-changes ply)))
     (and (listp changes) (not (symbolp (car changes)))
         (car changes))))
 
 (defsubst chess-ply-target (ply)
   "Returns the target square index value of PLY."
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (let ((changes (chess-ply-changes ply)))
     (and (listp changes) (not (symbolp (car changes)))
         (cadr changes))))
 
 (defsubst chess-ply-next-pos (ply)
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (or (chess-ply-keyword ply :next-pos)
       (let ((position (apply 'chess-pos-move
                             (chess-pos-copy (chess-ply-pos ply))
@@ -142,12 +142,12 @@
        (chess-ply-set-keyword ply :next-pos position))))
 
 (defsubst chess-ply-to-string (ply &optional long)
-  (assert (listp ply))
+  (cl-assert (listp ply))
   (chess-ply-to-algebraic ply long))
 
 (defsubst chess-ply-from-string (position move)
-  (assert (vectorp position))
-  (assert (stringp move))
+  (cl-assert (vectorp position))
+  (cl-assert (stringp move))
   (chess-algebraic-to-ply position move))
 
 (defconst chess-piece-name-table
@@ -158,7 +158,7 @@
 
 (defun chess-ply-castling-changes (position &optional long king-index)
   "Create castling changes; this function supports Fischer Random castling."
-  (assert (vectorp position))
+  (cl-assert (vectorp position))
   (let* ((color (chess-pos-side-to-move position))
         (king (or king-index (chess-pos-king-index position color)))
         (rook (chess-pos-can-castle position (if color
@@ -186,7 +186,7 @@
 (defvar chess-ply-allow-interactive-query nil)
 
 (defsubst chess-ply-create* (position)
-  (assert (vectorp position))
+  (cl-assert (vectorp position))
   (list position))
 
 (defun chess-ply-create (position &optional valid-p &rest changes)
@@ -197,7 +197,7 @@ also extend castling, and will prompt for a promotion piece.
 
 Note: Do not pass in the rook move if CHANGES represents a castling
 maneuver."
-  (assert (vectorp position))
+  (cl-assert (vectorp position))
   (let* ((ply (cons position changes))
         (color (chess-pos-side-to-move position))
         piece)
@@ -346,7 +346,7 @@ criteria.
 
 NOTE: All of the returned plies will reference the same copy of the
 position object passed in."
-  (assert (vectorp position))
+  (cl-assert (vectorp position))
   (cond
    ((null keywords)
     (let ((plies (list t)))
diff --git a/chess-var.el b/chess-var.el
index 8c3334f..a546563 100644
--- a/chess-var.el
+++ b/chess-var.el
@@ -27,43 +27,43 @@
 
 (defsubst chess-var-plies (var)
   "Return the plies of VAR."
-  (assert var)
+  (cl-assert var)
   var)
 
 (defsubst chess-var-pos (var &optional index)
   "Return the position related to VAR's INDEX ply."
-  (assert var)
+  (cl-assert var)
   (chess-ply-pos (chess-var-ply var index)))
 
 (defsubst chess-var-index (var)
   "Return the VAR's current position index."
-  (assert var)
+  (cl-assert var)
   (1- (length (chess-var-plies var))))
 
 (defsubst chess-var-seq (var)
   "Return the current VAR sequence."
-  (assert var)
+  (cl-assert var)
   (1+ (/ (chess-var-index var) 2)))
 
 (defsubst chess-var-side-to-move (var &optional index)
   "Return the color whose move it is in VAR at INDEX (or at the last position
 of the variation if INDEX is nil)."
-  (assert var)
+  (cl-assert var)
   (chess-pos-side-to-move (chess-var-pos var index)))
 
 (defun chess-var-ply (var &optional index)
   "Return VAR's INDEXth ply."
-  (assert var)
+  (cl-assert var)
   (if index
       (nth index (chess-var-plies var))
     (car (last (chess-var-plies var)))))
 
 (defun chess-var-add-ply (var ply)
   "Return the position related to VAR's INDEX position."
-  (assert var)
-  (assert (listp ply))
+  (cl-assert var)
+  (cl-assert (listp ply))
   (let ((plies (chess-var-plies var)))
-    (assert plies)
+    (cl-assert plies)
     (nconc plies (list ply))))
 
 (defsubst chess-var-create (&optional position)
@@ -76,14 +76,14 @@ Optionally use the given starting POSITION."
 This creates a new position and adds it to the main variation.
 The 'changes' of the last ply reflect whether the var is currently in
 progress (nil), if it is drawn, resigned, mate, etc."
-  (assert var)
-  (assert (listp ply))
+  (cl-assert var)
+  (cl-assert (listp ply))
   (let ((current-ply (chess-var-ply var))
        (changes (chess-ply-changes ply))
        (position (chess-ply-pos ply)))
     (if (chess-ply-final-p current-ply)
        (chess-error 'add-to-completed))
-    (assert (eq position (chess-ply-pos current-ply)))
+    (cl-assert (eq position (chess-ply-pos current-ply)))
     (chess-ply-set-changes current-ply changes)
     (chess-var-add-ply var (chess-ply-create*
                            (chess-ply-next-pos current-ply)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]