annotate tests/automated/face-tests.el @ 5763:23dc211f4d2f

Make fc-name-parse signal on invalid-argument. Add fc-name-parse-harder, which retries without unparseable attributes. Add tests for fc-name-parse and fc-name-parse-harder. A few fixups in comments and docstrings.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sun, 15 Sep 2013 23:50:20 +0900
parents
children f22989bb7632
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5763
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
1 ;;; face-tests.el --- test text display (faces, fonts) -*- coding: utf-8 -*-
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
2
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
4
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
5 ;; Author: Stephen J. Turnbull <stephen@xemacs.org>
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
6 ;; Created: 2013
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
7 ;; Keywords: tests
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
8
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
9 ;; This file is part of XEmacs.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
10
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
14 ;; option) any later version.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
15
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
19 ;; for more details.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
20
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
23
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
25
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
26 ;;; Commentary:
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
27
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
28 ;; Test text display (faces, fonts)
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
29
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
30 ;; Test fontconfig
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
31
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
32 (let* ((test-name-parts
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
33 '("Bitstream Vera Sans Mono-16"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
34 "familylang=en"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
35 "style=Roman"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
36 "stylelang=en"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
37 "fullname=Bitstream Vera Sans Mono"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
38 "fullnamelang=en"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
39 "slant=0"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
40 "weight=80"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
41 "width=100"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
42 "pixelsize=21.3174"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
43 "spacing=100"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
44 "foundry=bitstream"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
45 "antialias=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
46 "hintstyle=3"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
47 "hinting=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
48 "verticallayout=False"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
49 "autohint=False"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
50 "globaladvance=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
51 "file=/usr/X11/lib/X11/fonts/TTF/VeraMono.ttf"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
52 "index=0"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
53 "outline=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
54 "scalable=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
55 "dpi=95.9282"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
56 "rgba=0"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
57 "scale=1"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
58 "minspace=False"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
59 "charset= |>^1!|>^1!P0oWQ |>^1!|>^1!|>^1!!!!%#gfN8.!!B7%ggR6OF3y?4!!K?& !!!)$ 9;*f! !!!.% !!!)$!!!!# !!#0GM>RAd#y#fx !!!W5 !!#3H !!!!& !!#6I<UKaX!!!?+!!!%#!!!!X !!#AL !!!1& !!+u{!!!!) "
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
60 "lang=aa|ay|bi|br|ch|co|da|de|en|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|ia|id|ie|io|is|it|lb|mg|nb|nds|nl|nn|no|nr|nso|oc|om|pt|rm|sma|smj|so|sq|ss|st|sv|sw|tl|tn|tr|ts|uz|vo|vot|wa|xh|yap|zu|an|crh|fil|ht|jv|kj|ku-tr|kwm|li|ms|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
61 "fontversion=131072"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
62 "fontformat=TrueType"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
63 "embolden=False"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
64 "embeddedbitmap=True"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
65 "decorative=False"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
66 "lcdfilter=1"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
67 "namelang=en"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
68 "prgname=xemacs"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
69 "hash=sha256\\:da4281dc7db17a3dfce64a62ced92875c5895340055ec8ba24a3914eb97b349d"
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
70 "postscriptname=BitstreamVeraSansMono-Roman"))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
71 (test-name-degenerate "")
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
72 (test-name-trivial (nth 0 test-name-parts))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
73 (test-name-short
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
74 (concat (nth 0 test-name-parts) ":" (nth 26 test-name-parts)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
75 (test-name-long (mapconcat #'identity
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
76 (append (subseq test-name-parts 0 26)
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
77 (subseq test-name-parts 27))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
78 ":"))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
79 (test-name-full (mapconcat #'identity test-name-parts ":"))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
80 )
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
81 (labels ((try (fontname)
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
82 (fc-name-unparse (fc-name-parse fontname)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
83 (try-harder (fontname)
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
84 (fc-name-unparse (fc-name-parse-harder fontname))))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
85 (Assert (string= test-name-degenerate (try test-name-degenerate)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
86 (Assert (string= test-name-degenerate (try-harder test-name-degenerate)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
87 (Assert (string= test-name-trivial (try test-name-trivial)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
88 (Assert (string= test-name-trivial (try-harder test-name-trivial)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
89 ;; Note when the `try' form fails, the `try-harder' form returns a
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
90 ;; shorter name.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
91 (Check-Error 'invalid-argument
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
92 (string= test-name-short (try test-name-short)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
93 (Assert (string= test-name-trivial (try-harder test-name-short)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
94 (Assert (string= test-name-long (try test-name-long)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
95 (Assert (string= test-name-long (try-harder test-name-long)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
96 ;; Note when the `try' form fails, the `try-harder' form returns a
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
97 ;; shorter name.
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
98 (Check-Error 'invalid-argument
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
99 (string= test-name-full (try test-name-full)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
100 (Assert (string= test-name-long (try-harder test-name-full)))
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
101 ) ; labels
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
102 ) ; let
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
103
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
104 ;;; end face-tests.el