diff options
author | S. Gilles <sgilles@math.umd.edu> | 2017-10-26 21:06:42 -0400 |
---|---|---|
committer | Ori Bernstein <ori@markovcorp.com> | 2017-10-27 11:52:01 -0700 |
commit | 715cf398c47f4bb36df95a06f506cc714e4933e6 (patch) | |
tree | 19942a7ac67eff195d52c1e792a8626ffa14a55c | |
parent | d02ab96e27f1592534b97108ecbdd93b0f8d4132 (diff) | |
download | libtermdraw-715cf398c47f4bb36df95a06f506cc714e4933e6.tar.gz |
Allow litint with nontrivial start
-rw-r--r-- | test/tifmt.myr | 8 | ||||
-rw-r--r-- | tifmt.myr | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/test/tifmt.myr b/test/tifmt.myr index 01a3fbb..cd02fd5 100644 --- a/test/tifmt.myr +++ b/test/tifmt.myr @@ -20,6 +20,14 @@ const main = { checkfmt(ctx, "%i%p1%d-%p2%d-%p3%s", params, "124-244-abc") }], + /* literals */ + [.name="litint-1", .fn={ctx + checkfmt(ctx, "%{5}%d", [`termdraw.Int 9][:], "5") + }], + [.name="litint-2", .fn={ctx + checkfmt(ctx, "%{5}%{6}%d", [`termdraw.Int 9][:], "6") + }], + /* numeric */ [.name="arith-add", .fn={ctx; binop(ctx, 'd', '+', 10, 21, "31")}], [.name="arith-sub", .fn={ctx; binop(ctx, 'd', '-', 21, 10, "-11")}], @@ -324,6 +324,7 @@ const strfmt = {f, sb, lpad, width, prec, str const scannum = {s : byte[:], start var i, c + var begin = start# i = start while true @@ -333,7 +334,7 @@ const scannum = {s : byte[:], start ;; i# += std.charlen(c) ;; - match std.intparse(s[:i#]) + match std.intparse(s[begin:i#]) | `std.Some n: -> n | `std.None: -> 0 ;; |