diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/untestable/gdb/gdb_pretty_printer_test.py | 26 | ||||
-rw-r--r-- | tests/untestable/gdb/gdb_pretty_printer_test_program.nim | 57 |
2 files changed, 63 insertions, 20 deletions
diff --git a/tests/untestable/gdb/gdb_pretty_printer_test.py b/tests/untestable/gdb/gdb_pretty_printer_test.py index f002941ec..5b34bcb3d 100644 --- a/tests/untestable/gdb/gdb_pretty_printer_test.py +++ b/tests/untestable/gdb/gdb_pretty_printer_test.py @@ -6,31 +6,47 @@ import gdb # frontends might still be broken. gdb.execute("source ../../../tools/nim-gdb.py") -# debug all instances of the generic function `myDebug`, should be 8 +# debug all instances of the generic function `myDebug`, should be 14 gdb.execute("rbreak myDebug") gdb.execute("run") outputs = [ 'meTwo', + '""', '"meTwo"', '{meOne, meThree}', 'MyOtherEnum(1)', '5', 'array = {1, 2, 3, 4, 5}', + 'seq(0, 0)', + 'seq(0, 10)', + 'array = {"one", "two"}', + 'seq(3, 3) = {1, 2, 3}', 'seq(3, 3) = {"one", "two", "three"}', - 'Table(3, 64) = {["two"] = 2, ["three"] = 3, ["one"] = 1}', + 'Table(3, 64) = {[4] = "four", [5] = "five", [6] = "six"}', + 'Table(3, 8) = {["two"] = 2, ["three"] = 3, ["one"] = 1}', ] for i, expected in enumerate(outputs): + gdb.write(f"{i+1}) expecting: {expected}: ", gdb.STDLOG) + gdb.flush() + functionSymbol = gdb.selected_frame().block().function assert functionSymbol.line == 21 - if i == 5: + if i == 6: # myArray is passed as pointer to int to myDebug. I look up myArray up in the stack gdb.execute("up") - output = str(gdb.parse_and_eval("myArray")) + raw = gdb.parse_and_eval("myArray") + elif i == 9: + # myOtherArray is passed as pointer to int to myDebug. I look up myOtherArray up in the stack + gdb.execute("up") + raw = gdb.parse_and_eval("myOtherArray") else: - output = str(gdb.parse_and_eval("arg")) + raw = gdb.parse_and_eval("arg") + + output = str(raw) assert output == expected, output + " != " + expected + gdb.write(f"passed\n", gdb.STDLOG) gdb.execute("continue") diff --git a/tests/untestable/gdb/gdb_pretty_printer_test_program.nim b/tests/untestable/gdb/gdb_pretty_printer_test_program.nim index 458435c1a..c376ef89a 100644 --- a/tests/untestable/gdb/gdb_pretty_printer_test_program.nim +++ b/tests/untestable/gdb/gdb_pretty_printer_test_program.nim @@ -23,29 +23,56 @@ proc myDebug[T](arg: T): void = proc testProc(): void = var myEnum = meTwo - myDebug(myEnum) + myDebug(myEnum) #1 + + # create a string, but don't allocate it + var myString: string + myDebug(myString) #2 + # create a string object but also make the NTI for MyEnum is generated - var myString = $myEnum - myDebug(myString) + myString = $myEnum + myDebug(myString) #3 + var mySet = {meOne,meThree} - myDebug(mySet) + myDebug(mySet) #4 # for MyOtherEnum there is no NTI. This tests the fallback for the pretty printer. var moEnum = moTwo - myDebug(moEnum) + myDebug(moEnum) #5 + var moSet = {moOne,moThree} - myDebug(moSet) + myDebug(moSet) #6 let myArray = [1,2,3,4,5] - myDebug(myArray) - let mySeq = @["one","two","three"] - myDebug(mySeq) - - var myTable = initTable[string, int]() - myTable["one"] = 1 - myTable["two"] = 2 - myTable["three"] = 3 - myDebug(myTable) + myDebug(myArray) #7 + + # implicitly initialized seq test + var mySeq: seq[string] + myDebug(mySeq) #8 + + # len not equal to capacity + let myOtherSeq = newSeqOfCap[string](10) + myDebug(myOtherSeq) #9 + + let myOtherArray = ["one","two"] + myDebug(myOtherArray) #10 + + # numeric sec + var mySeq3 = @[1,2,3] + myDebug(mySeq3) #11 + + # seq had to grow + var mySeq4 = @["one","two","three"] + myDebug(mySeq4) #12 + + var myTable = initTable[int, string]() + myTable[4] = "four" + myTable[5] = "five" + myTable[6] = "six" + myDebug(myTable) #13 + + var myOtherTable = {"one": 1, "two": 2, "three": 3}.toTable + myDebug(myOtherTable) #14 echo(counter) |