[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/beancount ad26ec2b29 025/103: beancount.el: Add fontificat
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/beancount ad26ec2b29 025/103: beancount.el: Add fontification tests |
Date: |
Mon, 29 Apr 2024 15:59:42 -0400 (EDT) |
branch: elpa/beancount
commit ad26ec2b29078f174899e8590eff17606389b302
Author: Daniele Nicolodi <daniele@grinta.net>
Commit: Daniele Nicolodi <daniele@grinta.net>
beancount.el: Add fontification tests
---
beancount-tests.el | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/beancount-tests.el b/beancount-tests.el
index 56f11a0a44..10e1b4d58d 100644
--- a/beancount-tests.el
+++ b/beancount-tests.el
@@ -23,3 +23,91 @@
(with-temp-buffer
(beancount-mode)
(font-lock-ensure)))
+
+(defun beancount-test-fontify-string (string)
+ "Fontify STRING in beancount-mode."
+ (with-temp-buffer
+ (insert string)
+ (beancount-mode)
+ (font-lock-ensure)
+ (buffer-string)))
+
+(defun beancount-test-face-groups (fontified)
+ "Group a fontified string by face.
+Return a list of substrings each followed by its face."
+ (cl-loop for start = 0 then end
+ while start
+ for end = (next-single-property-change start 'face fontified)
+ for prop = (get-text-property start 'face fontified)
+ for text = (substring-no-properties fontified start end)
+ if prop
+ append (list text prop)))
+
+(defun beancount-test-group-str-by-face (str)
+ "Fontify `str' in beancount-mode and group it by face.
+Return a list of substrings each followed by its face."
+ (beancount-test-face-groups (beancount-test-fontify-string str)))
+
+(defun beancount-test-font-lock (source face-groups)
+ "Test that `source' fontifies to the expected `face-groups'."
+ (should (equal (beancount-test-group-str-by-face source) face-groups)))
+
+(ert-deftest beancount/fontify-001 ()
+ :tags '(font regress)
+ (beancount-test-font-lock "
+2019-01-01 * \"Example\"
+ Expenses:Example 1.00 USD
+ Assets:Checking
+"
+ '("2019-01-01" beancount-date
+ "*" beancount-narrative-cleared
+ "\"Example\"" beancount-narrative-cleared
+ "Expenses:Example" beancount-account
+ "1.00 USD" beancount-amount
+ "Assets:Checking" beancount-account)))
+
+(ert-deftest beancount/fontify-002 ()
+ :tags '(font regress)
+ (beancount-test-font-lock "
+2019-01-01 ! \"Example\"
+ Expenses:Example 1.00 USD
+ Assets:Checking
+"
+ '("2019-01-01" beancount-date
+ "!" beancount-narrative-pending
+ "\"Example\"" beancount-narrative-pending
+ "Expenses:Example" beancount-account
+ "1.00 USD" beancount-amount
+ "Assets:Checking" beancount-account)))
+
+(ert-deftest beancount/fontify-003 ()
+ :tags '(font regress)
+ (beancount-test-font-lock "
+2019-01-01 A \"Example\"
+ Expenses:Example 1.00 USD
+ Assets:Checking
+"
+ '("2019-01-01" beancount-date
+ "A" beancount-narrative
+ "\"Example\"" beancount-narrative
+ "Expenses:Example" beancount-account
+ "1.00 USD" beancount-amount
+ "Assets:Checking" beancount-account)))
+
+(ert-deftest beancount/fontify-004 ()
+ :tags '(font regress)
+ (beancount-test-font-lock "
+2019-01-01 * \"Example\"
+ #foo
+ ^bar
+ Expenses:Example 1.00 USD
+ Assets:Checking
+"
+ '("2019-01-01" beancount-date
+ "*" beancount-narrative-cleared
+ "\"Example\"" beancount-narrative-cleared
+ "#foo" beancount-tag
+ "^bar" beancount-link
+ "Expenses:Example" beancount-account
+ "1.00 USD" beancount-amount
+ "Assets:Checking" beancount-account)))
- [nongnu] elpa/beancount d5471cf09f 038/103: beancount.el: Highlight headings when combined with outline-minor-mode, (continued)
- [nongnu] elpa/beancount d5471cf09f 038/103: beancount.el: Highlight headings when combined with outline-minor-mode, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 615881f379 054/103: beancount.el: Fix beancount-collect to correctly ignore entry at point, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount da9073b124 096/103: Update readme, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 4750bfa470 098/103: Change keybindings to respect Emacs conventions, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 546163fd2c 102/103: flymake-bean-check: Send buffer contents over stdin, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 9ee4aaa306 009/103: (merge default -> booking), ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 83a046d1dc 010/103: (merge booking -> default), ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount ada0966cdd 012/103: Moved src/python/beancount/... to beancount/..., ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 1da4c88ebb 018/103: Merged in elisp-comment-fixes (pull request #107), ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount ad05238927 022/103: beancount.el: Small simplifications, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount ad26ec2b29 025/103: beancount.el: Add fontification tests,
ELPA Syncer <=
- [nongnu] elpa/beancount 8c52ee05ee 030/103: beancount.el: Revamp function to toggle transaction flag, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 201629317d 032/103: beancount.el: Sort option names alphabetically, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount fa285958d0 033/103: beancount.el: Drop unused function, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount d8d95a2f0a 036/103: beancount.el: Small tests cleanup, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount d4db16f0ee 042/103: beancount.el: Fix fontification of outline headings, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 35d127f8fe 048/103: beancount.el: Add imenu support, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount d51963d156 052/103: beancount.el: Remove redundant :group, ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount 70d4878171 051/103: Merged in default (pull request #133), ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount b377d14caf 047/103: (merge), ELPA Syncer, 2024/04/29
- [nongnu] elpa/beancount ba6bada870 058/103: beancount.el: Rework imenu support and add tests, ELPA Syncer, 2024/04/29