annotate tests/automated/face-tests.el @ 5915:1af53d35dd53

Avoid allocation in #'integer-length; add #'logcount. lisp/ChangeLog addition: 2015-05-29 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): Add #'integer-length, #'logcount here. * cl-extra.el: * cl-extra.el (integer-length): Update this to avoid allocating memory. * cl-extra.el (logcount): New. Return the number of one bits in INTEGER, if non-negative. Function from Common Lisp. tests/ChangeLog addition: 2015-05-29 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test #'integer-length, #'logcount in this file.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 29 May 2015 17:06:24 +0100
parents f22989bb7632
children
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
5770
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
32 (when (featurep 'font-mgr)
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
33 (let* ((test-name-parts
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
34 '("Bitstream Vera Sans Mono-16"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
35 "familylang=en"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
36 "style=Roman"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
37 "stylelang=en"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
38 "fullname=Bitstream Vera Sans Mono"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
39 "fullnamelang=en"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
40 "slant=0"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
41 "weight=80"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
42 "width=100"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
43 "pixelsize=21.3174"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
44 "spacing=100"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
45 "foundry=bitstream"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
46 "antialias=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
47 "hintstyle=3"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
48 "hinting=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
49 "verticallayout=False"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
50 "autohint=False"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
51 "globaladvance=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
52 "file=/usr/X11/lib/X11/fonts/TTF/VeraMono.ttf"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
53 "index=0"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
54 "outline=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
55 "scalable=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
56 "dpi=95.9282"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
57 "rgba=0"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
58 "scale=1"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
59 "minspace=False"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
60 "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{!!!!) "
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
61 "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"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
62 "fontversion=131072"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
63 "fontformat=TrueType"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
64 "embolden=False"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
65 "embeddedbitmap=True"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
66 "decorative=False"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
67 "lcdfilter=1"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
68 "namelang=en"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
69 "prgname=xemacs"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
70 "hash=sha256\\:da4281dc7db17a3dfce64a62ced92875c5895340055ec8ba24a3914eb97b349d"
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
71 "postscriptname=BitstreamVeraSansMono-Roman"))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
72 (test-name-degenerate "")
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
73 (test-name-trivial (nth 0 test-name-parts))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
74 (test-name-short
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
75 (concat (nth 0 test-name-parts) ":" (nth 26 test-name-parts)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
76 (test-name-long (mapconcat #'identity
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
77 (append (subseq test-name-parts 0 26)
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
78 (subseq test-name-parts 27))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
79 ":"))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
80 (test-name-full (mapconcat #'identity test-name-parts ":")))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
81 (labels ((try (fontname)
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
82 (fc-name-unparse (fc-name-parse fontname)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
83 (try-harder (fontname)
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
84 (fc-name-unparse (fc-name-parse-harder fontname))))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
85 (Assert (string= test-name-degenerate (try test-name-degenerate)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
86 (Assert (string= test-name-degenerate (try-harder test-name-degenerate)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
87 (Assert (string= test-name-trivial (try test-name-trivial)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
88 (Assert (string= test-name-trivial (try-harder test-name-trivial)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
89 ;; Note when the `try' form fails, the `try-harder' form returns a
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
90 ;; shorter name.
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
91 (Check-Error 'invalid-argument
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
92 (string= test-name-short (try test-name-short)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
93 (Assert (string= test-name-trivial (try-harder test-name-short)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
94 (Assert (string= test-name-long (try test-name-long)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
95 (Assert (string= test-name-long (try-harder test-name-long)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
96 ;; Note when the `try' form fails, the `try-harder' form returns a
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
97 ;; shorter name.
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
98 (Check-Error 'invalid-argument
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
99 (string= test-name-full (try test-name-full)))
f22989bb7632 Check (featurep 'font-mgr) before calling fontconfig functions, tests
Aidan Kehoe <kehoea@parhasard.net>
parents: 5763
diff changeset
100 (Assert (string= test-name-long (try-harder test-name-full))))))
5763
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
101
23dc211f4d2f Make fc-name-parse signal on invalid-argument.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
diff changeset
102 ;;; end face-tests.el