tfailedassert_stacktrace.nim 915 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. cmd: "nim $target $options --excessiveStackTrace:off $file"
  3. output: '''true'''
  4. """
  5. const expected = """
  6. tfailedassert_stacktrace.nim(35) tfailedassert_stacktrace
  7. tfailedassert_stacktrace.nim(34) foo
  8. assertions.nim(*) failedAssertImpl
  9. assertions.nim(*) raiseAssert
  10. fatal.nim(*) sysFatal"""
  11. proc tmatch(x, p: string): bool =
  12. var i = 0
  13. var k = 0
  14. while i < p.len:
  15. if p[i] == '*':
  16. let oldk = k
  17. while k < x.len and x[k] in {'0'..'9'}: inc k
  18. # no digit skipped?
  19. if oldk == k: return false
  20. inc i
  21. elif k < x.len and p[i] == x[k]:
  22. inc i
  23. inc k
  24. else:
  25. return false
  26. while k < x.len and x[k] in {' ', '\L', '\C'}: inc k
  27. result = i >= p.len and k >= x.len
  28. try:
  29. proc foo() =
  30. assert(false)
  31. foo()
  32. except AssertionError:
  33. let e = getCurrentException()
  34. let trace = e.getStackTrace
  35. echo tmatch(trace, expected)