-
Notifications
You must be signed in to change notification settings - Fork 1
/
xml-internal-test.ss
87 lines (79 loc) · 3.48 KB
/
xml-internal-test.ss
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
#lang scheme/base
(require "test-base.ss")
(require "xml-cache.ss"
"range.ss"
"struct.ss"
; Need an uncontracted version of range-fold for testing:
(except-in "xml-internal.ss" range-fold))
(require/expose "xml-internal.ss"
(range-fold))
; Tests ------------------------------------------
(define xml-internal-tests
(test-suite "xml-internal.ss"
(test-case "range-fold"
(let ([accum null])
(range-fold (hc-append #:style
(make-uncompiled-style
(lambda (x y)
(make-compiled-style #:fill (make-solid-fill (rgb (/ x 4)
(/ y 4)
0)))))
"A"
(vc-append #:style
(make-uncompiled-style
(lambda (x y)
(make-compiled-style #:font (make-font #:size y))))
"B"
"C"
"D")
"E")
empty-style
(lambda (x y cell style)
(set! accum (cons (list x y cell style) accum)))
0
0)
(check-equal? (length accum) 9)
; First five entries are from subranges:
(check-equal?
(list-ref (reverse accum) 0)
(list 0 1
(make-cell "A")
(make-compiled-style #:fill (make-solid-fill (rgb (/ 0 4) (/ 1 4) 0)))))
(check-equal?
(list-ref (reverse accum) 1)
(list 1 0
(make-cell "B")
(make-compiled-style #:fill (make-solid-fill (rgb (/ 1 4) (/ 0 4) 0))
#:font (make-font #:size 0))))
(check-equal?
(list-ref (reverse accum) 2)
(list 1 1
(make-cell "C")
(make-compiled-style #:fill (make-solid-fill (rgb (/ 1 4) (/ 1 4) 0))
#:font (make-font #:size 1))))
(check-equal?
(list-ref (reverse accum) 3)
(list 1 2
(make-cell "D")
(make-compiled-style #:fill (make-solid-fill (rgb (/ 1 4) (/ 2 4) 0))
#:font (make-font #:size 2))))
(check-equal?
(list-ref (reverse accum) 4)
(list 2 1
(make-cell "E")
(make-compiled-style #:fill (make-solid-fill (rgb (/ 2 4) (/ 1 4) 0)))))
; Last four entries are from blank spaces:
(check-equal?
(list-ref (reverse accum) 5)
(list 0 0 #f (make-compiled-style #:fill (make-solid-fill (rgb (/ 0 4) (/ 0 4) 0)))))
(check-equal?
(list-ref (reverse accum) 6)
(list 2 0 #f (make-compiled-style #:fill (make-solid-fill (rgb (/ 2 4) (/ 0 4) 0)))))
(check-equal?
(list-ref (reverse accum) 7)
(list 0 2 #f (make-compiled-style #:fill (make-solid-fill (rgb (/ 0 4) (/ 2 4) 0)))))
(check-equal?
(list-ref (reverse accum) 8)
(list 2 2 #f (make-compiled-style #:fill (make-solid-fill (rgb (/ 2 4) (/ 2 4) 0)))))))))
; Provide statements -----------------------------
(provide xml-internal-tests)