diff options
Diffstat (limited to 'tests/destructor/tnewruntime_strutils.nim')
-rw-r--r-- | tests/destructor/tnewruntime_strutils.nim | 85 |
1 files changed, 74 insertions, 11 deletions
diff --git a/tests/destructor/tnewruntime_strutils.nim b/tests/destructor/tnewruntime_strutils.nim index 5b8684354..9c8d41973 100644 --- a/tests/destructor/tnewruntime_strutils.nim +++ b/tests/destructor/tnewruntime_strutils.nim @@ -1,22 +1,47 @@ discard """ - cmd: '''nim c --newruntime $file''' - output: '''442 442''' + valgrind: true + cmd: '''nim c -d:nimAllocStats --gc:arc -d:useMalloc $file''' + output: ''' +@[(input: @["KXSC", "BGMC"]), (input: @["PXFX"]), (input: @["WXRQ", "ZSCZD"])] +14 +First tasks completed. +Second tasks completed. +test1''' """ -import strutils, os +import strutils, os, std / wordwrap -import core / allocators import system / ansi_c # bug #11004 proc retTuple(): (seq[int], int) = - # XXX this doesn't allocate yet but probably it should return (@[1], 1) +# bug #12899 + +import sequtils, strmisc + +const input = ["KXSC, BGMC => 7 PTHL", "PXFX => LBZJ", "WXRQ, ZSCZD => HLQM"] + +type + Reaction = object + input: seq[string] + +proc bug12899 = + var reactions: seq[Reaction] = @[] + for l in input: + let x = l.partition(" => ") + reactions.add Reaction(input: @(x[0].split(", "))) + + let x = $reactions + echo x + +bug12899() + + proc nonStaticTests = doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000" - when not defined(js): - doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # <=== bug 8242 + doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # bugs 8242, 12586 doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6" doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001" doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in @@ -78,12 +103,12 @@ proc staticTests = inp = """ this is a long text -- muchlongerthan10chars and here it goes""" outp = " this is a\nlong text\n--\nmuchlongerthan10chars\nand here\nit goes" - doAssert wordWrap(inp, 10, false) == outp + doAssert wrapWords(inp, 10, false) == outp let longInp = """ThisIsOneVeryLongStringWhichWeWillSplitIntoEightSeparatePartsNow""" longOutp = "ThisIsOn\neVeryLon\ngStringW\nhichWeWi\nllSplitI\nntoEight\nSeparate\nPartsNow" - doAssert wordWrap(longInp, 8, true) == longOutp + doAssert wrapWords(longInp, 8, true) == longOutp doAssert "$animal eats $food." % ["animal", "The cat", "food", "fish"] == "The cat eats fish." @@ -187,5 +212,43 @@ proc staticTests = nonStaticTests() staticTests() -let (a, d) = allocCounters() -discard cprintf("%ld %ld\n", a, d) +# bug #12965 +let xaa = @[""].join() +let xbb = @["", ""].join() + +# bug #16365 + +# Task 1: +when true: + # Task 1_a: + var test_string_a = "name_something" + echo test_string_a.len() + let new_len_a = test_string_a.len - "_something".len() + test_string_a.setLen new_len_a + + echo "First tasks completed." + +# Task 2: +when true: + # Task 2_a + var test_string: string + let some_string = "something" + for i in some_string.items: + test_string.add $i + + # Task 2_b + var test_string_b = "name_something" + let new_len_b = test_string_b.len - "_something".len() + test_string_b.setLen new_len_b + + echo "Second tasks completed." + +# bug #17450 +proc main = + var i = 1 + echo: + block: + "test" & $i + +main() + |