doomemacs/core/test/test-autoload-message.el
Henrik Lissner 4d10c28c37
Change doom-ansi-apply, print! & format!
Color let-functions no longer take format string arguments. e.g.

  (format! (red "Hello %s" "world"))

Becomes

  (format! (red "Hello %s") "world")

The same goes for print!. Also, doom-ansi-apply now takes two arguments
instead of three.

Also merges doom-message-{fg,bg,fx} into doom-ansi-alist, and reduces
backtrace noise when errors originate from inside these macros.
2018-09-09 09:58:20 -04:00

38 lines
1.6 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;; -*- no-byte-compile: t; -*-
;;; core/test/test-autoload-message.el
(describe "core/autoload/message"
(describe "format!"
:var (noninteractive)
(before-all (setq noninteractive t))
(it "should be a drop-in replacement for `format'"
(expect (format! "Hello %s" "World")
:to-equal "Hello World"))
(it "supports ansi coloring in noninteractive sessions"
(expect (format! (red "Hello %s") "World")
:to-equal "Hello World"))
(it "supports faces in interactive sessions"
(let (noninteractive)
(expect (get-text-property 0 'face (format! (red "Hello %s") "World"))
:to-equal (list :foreground (face-foreground 'term-color-red)))))
(it "supports nested color specs"
(expect (format! (bold (red "Hello %s")) "World")
:to-equal (format "\e[%dm%s\e[0m" 1
(format "\e[%dm%s\e[0m" 31 "Hello World")))
(expect (format! (on-red (bold "Hello %s")) "World")
:to-equal (format "\e[%dm%s\e[0m" 41
(format "\e[%dm%s\e[0m" 1 "Hello World")))
(expect (format! (dark (white "Hello %s")) "World")
:to-equal (format "\e[%dm%s\e[0m" 2
(format "\e[%dm%s\e[0m" 37 "Hello World"))))
(it "supports dynamic color apply syntax"
(expect (format! (color 'red "Hello %s") "World")
:to-equal (format! (red "Hello %s") "World"))
(expect (format! (color (if nil 'red 'blue) "Hello %s") "World")
:to-equal (format! (blue "Hello %s") "World")))))