summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-06-18 16:58:31 -0700
committerOri Bernstein <ori@eigenstate.org>2015-06-18 16:58:31 -0700
commitcf94e8f3c050f869d11a985f7ac4a4d9a477a9e4 (patch)
treed5af6f3faa597de4b6c2f0014a7f97e3e2a235da /libstd
parent58f59a52b75a9bd3d1be9ae6f4532f5949e45896 (diff)
downloadmc-cf94e8f3c050f869d11a985f7ac4a4d9a477a9e4.tar.gz
Add tests for formatting.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/test/fmt.myr20
1 files changed, 11 insertions, 9 deletions
diff --git a/libstd/test/fmt.myr b/libstd/test/fmt.myr
index 15522af..e6fcb75 100644
--- a/libstd/test/fmt.myr
+++ b/libstd/test/fmt.myr
@@ -7,7 +7,7 @@ const check = {expected, fmt, args : ...
ap = std.vastart(&args)
sl = std.bfmtv(buf[:], fmt, &ap)
if !std.sleq(expected, sl)
- std.fatal("mismatched expected fmt \"{}\", expected \"{}\"\n", sl, expected)
+ std.fatal("mismatched fmt: got \"{}\", expected \"{}\"\n", sl, expected)
;;
}
@@ -17,15 +17,17 @@ const main = {
check("00000bdcae", "%010s", "bdcae")
check("abcdefghijkl", "%010s", "abcdefghijkl")
check("a", "%01s", "a")
- check(" 10", "%10i", 10)
- check("0000000010", "%010i", 10)
- check("4294967295", "%010ui", -1)
- check("-000000001", "%010i", -1)
- check(" -1", "%10i", -1)
- check("100000" , "%3i", 100000)
- check("foobarbaz", "%sbar%s", "foo", "baz")
- check("%sbarbaz", "%%sbar%s", "baz")
*/
+ check(" 10", "{w=10}", 10)
+ check("0000000010", "{p=0,w=10}", 10)
+ check("4294967295", "{p=0,w=10}", -1 castto(uint))
+ check("-000000001", "{p=0,w=10}", -1)
+ check("xxxxxxxx-1", "{p=x,w=10}", -1)
+ check(" -1", "{w=10}", -1)
+ check("100000" , "{3}", 100000)
+ check("foobarbaz", "{}bar{}", "foo", "baz")
+ check("{}barbaz", "{{}}bar{}", "baz")
+ check("{barbaz}", "{{bar{}}}", "baz")
check("abcd", "{}", "abcd")
check("123", "{}", 123)
check("7b", "{x}", 123)