blob: 389f8ba11a09267d0451eb4d57bf5bc7837bbe90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
;;; Test the Info engine. -*- Scheme -*-
;;;
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Skribilo.
;;;
;;; Skribilo is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Skribilo is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(define-module (tests engines info)
:use-module (skribilo ast)
:use-module (skribilo engine)
:use-module (skribilo resolve)
:use-module (skribilo package base)
:use-module (srfi srfi-1)
:use-module (srfi srfi-11)
:use-module (srfi srfi-64))
(define %info
(find-engine 'info))
(define node-next+prev+up
(@@ (skribilo engine info) node-next+prev+up))
(test-begin "info")
(test-assert "empty document"
(let*-values (((doc) (document #:title "t"))
((next prev up) (node-next+prev+up doc %info)))
(and (equal? next "Top")
(equal? prev "(dir)")
(equal? up "(dir)"))))
(test-assert "two chapters"
(let ((doc (document #:title "t"
(chapter #:title "c" "body")
(chapter #:title "d" "body"))))
(resolve! doc %info '())
(let-values (((next prev up) (node-next+prev+up doc %info)))
(and (equal? up "(dir)")
(equal? prev "(dir)")
(equal? next "c")
(let*-values (((ch) (car (markup-body doc)))
((next prev up) (node-next+prev+up ch %info)))
(and (equal? up "Top")
(equal? prev "Top")
(equal? next "d")))
(let*-values (((ch) (cadr (markup-body doc)))
((next prev up) (node-next+prev+up ch %info)))
(and (equal? up "Top")
(equal? prev "c")
(not next)))))))
(test-assert "nest"
(let ((doc (document #:title "t"
"hello"
(chapter #:ident "c" #:title "c"
(p "body")
(section #:ident "s" #:title "s" "body"))
(chapter #:ident "d" #:title "d" "body"))))
(resolve! doc %info '())
(and (let*-values (((ch) (document-lookup-node doc "c"))
((next prev up) (node-next+prev+up ch %info)))
(and (equal? up "Top")
(equal? prev "Top")
(equal? next "d")))
(let*-values (((sec) (document-lookup-node doc "s"))
((next prev up) (node-next+prev+up sec %info)))
(and (equal? up "c")
(not prev)
(not next)))
(let*-values (((sec) (document-lookup-node doc "d"))
((next prev up) (node-next+prev+up sec %info)))
(and (equal? up "Top")
(equal? prev "c")
(not next))))))
(test-end "info")
(exit (= (test-runner-fail-count (test-runner-current)) 0))
;; Local Variables:
;; coding: utf-8
;; eval: (put 'test-assert 'scheme-indent-function 1)
;; End:
|