]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-core.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / test / test-core.el
1 (require 'test-simple)
2 (eval-when-compile (defvar trepan-core))
3
4 (declare-function __FILE__ 'load-relative)
5 (setq trepan-core "../realgud/debugger/trepan/core.el")
6 (load-file "../realgud/common/core.el")
7
8 (declare-function realgud:expand-file-name-if-exists 'realgud-core)
9 (declare-function realgud-parse-command-arg, 'realgud-core)
10 (declare-function realgud:trepan-parse-cmd-args 'realgud:trepan)
11
12 ;; We use a specific language to test core. Here we use trepan.
13 (load-file "../realgud/debugger/trepan/core.el")
14
15 (test-simple-start)
16
17 ;; FIXME: Add a test of relgud-exec-shell where
18 ;; we have two invocation of different files that canonicalize
19 ;; to the same buffer. Make sure the buffers are distinct.
20 ;; For example: bashdb /etc/profile should not match
21 ;; bashdb /tmp/profile
22
23 (note "realgud:expand-file-name-if-exists")
24
25 (assert-equal (realgud:expand-file-name-if-exists "file-not-here")
26 "file-not-here" "no expansion when expanded file doesn't exist")
27
28 (assert-equal (realgud:expand-file-name-if-exists ".")
29 (expand-file-name "."))
30
31 (note "realgud-parse-...")
32
33 (lexical-let ((opt-two-args '("0" "C" "e" "E" "F" "i")))
34 (assert-equal '(("-0" "a") nil)
35 (realgud-parse-command-arg '("-0" "a") '() opt-two-args)
36 "Two args found, none remain afterwards though.")
37
38 (assert-equal
39 '(("-5") ("a" "-0"))
40 (realgud-parse-command-arg '("-5" "a" "-0") '()
41 opt-two-args)
42 "One arg not found.")
43
44 (assert-equal
45 '((nil) nil)
46 (realgud-parse-command-arg '() '() opt-two-args)
47 "Degenerate case - no args"
48 )
49
50 (assert-equal
51 '(("--port" "123") ("bar"))
52 (realgud-parse-command-arg
53 '("--port" "123" "bar") '("-port") '())
54 "two mandatory args"
55 )
56
57 (assert-equal
58 '(("/usr/bin/ruby1.9" "-W") ("trepan") ("foo") nil)
59 (realgud:trepan-parse-cmd-args
60 '("/usr/bin/ruby1.9" "-W" "trepan" "foo"))
61 "Separate Ruby with its arg from debugger and its arg.")
62
63 (assert-equal
64 '(("ruby1.9" "-T3") ("trepan" "--port" "123") ("bar") nil)
65 (realgud:trepan-parse-cmd-args
66 '("ruby1.9" "-T3" "trepan" "--port" "123" "bar"))
67 "Ruby with two args and trepan with two args")
68
69 (assert-equal
70 '(nil ("trepan" "--port" "1" "--annotate=3")
71 ("foo" "a") t)
72 (realgud:trepan-parse-cmd-args
73 '("trepan" "--port" "1" "--annotate=3" "foo" "a"))
74 "trepan with annotate args")
75
76 (assert-equal
77 '(nil ("trepan" "--port" "123")
78 ("foo" "--emacs" "a") nil)
79 (realgud:trepan-parse-cmd-args
80 '("trepan" "--port" "123" "foo" "--emacs" "a"))
81 "trepan with --emacs in the wrong place")
82
83 (assert-equal
84 '(("ruby" "-I/usr/lib/ruby")
85 ("trepan" "-h" "foo" "--emacs")
86 ("baz") t)
87 (realgud:trepan-parse-cmd-args
88 '("ruby" "-I/usr/lib/ruby" "trepan" "-h" "foo"
89 "--emacs" "baz"))
90 "trepan with emacs")
91 )
92
93 (end-tests)