Login
7 branches 0 tags
Ben (X13/Arch) Simplified things a little 0643405 9 days ago 1260 Commits
nujel / tests / testsuite / fmt.nuj
("asd" (fmt "asd"))
("asd" (macroexpand (fmt "asd")))
("123" (eval (macroexpand (fmt "{}" 123))))
("asd qwe" (eval (macroexpand (fmt "asd {}" "qwe"))))
("asd 123" (eval (macroexpand (fmt "asd {}" 123))))
("asd 123 qwe" (eval (macroexpand (fmt "asd {} qwe" 123))))
("asd a qwe a" (eval (macroexpand (fmt "asd {0} qwe {0}" "a"))))
("asd a qwe b" (eval (macroexpand (fmt "asd {0} qwe {1}" "a" "b"))))
("asd a qwe b" (eval (macroexpand (fmt "asd {} qwe {}" "a" "b"))))
("asd a qwe b" (eval (macroexpand (fmt "asd {0} qwe {}" "a" "b"))))
(:format-error (try car (macroexpand (fmt "asd {} qwe {1}" "a" "b"))))
("1 2 2" (eval (macroexpand (fmt "{} {1} {}" 1 2))))
(:format-error (try car (macroexpand (fmt "{0} {0} {}" 1 2 3))))
("1 1 1" (eval (macroexpand (fmt "{0} {0} {}" 1))))
("asd qwe" (eval (macroexpand (fmt "asd {0}" "qwe"))))
(:format-error (try car (eval (macroexpand (fmt "asd {1}" "qwe")))))
("Hello, World!" (eval (macroexpand (let ((w "World")) (fmt "Hello, {w}!")))))
(:type-error (try car (macroexpand (fmt))))
(1 (:length (eval (macroexpand (fmt "{:}" "\n")))))
(4 (:length (eval (macroexpand (fmt "{:?}" "\n"))))) ;
("   255" (eval (macroexpand (fmt "{:6d}" 255))))
("     99.12" (eval (macroexpand (fmt "{:10.2d}" 99.1234))))
(" 99.12" (eval (macroexpand (fmt "{:6.2d}" 99.1234))))
("ff" (eval (macroexpand (fmt "{:x}" 255))))
("#xff" (eval (macroexpand (fmt "{:x?}" 255))))
("#xFF" (eval (macroexpand (fmt "{:X?}" 255))))
("1F" (eval (macroexpand (fmt "{:X}" 31))))
("#d31" (eval (macroexpand (fmt "{:d?}" 31))))
("31" (eval (macroexpand (fmt "{:d}" 31))))
("37" (eval (macroexpand (fmt "{:o}" 31))))
("#o37" (eval (macroexpand (fmt "{:o?}" 31))))
("#b10011" (eval (macroexpand (fmt "{:b?}" 19))))
("10011" (eval (macroexpand (fmt "{:b}" 19))))
("   10011" (eval (macroexpand (fmt "{:8b}" 19))))
("00010011" (eval (macroexpand (fmt "{:08b}" 19))))
("#b010011" (eval (macroexpand (fmt "{:08b?}" 19))))
("#b11" (eval (macroexpand (fmt "{:04b?}" 19))))
("  13" (eval (macroexpand (fmt "{:4x}" 19))))
("0013" (eval (macroexpand (fmt "{:04x}" 19))))
("#x0013" (eval (macroexpand (fmt "{:06x?}" 19))))
("#x  13" (eval (macroexpand (fmt "{:6x?}" 19))))
("   asd" (eval (macroexpand (fmt "{:6}" "asd"))))
("000asd" (eval (macroexpand (fmt "{:06}" "asd"))))
("00012" (eval (macroexpand (fmt "{:>05x}" #x12))))
("12   " (eval (macroexpand (fmt "{:<5x}"  #x12))))
(" 12  " (eval (macroexpand (fmt "{:^5x}"  #x12))))
("   12" (eval (macroexpand (fmt "{:>5x}"  #x12))))
("12000" (eval (macroexpand (fmt "{:<05x}" #x12))))
(:format-error (try car (macroexpand (fmt "abc {{}}" "def"))))
(:format-error (try car (macroexpand (fmt "abc {" "def}"))))
(:format-error (try car (macroexpand (fmt "" "abc"))))
("a 0 b cd e 5" (eval (macroexpand (let ((i 0)) (fmt "a {i} b {} e {}" (cat "c" "d") (+ 2 3))))))
("00620062" (fmt "{:08X}" (do (require :crypto/adler32) (crypto/adler32/hash "a")))) ; These can be left in to test the require form
("0F9D02BC" (fmt "{:08X}" (do (require :crypto/adler32) (crypto/adler32/hash "asdQWE123"))))
("796B110D" (fmt "{:08X}" (do (import (hash :as adler32) :crypto/adler32) (adler32 "DiesIstEinTestDerNujelAdler32Implementierung")))) ; These can be left in to test the import form
(#t (= (cat System/OS " " System/Architecture " " 5) (fmt "{System/OS} {System/Architecture} {}" (if #t 5 0))))