Permalink
Browse files

DRY test code.

  • Loading branch information...
1 parent 9cbef50 commit 53acebf1be7d15cacb7ac09e24da05f708ae9b44 @rocky rocky committed Jul 1, 2012
View
@@ -7,3 +7,4 @@
(font-lock-fontify-buffer)
(goto-char (point-min))
))
+
View
@@ -8,3 +8,12 @@
(string-match (dbgr-loc-pat-regexp var) text)
)
+(defun prompt-match(prompt-str &optional num-str fmt-str)
+ (unless fmt-str (setq fmt-str "debugger prompt %s"))
+ (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
+ prompt-str)
+ (format fmt-str prompt-str))
+ (if num-str
+ (assert-equal num-str (substring prompt-str
+ (match-beginning 1) (match-end 1))))
+)
View
@@ -1,21 +1,15 @@
(require 'test-simple)
(load-file "../dbgr/debugger/bashdb/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
-(setq prompt-pat (gethash "prompt" dbgr-bashdb-pat-hash))
-
-(defun prompt-match(prompt-str num-str)
- (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
- prompt-str))
- (assert-equal num-str (substring prompt-str
- (match-beginning 1) (match-end 1)))
-)
+(setq prompt-pat (gethash "prompt" dbgr-bashdb-pat-hash))
(note "bashdb prompt matching")
(prompt-match "bashdb<10> " "10")
-(prompt-match "bashdb<(5)> " "5")
-(prompt-match "bashdb<<1>> " "1")
+(prompt-match "bashdb<(5)> " "5" "subshell prompt %s")
+(prompt-match "bashdb<<1>> " "1" "nested debug prompt %s")
(note "debugger-backtrace")
(setq dbgr-pat-bat (gethash "debugger-backtrace"
View
@@ -1,5 +1,6 @@
(require 'test-simple)
(load-file "../dbgr/debugger/pdb/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
@@ -16,15 +17,6 @@
(set (make-local-variable 'tb-pat)
(gethash "lang-backtrace" dbgr-pdb-pat-hash))
-(defun loc-match(text var)
- (string-match (dbgr-loc-pat-regexp var) text)
-)
-
-(defun prompt-match(prompt-str msg-fmt)
- (assert-equal 0 (loc-match prompt-str prompt-pat)
- (format msg-fmt prompt-str))
-)
-
;; FIXME: we get a void variable somewhere in here when running
;; even though we define it in lexical-let. Dunno why.
;; setq however will workaround this.
@@ -60,8 +52,6 @@
bps-pat)
text) "extract breakpoint line number")
-(note "pdb prompt matching")
-
;; (set text "(c:\\working\\python\\helloworld.py:30): <module>")
;;
;; (assert-t (numberp (loc-match text loc-pat)) "MS DOS position location")
@@ -91,11 +81,11 @@
"extract line number")
-(set (make-local-variable 'prompt-str) "(Pdb) ")
(note "prompt matching")
-(prompt-match prompt-str "valid debugger prompt: %s")
+(set (make-local-variable 'prompt-str) "(Pdb) ")
+(prompt-match prompt-str nil "debugger prompt: %s")
(setq prompt-str "((Pdb)) ")
-(prompt-match prompt-str "valid nested debugger prompt: %s")
+(prompt-match prompt-str nil "nested debugger prompt: %s")
(setq prompt-str "Pdb) ")
(assert-nil (numberp (loc-match prompt-str prompt-pat))
(format "%s %s" "invalid debugger prompt"
@@ -1,6 +1,7 @@
(require 'test-simple)
(load-file "../dbgr/common/buffer/command.el")
(load-file "../dbgr/debugger/perldb/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
@@ -18,11 +19,6 @@
:line-group (dbgr-loc-pat-line-group loc-pat)))
-(defun prompt-match(prompt-str num-str)
- (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
- prompt-str))
-)
-
(note "prompt")
(prompt-match " DB<2> " "2")
(prompt-match "[pid=6489->6502] DB<1> " "1")
@@ -31,9 +27,6 @@
"(eval 1006)[../example/eval.pl:5]")
"perldb file ignore matching")
-(prompt-match " DB<2> " "2")
-(prompt-match "[pid=6489->6502] DB<1> " "1")
-
(defun loc-match(text)
(string-match (dbgr-cmdbuf-info-loc-regexp dbgr) text)
)
@@ -1,5 +1,6 @@
(require 'test-simple)
(load-file "../dbgr/debugger/remake/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
@@ -8,13 +9,6 @@
(set (make-local-variable 'frame-pat)
(gethash "debugger-backtrace" dbgr-remake-pat-hash))
-(defun prompt-match(prompt-str num-str)
- (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
- prompt-str))
- (assert-equal num-str (substring prompt-str
- (match-beginning 1) (match-end 1)))
-)
-
(note "remake prompt")
(prompt-match "remake<10> " "10")
(prompt-match "remake<<1>> " "1")
View
@@ -1,5 +1,6 @@
(require 'test-simple)
(load-file "../dbgr/debugger/trepan/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
@@ -14,15 +15,6 @@
(set (make-local-variable 'ctrl-pat)
(gethash "control-frame" dbgr-trepan-pat-hash))
-(defun loc-match(text var)
- (string-match (dbgr-loc-pat-regexp var) text)
-)
-
-(defun prompt-match(prompt-str)
- (assert-equal 0 (loc-match prompt-str prompt-pat)
- (format "valid prompt %s" prompt-str))
-)
-
;; FIXME: we get a void variable somewhere in here when running
;; even though we define it in lexical-let. Dunno why.
;; setq however will workaround this.
@@ -84,9 +76,9 @@
(note "prompt")
(prompt-match "(trepan): ")
-(prompt-match "((trepan)): ")
-(prompt-match "((trepan@55)): ")
-(prompt-match "((trepan@main)): ")
+(prompt-match "((trepan)): " nil "nested debugger prompt: %s")
+(prompt-match "((trepan@55)): " nil "nested debugger prompt with addr: %s")
+(prompt-match "((trepan@main)): " nil "nested debugger prompt with method: %s")
(setq prompt-str "trepan:")
(assert-nil (loc-match prompt-str prompt-pat)
(format "invalid prompt %s" prompt-str))
View
@@ -1,22 +1,16 @@
(require 'test-simple)
(load-file "../dbgr/debugger/zshdb/init.el")
+(load-file "./regexp-helper.el")
(test-simple-start)
-(setq prompt-pat (gethash "prompt" dbgr-zshdb-pat-hash))
+(setq prompt-pat (gethash "prompt" dbgr-zshdb-pat-hash))
(setq frame-pat (gethash "debugger-backtrace" dbgr-zshdb-pat-hash))
-(defun prompt-match(prompt-str num-str)
- (assert-equal 0 (string-match (dbgr-loc-pat-regexp prompt-pat)
- prompt-str))
- (assert-equal num-str (substring prompt-str
- (match-beginning 1) (match-end 1)))
-)
-
(note "zshdb prompt matching")
(prompt-match "zshdb<10> " "10")
-(prompt-match "zshdb<(5)> " "5")
-(prompt-match "zshdb<<1>> " "1")
+(prompt-match "zshdb<(5)> " "5" "subshell prompt %s")
+(prompt-match "zshdb<<1>> " "1" "nested debug prompt %s")
(note "zshdb frame matching")

0 comments on commit 53acebf

Please sign in to comment.