Login
7 branches 0 tags
Ben (Win10) Fixed clang fb81367 3 years ago 624 Commits
nujel / testsuite / fmt.nuj
[test/add "asd" [fmt "asd"]]
[test/add "asd" [compile '[fmt "asd"]]]
[test/add "123" [eval [compile '[fmt "{}" 123]]]]
[test/add "asd qwe" [eval [compile '[fmt "asd {}" "qwe"]]]]
[test/add "asd 123" [eval [compile '[fmt "asd {}" 123]]]]
[test/add "asd 123 qwe" [eval [compile '[fmt "asd {} qwe" 123]]]]
[test/add "asd a qwe a" [eval [compile '[fmt "asd {0} qwe {0}" "a"]]]]
[test/add "asd a qwe b" [eval [compile '[fmt "asd {0} qwe {1}" "a" "b"]]]]
[test/add "asd a qwe b" [eval [compile '[fmt "asd {} qwe {}" "a" "b"]]]]
[test/add "asd a qwe b" [eval [compile '[fmt "asd {0} qwe {}" "a" "b"]]]]
[test/add :format-error [try car [compile '[fmt "asd {} qwe {1}" "a" "b"]]]]
[test/add "1 2 2" [eval [compile '[fmt "{} {1} {}" 1 2]]]]
[test/add :format-error [try car [compile '[fmt "{0} {0} {}" 1 2 3]]]]
[test/add "1 1 1" [eval [compile '[fmt "{0} {0} {}" 1]]]]
[test/add "asd qwe" [eval [compile '[fmt "asd {0}" "qwe"]]]]
[test/add :format-error [try car [eval [compile '[fmt "asd {1}" "qwe"]]]]]
[test/add "Hello, World!" [eval [compile '[let [[w "World"]] [fmt "Hello, {w}!"]]]]]
[test/add :type-error [try car [compile '[fmt]]]]
[test/add 1 [string/length [eval [compile '[fmt "{:}" "\n"]]]]]
[test/add 4 [string/length [eval [compile '[fmt "{:?}" "\n"]]]]] ;
[test/add "   255" [eval [compile '[fmt "{:6d}" 255]]]]
[test/add "     99.12" [eval [compile '[fmt "{:10.2d}" 99.1234]]]]
[test/add " 99.12" [eval [compile '[fmt "{:6.2d}" 99.1234]]]]
[test/add "ff" [eval [compile '[fmt "{:x}" 255]]]]
[test/add "#xff" [eval [compile '[fmt "{:x?}" 255]]]]
[test/add "#xFF" [eval [compile '[fmt "{:X?}" 255]]]]
[test/add "1F" [eval [compile '[fmt "{:X}" 31]]]]
[test/add "#d31" [eval [compile '[fmt "{:d?}" 31]]]]
[test/add "31" [eval [compile '[fmt "{:d}" 31]]]]
[test/add "37" [eval [compile '[fmt "{:o}" 31]]]]
[test/add "#o37" [eval [compile '[fmt "{:o?}" 31]]]]
[test/add "#b10011" [eval [compile '[fmt "{:b?}" 19]]]]
[test/add "10011" [eval [compile '[fmt "{:b}" 19]]]]
[test/add "   10011" [eval [compile '[fmt "{:8b}" 19]]]]
[test/add "00010011" [eval [compile '[fmt "{:08b}" 19]]]]
[test/add "#b010011" [eval [compile '[fmt "{:08b?}" 19]]]]
[test/add "#b11" [eval [compile '[fmt "{:04b?}" 19]]]]
[test/add "  13" [eval [compile '[fmt "{:4x}" 19]]]]
[test/add "0013" [eval [compile '[fmt "{:04x}" 19]]]]
[test/add "#x0013" [eval [compile '[fmt "{:06x?}" 19]]]]
[test/add "#x  13" [eval [compile '[fmt "{:6x?}" 19]]]]
[test/add "   asd" [eval [compile '[fmt "{:6}" "asd"]]]]
[test/add "000asd" [eval [compile '[fmt "{:06}" "asd"]]]]
[test/add "00012" [eval [compile '[fmt "{:>05x}" #x12]]]]
[test/add "12   " [eval [compile '[fmt "{:<5x}"  #x12]]]]
[test/add " 12  " [eval [compile '[fmt "{:^5x}"  #x12]]]]
[test/add "   12" [eval [compile '[fmt "{:>5x}"  #x12]]]]
[test/add "12000" [eval [compile '[fmt "{:<05x}" #x12]]]]
[test/add :format-error [try car [compile '[fmt "abc {{}}" "def"]]]]
[test/add :format-error [try car [compile '[fmt "abc {" "def}"]]]]
[test/add :format-error [try car [compile '[fmt "" "abc"]]]]
[test/add "a 0 b cd e 5" [eval [compile '[let [[i 0]] [fmt "a {i} b {} e {}" [cat "c" "d"] [+ 2 3]]]]]]
[test/add "00620062" [fmt "{:08X}" [hash/adler32 "a"]]]
[test/add "0F9D02BC" [fmt "{:08X}" [hash/adler32 "asdQWE123"]]]
[test/add "796B110D" [fmt "{:08X}" [hash/adler32 "DiesIstEinTestDerNujelAdler32Implementierung"]]]
[test/add #t [== [cat test-context " " System/OS " " System/Architecture " " 5] [fmt "{test-context} {System/OS} {System/Architecture} {}" [if #t 5 0]]]]